diff --git a/.gitignore b/.gitignore index f99867f73a..0b40b42f79 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ __pycache__/ # Test tool cache directories .tox/ .cache/ +.pytest_cache/ diff --git a/.travis.yml b/.travis.yml index 76fc9d3742..e438814946 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,4 +72,4 @@ notifications: on_success: change on_failure: always use_notice: true - skip_join: true + skip_join: false diff --git a/contrib/src/ai/aiBehaviors.cxx b/contrib/src/ai/aiBehaviors.cxx index 38d32b1026..1ace436e5b 100644 --- a/contrib/src/ai/aiBehaviors.cxx +++ b/contrib/src/ai/aiBehaviors.cxx @@ -13,6 +13,10 @@ #include "aiBehaviors.h" +using std::cout; +using std::endl; +using std::string; + static const float _PI = 3.14; AIBehaviors::AIBehaviors() { diff --git a/contrib/src/ai/aiCharacter.cxx b/contrib/src/ai/aiCharacter.cxx index 240f1a4ea3..58485081c3 100644 --- a/contrib/src/ai/aiCharacter.cxx +++ b/contrib/src/ai/aiCharacter.cxx @@ -13,7 +13,7 @@ #include "aiCharacter.h" -AICharacter::AICharacter(string model_name, NodePath model_np, double mass, double movt_force, double max_force) { +AICharacter::AICharacter(std::string model_name, NodePath model_np, double mass, double movt_force, double max_force) { _name = model_name; _ai_char_np = model_np; diff --git a/contrib/src/ai/aiPathFinder.cxx b/contrib/src/ai/aiPathFinder.cxx index 8167a6e42e..be2b2dd56a 100644 --- a/contrib/src/ai/aiPathFinder.cxx +++ b/contrib/src/ai/aiPathFinder.cxx @@ -74,7 +74,7 @@ void PathFinder::generate_path() { add_to_clist(nxt_node); } } - cout<<"DESTINATION NOT REACHABLE MATE!"<_world = this; } -void AIWorld::remove_ai_char(string name) { +void AIWorld::remove_ai_char(std::string name) { AICharPool::iterator it; for (it = _ai_char_pool.begin(); it != _ai_char_pool.end(); ++it) { AICharacter *ai_char = *it; @@ -38,10 +38,10 @@ void AIWorld::remove_ai_char(string name) { } } - remove_ai_char_from_flock(move(name)); + remove_ai_char_from_flock(std::move(name)); } -void AIWorld::remove_ai_char_from_flock(string name) { +void AIWorld::remove_ai_char_from_flock(std::string name) { for (AICharacter *ai_char : _ai_char_pool) { for (Flock *flock : _flock_pool) { if (ai_char->_ai_char_flock_id == flock->get_id()) { @@ -62,7 +62,7 @@ void AIWorld::remove_ai_char_from_flock(string name) { */ void AIWorld::print_list() { for (AICharacter *ai_char : _ai_char_pool) { - cout << ai_char->_name << endl; + std::cout << ai_char->_name << std::endl; } } diff --git a/contrib/src/ai/arrival.cxx b/contrib/src/ai/arrival.cxx index af7400d170..966a6b2611 100644 --- a/contrib/src/ai/arrival.cxx +++ b/contrib/src/ai/arrival.cxx @@ -77,7 +77,7 @@ LVecBase3 Arrival::do_arrival() { return(desired_force); } - cout<<"Arrival works only with seek and pursue"< 0) { diff --git a/contrib/src/rplight/gpuCommand.cxx b/contrib/src/rplight/gpuCommand.cxx index 2bd468c902..0b977bc5bb 100644 --- a/contrib/src/rplight/gpuCommand.cxx +++ b/contrib/src/rplight/gpuCommand.cxx @@ -57,13 +57,13 @@ GPUCommand::GPUCommand(CommandType command_type) { * in mind that integers might be shown in their binary float representation, * depending on the setting in the GPUCommand::convert_int_to_float method. */ -void GPUCommand::write(ostream &out) const { - out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << endl; +void GPUCommand::write(std::ostream &out) const { + out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << std::endl; for (size_t k = 0; k < GPU_COMMAND_ENTRIES; ++k) { out << std::setw(12) << std::fixed << std::setprecision(5) << _data[k] << " "; - if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << endl; + if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << std::endl; } - out << "})" << endl; + out << "})" << std::endl; } /** diff --git a/contrib/src/rplight/iesDataset.cxx b/contrib/src/rplight/iesDataset.cxx index 34f5a8608e..9aafbf2f86 100644 --- a/contrib/src/rplight/iesDataset.cxx +++ b/contrib/src/rplight/iesDataset.cxx @@ -141,7 +141,7 @@ float IESDataset::get_candela_value(float vertical_angle, float horizontal_angle iesdataset_cat.error() << "Invalid horizontal lerp: " << lerp << ", requested angle was " << horizontal_angle << ", prev = " << prev_angle << ", cur = " << curr_angle - << endl; + << std::endl; } return curr_value * lerp + prev_value * (1-lerp); @@ -192,7 +192,7 @@ float IESDataset::get_vertical_candela_value(size_t horizontal_angle_idx, float iesdataset_cat.error() << "ERROR: Invalid vertical lerp: " << lerp << ", requested angle was " << vertical_angle << ", prev = " << prev_angle << ", cur = " << curr_angle - << endl; + << std::endl; } return curr_value * lerp + prev_value * (1-lerp); diff --git a/contrib/src/rplight/internalLightManager.cxx b/contrib/src/rplight/internalLightManager.cxx index ea45c518fd..616e089cbc 100644 --- a/contrib/src/rplight/internalLightManager.cxx +++ b/contrib/src/rplight/internalLightManager.cxx @@ -29,6 +29,8 @@ #include +using std::endl; + NotifyCategoryDef(lightmgr, ""); @@ -133,7 +135,7 @@ void InternalLightManager::setup_shadows(RPLight* light) { } // Init all sources - for (int i = 0; i < num_sources; ++i) { + for (size_t i = 0; i < num_sources; ++i) { ShadowSource* source = light->get_shadow_source(i); // Set the source as dirty, so it gets updated in the beginning @@ -355,7 +357,7 @@ bool InternalLightManager::compare_shadow_sources(const ShadowSource* a, const S void InternalLightManager::update_shadow_sources() { // Find all dirty shadow sources and make a list of them - vector sources_to_update; + std::vector sources_to_update; for (auto iter = _shadow_sources.begin(); iter != _shadow_sources.end(); ++iter) { ShadowSource* source = *iter; if (source) { @@ -393,7 +395,7 @@ void InternalLightManager::update_shadow_sources() { // Free the regions of all sources which will get updated. We have to take into // account that only a limited amount of sources can get updated per frame. - size_t update_slots = min(sources_to_update.size(), + size_t update_slots = std::min(sources_to_update.size(), _shadow_manager->get_num_update_slots_left()); for(size_t i = 0; i < update_slots; ++i) { if (sources_to_update[i]->has_region()) { diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index c37102574f..d63594209b 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -170,7 +170,7 @@ public: _num_entries--; // Update maximum index - if (slot == _max_index) { + if ((int)slot == _max_index) { while (_max_index >= 0 && !_data[_max_index--]); } } diff --git a/contrib/src/rplight/rpLight.I b/contrib/src/rplight/rpLight.I index 9cde259478..c0e2422651 100644 --- a/contrib/src/rplight/rpLight.I +++ b/contrib/src/rplight/rpLight.I @@ -33,7 +33,7 @@ * * @return Amount of shadow sources */ -inline int RPLight::get_num_shadow_sources() const { +inline size_t RPLight::get_num_shadow_sources() const { return _shadow_sources.size(); } diff --git a/contrib/src/rplight/rpLight.h b/contrib/src/rplight/rpLight.h index 1a104f8ac7..51bca24a76 100644 --- a/contrib/src/rplight/rpLight.h +++ b/contrib/src/rplight/rpLight.h @@ -57,7 +57,7 @@ public: virtual void update_shadow_sources() = 0; virtual void write_to_command(GPUCommand &cmd); - inline int get_num_shadow_sources() const; + inline size_t get_num_shadow_sources() const; inline ShadowSource* get_shadow_source(size_t index) const; inline void clear_shadow_sources(); diff --git a/contrib/src/rplight/shadowAtlas.cxx b/contrib/src/rplight/shadowAtlas.cxx index 15d4ea1bd0..2f76aae33d 100644 --- a/contrib/src/rplight/shadowAtlas.cxx +++ b/contrib/src/rplight/shadowAtlas.cxx @@ -131,13 +131,13 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h // Check for empty region if (tile_width < 1 || tile_height < 1) { - shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << endl; + shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << std::endl; return LVecBase4i(-1); } // Check for region bigger than the shadow atlas if (tile_width > _num_tiles || tile_height > _num_tiles) { - shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << endl; + shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << std::endl; return LVecBase4i(-1); } @@ -155,7 +155,7 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h // When we reached this part, we couldn't find a free region, so the atlas // seems to be full. shadowatlas_cat.error() << "Failed to find a free region of size " << tile_width - << " x " << tile_height << "!" << endl; + << " x " << tile_height << "!" << std::endl; return LVecBase4i(-1); } @@ -173,12 +173,12 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h void ShadowAtlas::free_region(const LVecBase4i& region) { // Out of bounds check, can't hurt nassertv(region.get_x() >= 0 && region.get_y() >= 0); - nassertv(region.get_x() + region.get_z() <= _num_tiles && region.get_y() + region.get_w() <= _num_tiles); + nassertv(region.get_x() + region.get_z() <= (int)_num_tiles && region.get_y() + region.get_w() <= (int)_num_tiles); _num_used_tiles -= region.get_z() * region.get_w(); - for (size_t x = 0; x < region.get_z(); ++x) { - for (size_t y = 0; y < region.get_w(); ++y) { + for (int x = 0; x < region.get_z(); ++x) { + for (int y = 0; y < region.get_w(); ++y) { // Could do an assert here, that the tile should have been used (=true) before set_tile(region.get_x() + x, region.get_y() + y, false); } diff --git a/contrib/src/rplight/tagStateManager.cxx b/contrib/src/rplight/tagStateManager.cxx index ddc996f9a4..30653d1f79 100644 --- a/contrib/src/rplight/tagStateManager.cxx +++ b/contrib/src/rplight/tagStateManager.cxx @@ -27,6 +27,8 @@ #include "tagStateManager.h" +using std::endl; + NotifyCategoryDef(tagstatemgr, ""); @@ -77,7 +79,7 @@ TagStateManager:: */ void TagStateManager:: apply_state(StateContainer& container, NodePath np, Shader* shader, - const string &name, int sort) { + const std::string &name, int sort) { if (tagstatemgr_cat.is_spam()) { tagstatemgr_cat.spam() << "Constructing new state " << name << " with shader " << shader << endl; diff --git a/contrib/src/sceneeditor/MetadataPanel.py b/contrib/src/sceneeditor/MetadataPanel.py index 7510f3d7fc..9f6bc222f4 100644 --- a/contrib/src/sceneeditor/MetadataPanel.py +++ b/contrib/src/sceneeditor/MetadataPanel.py @@ -36,7 +36,7 @@ class MetadataPanel(AppShell,Pmw.MegaWidget): def appInit(self): - print "Metadata Panel" + print("Metadata Panel") def createInterface(self): interior = self.interior() diff --git a/contrib/src/sceneeditor/SideWindow.py b/contrib/src/sceneeditor/SideWindow.py index 58a41a05be..96c225c58f 100644 --- a/contrib/src/sceneeditor/SideWindow.py +++ b/contrib/src/sceneeditor/SideWindow.py @@ -6,8 +6,16 @@ from direct.tkwidgets.AppShell import AppShell from direct.tkwidgets.VectorWidgets import ColorEntry from direct.showbase.TkGlobal import spawnTkLoop import seSceneGraphExplorer -from Tkinter import Frame, IntVar, Checkbutton, Toplevel -import Pmw, Tkinter + +import Pmw, sys + +if sys.version_info >= (3, 0): + from tkinter import Frame, IntVar, Checkbutton, Toplevel + import tkinter +else: + from Tkinter import Frame, IntVar, Checkbutton, Toplevel + import Tkinter as tkinter + class sideWindow(AppShell): ################################################################# @@ -65,7 +73,7 @@ class sideWindow(AppShell): self.parent.resizable(False,False) ## Disable the ability to resize for this Window. def appInit(self): - print '----SideWindow is Initialized!!' + print('----SideWindow is Initialized!!') def createInterface(self): # The interior of the toplevel panel @@ -73,7 +81,7 @@ class sideWindow(AppShell): mainFrame = Frame(interior) ## Creat NoteBook self.notebookFrame = Pmw.NoteBook(mainFrame) - self.notebookFrame.pack(fill=Tkinter.BOTH,expand=1) + self.notebookFrame.pack(fill=tkinter.BOTH,expand=1) sgePage = self.notebookFrame.add('Tree Graph') envPage = self.notebookFrame.add('World Setting') self.notebookFrame['raisecommand'] = self.updateInfo @@ -83,7 +91,7 @@ class sideWindow(AppShell): sgePage, nodePath = render, scrolledCanvas_hull_width = 270, scrolledCanvas_hull_height = 570) - self.SGE.pack(fill = Tkinter.BOTH, expand = 0) + self.SGE.pack(fill = tkinter.BOTH, expand = 0) ## World Setting Page envPage = Frame(envPage) @@ -95,8 +103,8 @@ class sideWindow(AppShell): text = 'Enable Lighting', variable = self.LightingVar, command = self.toggleLights) - self.LightingButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.LightingButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.CollisionVar = IntVar() @@ -106,8 +114,8 @@ class sideWindow(AppShell): text = 'Show Collision Object', variable = self.CollisionVar, command = self.showCollision) - self.CollisionButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.CollisionButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.ParticleVar = IntVar() @@ -117,8 +125,8 @@ class sideWindow(AppShell): text = 'Show Particle Dummy', variable = self.ParticleVar, command = self.enableParticle) - self.ParticleButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.ParticleButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.baseUseDriveVar = IntVar() @@ -128,8 +136,8 @@ class sideWindow(AppShell): text = 'Enable base.usedrive', variable = self.baseUseDriveVar, command = self.enablebaseUseDrive) - self.baseUseDriveButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.baseUseDriveButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.backfaceVar = IntVar() @@ -139,8 +147,8 @@ class sideWindow(AppShell): text = 'Enable BackFace', variable = self.backfaceVar, command = self.toggleBackface) - self.backfaceButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.backfaceButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.textureVar = IntVar() @@ -150,8 +158,8 @@ class sideWindow(AppShell): text = 'Enable Texture', variable = self.textureVar, command = self.toggleTexture) - self.textureButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.textureButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.wireframeVar = IntVar() @@ -161,8 +169,8 @@ class sideWindow(AppShell): text = 'Enable Wireframe', variable = self.wireframeVar, command = self.toggleWireframe) - self.wireframeButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.wireframeButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.gridVar = IntVar() @@ -172,8 +180,8 @@ class sideWindow(AppShell): text = 'Enable Grid', variable = self.gridVar, command = self.toggleGrid) - self.gridButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.gridButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.widgetVisVar = IntVar() @@ -183,8 +191,8 @@ class sideWindow(AppShell): text = 'Enable WidgetVisible', variable = self.widgetVisVar, command = self.togglewidgetVis) - self.widgetVisButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.widgetVisButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.enableAutoCameraVar = IntVar() @@ -194,17 +202,17 @@ class sideWindow(AppShell): text = 'Enable Auto Camera Movement for Loading Objects', variable = self.enableAutoCameraVar, command = self.toggleAutoCamera) - self.enableAutoCameraButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.enableAutoCameraButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.backgroundColor = ColorEntry( pageFrame, text = 'BG Color', value=self.worldColor) self.backgroundColor['command'] = self.setBackgroundColorVec self.backgroundColor['resetValue'] = [0,0,0,0] - self.backgroundColor.pack(side=Tkinter.LEFT, expand=False) + self.backgroundColor.pack(side=tkinter.LEFT, expand=False) self.bind(self.backgroundColor, 'Set background color') - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) envPage.pack(expand=False) @@ -320,11 +328,11 @@ class sideWindow(AppShell): # ################################################################# if self.enableBaseUseDrive==0: - print 'Enabled' + print('Enabled') base.useDrive() self.enableBaseUseDrive = 1 else: - print 'disabled' + print('disabled') #base.useTrackball() base.disableMouse() self.enableBaseUseDrive = 0 diff --git a/contrib/src/sceneeditor/collisionWindow.py b/contrib/src/sceneeditor/collisionWindow.py index 7122e801bb..9155db871a 100644 --- a/contrib/src/sceneeditor/collisionWindow.py +++ b/contrib/src/sceneeditor/collisionWindow.py @@ -9,9 +9,8 @@ from seColorEntry import * from direct.tkwidgets import VectorWidgets from direct.tkwidgets import Floater from direct.tkwidgets import Slider -from Tkinter import * import string, math, types -from pandac.PandaModules import * +from panda3d.core import * class collisionWindow(AppShell): @@ -195,7 +194,7 @@ class collisionWindow(AppShell): # put the object into a CollisionNode and attach it to the target nodePath ################################################################# collisionObject = None - print self.objType + print(self.objType) if self.objType=='collisionPolygon': pointA = Point3(float(self.widgetDict['PolygonPoint A'][0]._entry.get()), float(self.widgetDict['PolygonPoint A'][1]._entry.get()), @@ -236,7 +235,7 @@ class collisionWindow(AppShell): float(self.widgetDict['RayDirection'][1]._entry.get()), float(self.widgetDict['RayDirection'][2]._entry.get())) - print vector, point + print(vector, point) collisionObject = CollisionRay() collisionObject.setOrigin(point) diff --git a/contrib/src/sceneeditor/controllerWindow.py b/contrib/src/sceneeditor/controllerWindow.py index b66e390c73..03ca35d6d8 100644 --- a/contrib/src/sceneeditor/controllerWindow.py +++ b/contrib/src/sceneeditor/controllerWindow.py @@ -4,8 +4,14 @@ ################################################################# from direct.tkwidgets.AppShell import AppShell -from Tkinter import Frame, Label, Button -import string, Pmw, Tkinter +import sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Frame, Label, Button + import tkinter +else: + from Tkinter import Frame, Label, Button + import Tkinter as tkinter # Define the Category KEYBOARD = 'Keyboard-' @@ -75,11 +81,11 @@ class controllerWindow(AppShell): self.cotrollerTypeEntry = self.createcomponent( 'Controller Type', (), None, Pmw.ComboBox, (frame,), - labelpos = Tkinter.W, label_text='Controller Type:', entry_width = 20,entry_state = Tkinter.DISABLED, + labelpos = tkinter.W, label_text='Controller Type:', entry_width = 20,entry_state = tkinter.DISABLED, selectioncommand = self.setControllerType, scrolledlist_items = self.controllerList) - self.cotrollerTypeEntry.pack(side=Tkinter.LEFT) - frame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=False, pady = 3) + self.cotrollerTypeEntry.pack(side=tkinter.LEFT) + frame.pack(side=tkinter.TOP, fill=tkinter.X, expand=False, pady = 3) self.cotrollerTypeEntry.selectitem('Keyboard', setentry=True) self.inputZone = Pmw.Group(mainFrame, tag_pyclass = None) @@ -102,7 +108,7 @@ class controllerWindow(AppShell): keyboardPage = self.objNotebook.add('Keyboard') tarckerPage = self.objNotebook.add('Tracker') self.objNotebook.selectpage('Keyboard') - self.objNotebook.pack(side = Tkinter.TOP, fill='both',expand=False) + self.objNotebook.pack(side = tkinter.TOP, fill='both',expand=False) # Put this here so it isn't called right away self.objNotebook['raisecommand'] = self.updateControlInfo @@ -113,11 +119,11 @@ class controllerWindow(AppShell): widget = self.createcomponent( 'Target Type', (), None, Pmw.ComboBox, (Interior,), - labelpos = Tkinter.W, label_text='Target Object:', entry_width = 20, entry_state = Tkinter.DISABLED, + labelpos = tkinter.W, label_text='Target Object:', entry_width = 20, entry_state = tkinter.DISABLED, selectioncommand = self.setTargetObj, scrolledlist_items = self.listOfObj) - widget.pack(side=Tkinter.LEFT, padx=3) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 5) + widget.pack(side=tkinter.LEFT, padx=3) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 5) widget.selectitem(self.nameOfNode, setentry=True) self.widgetsDict[KEYBOARD+'ObjList'] = widget @@ -126,411 +132,411 @@ class controllerWindow(AppShell): settingFrame = inputZone.interior() Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Assign a Key For:').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True,pady = 6 ) + widget = Label(Interior, text = 'Assign a Key For:').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True,pady = 6 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Forward :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Forward :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Forward key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyForward'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyForward'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Forward Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedForward'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedForward'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Backward :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Backward :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Backward key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyBackward'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyBackward'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Backward Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedBackward'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedBackward'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Right :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Right :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Up :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Up :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Up key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Up Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Down :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Down :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Right:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Right:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Down :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Down :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Roll Right:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Roll Right:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRollRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRollRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRollRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRollRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Roll Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Roll Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRollLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRollLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRollLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRollLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale X UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale X UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleXUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleXUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleXUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleXUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale X Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale X Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleXDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleXDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down X Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleXDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleXDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Y UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Y UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleYUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleYUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleYUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleYUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Y Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Y Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleYDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleYDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down XY Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleYDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleYDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Z UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Z UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleZUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleZUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleZUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleZUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Z Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Z Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleZDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleZDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down Z Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleZDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleZDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) - assignFrame.pack(side=Tkinter.TOP, expand=True, fill = Tkinter.X) - keyboardPage.pack(side=Tkinter.TOP, expand=True, fill = Tkinter.X) + assignFrame.pack(side=tkinter.TOP, expand=True, fill = tkinter.X) + keyboardPage.pack(side=tkinter.TOP, expand=True, fill = tkinter.X) #################################################################### #################################################################### @@ -539,12 +545,12 @@ class controllerWindow(AppShell): #################################################################### # Pack the mainFrame frame = Frame(mainFrame) - widget = Button(frame, text='OK', width = 13, command=self.ok_press).pack(side=Tkinter.RIGHT) - widget = Button(frame, text='Enable Control', width = 13, command=self.enableControl).pack(side=Tkinter.LEFT) - widget = Button(frame, text='Disable Control', width = 13, command=self.disableControl).pack(side=Tkinter.LEFT) - widget = Button(frame, text='Save & Keep', width = 13, command=self.saveKeepControl).pack(side=Tkinter.LEFT) - frame.pack(side = Tkinter.BOTTOM, expand=1, fill = Tkinter.X) - mainFrame.pack(expand=1, fill = Tkinter.BOTH) + widget = Button(frame, text='OK', width = 13, command=self.ok_press).pack(side=tkinter.RIGHT) + widget = Button(frame, text='Enable Control', width = 13, command=self.enableControl).pack(side=tkinter.LEFT) + widget = Button(frame, text='Disable Control', width = 13, command=self.disableControl).pack(side=tkinter.LEFT) + widget = Button(frame, text='Save & Keep', width = 13, command=self.saveKeepControl).pack(side=tkinter.LEFT) + frame.pack(side = tkinter.BOTTOM, expand=1, fill = tkinter.X) + mainFrame.pack(expand=1, fill = tkinter.BOTH) def onDestroy(self, event): # Check if user wish to keep the control after the window closed. @@ -688,7 +694,7 @@ class controllerWindow(AppShell): self.keyboardMapDict[index] = self.widgetsDict['Keyboard-'+index].getvalue() for index in self.keyboardSpeedDict: self.keyboardSpeedDict[index] = float(self.widgetsDict['Keyboard-'+index].getvalue()) - print self.nodePath + print(self.nodePath) messenger.send('ControlW_saveSetting', ['Keyboard', [self.nodePath, self.keyboardMapDict, self.keyboardSpeedDict]]) return diff --git a/contrib/src/sceneeditor/dataHolder.py b/contrib/src/sceneeditor/dataHolder.py index 0981df643d..4e01ab2fa4 100644 --- a/contrib/src/sceneeditor/dataHolder.py +++ b/contrib/src/sceneeditor/dataHolder.py @@ -2,13 +2,15 @@ # TK and PMW INTERFACE MODULES# ############################### from direct.showbase.TkGlobal import* -from tkFileDialog import * import Pmw -import tkFileDialog -import tkMessageBox from direct.tkwidgets import Dial from direct.tkwidgets import Floater +if sys.version_info >= (3, 0): + from tkinter.filedialog import askopenfilename +else: + from tkFileDialog import askopenfilename + ############################# # Scene Editor Python Files # @@ -154,7 +156,7 @@ class dataHolder: self.ActorNum=0 self.theScene=None messenger.send('SGE_Update Explorer',[render]) - print 'Scene should be cleaned up!' + print('Scene should be cleaned up!') def removeObj(self, nodePath): ################################################################# @@ -169,7 +171,7 @@ class dataHolder: childrenList = nodePath.getChildren() - if self.ModelDic.has_key(name): + if name in self.ModelDic: del self.ModelDic[name] del self.ModelRefDic[name] if len(childrenList) != 0: @@ -178,7 +180,7 @@ class dataHolder: nodePath.removeNode() self.ModelNum -= 1 pass - elif self.ActorDic.has_key(name): + elif name in self.ActorDic: del self.ActorDic[name] del self.ActorRefDic[name] if len(childrenList) != 0: @@ -187,14 +189,14 @@ class dataHolder: nodePath.removeNode() self.ActorNum -= 1 pass - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: del self.collisionDict[name] if len(childrenList) != 0: for node in childrenList: self.removeObj(node) nodePath.removeNode() pass - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: del self.dummyDict[name] if len(childrenList) != 0: for node in childrenList: @@ -207,12 +209,12 @@ class dataHolder: self.removeObj(node) list = self.lightManager.delete(name) return list - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: self.particleNodes[name].removeNode() del self.particleNodes[name] del self.particleDict[name] else: - print 'You cannot remove this NodePath' + print('You cannot remove this NodePath') return messenger.send('SGE_Update Explorer',[render]) @@ -237,15 +239,15 @@ class dataHolder: cHpr = hpr cScale = scale parent = nodePath.getParent() - if self.ActorDic.has_key(name): + if name in self.ActorDic: holder = self.ActorDic holderRef = self.ActorRefDic isModel = False - elif self.ModelDic.has_key(name): + elif name in self.ModelDic: holder = self.ModelDic holderRef = self.ModelRefDic else: - print '---- DataHolder: Target Obj is not a legal object could be duplicate!' + print('---- DataHolder: Target Obj is not a legal object could be duplicate!') return FilePath = holderRef[name] @@ -356,7 +358,7 @@ class dataHolder: # This funciton will return True if there is an Actor in the scene named "name" # and will return False if not. ########################################################################### - return self.ActorDic.has_key(name) + return name in self.ActorDic def getActor(self, name): ########################################################################### @@ -366,7 +368,7 @@ class dataHolder: if self.isActor(name): return self.ActorDic[name] else: - print '----No Actor named: ', name + print('----No Actor named: ', name) return None def getModel(self, name): @@ -377,7 +379,7 @@ class dataHolder: if self.isModel(name): return self.ModelDic[name] else: - print '----No Model named: ', name + print('----No Model named: ', name) return None def isModel(self, name): @@ -386,7 +388,7 @@ class dataHolder: # This funciton will return True if there is a Model in the scene named "name" # and will return False if not. ########################################################################### - return self.ModelDic.has_key(name) + return name in self.ModelDic def loadAnimation(self,name, Dic): ########################################################################### @@ -406,7 +408,7 @@ class dataHolder: messenger.send('DataH_loadFinish'+name) return else: - print '------ Error when loading animation for Actor: ', name + print('------ Error when loading animation for Actor: ', name) def removeAnimation(self, name, anim): ########################################################################### @@ -527,7 +529,7 @@ class dataHolder: self.ActorDic[nName]= self.ActorDic[oName] self.ActorRefDic[nName]= self.ActorRefDic[oName] self.ActorDic[nName].setName(nName) - if self.blendAnimDict.has_key(oName): + if oName in self.blendAnimDict: self.blendAnimDict[nName] = self.blendAnimDict[oName] del self.blendAnimDict[oName] del self.ActorDic[oName] @@ -540,16 +542,16 @@ class dataHolder: del self.ModelRefDic[oName] elif self.lightManager.isLight(oName): list, lightNode = self.lightManager.rename(oName, nName) - elif self.dummyDict.has_key(oName): + elif oName in self.dummyDict: self.dummyDict[nName]= self.dummyDict[oName] self.dummyDict[nName].setName(nName) del self.dummyDict[oName] - elif self.collisionDict.has_key(oName): + elif oName in self.collisionDict: self.collisionDict[nName]= self.collisionDict[oName] self.collisionDict[nName].setName(nName) del self.collisionDict[oName] - elif self.particleNodes.has_key(oName): + elif oName in self.particleNodes: self.particleNodes[nName]= self.particleNodes[oName] self.particleDict[nName]= self.particleDict[oName] self.particleDict[nName].setName(nName) @@ -557,9 +559,9 @@ class dataHolder: del self.particleNodes[oName] del self.particleDict[oName] else: - print '----Error: This Object is not allowed to this function!' + print('----Error: This Object is not allowed to this function!') - if self.curveDict.has_key(oName): + if oName in self.curveDict: self.curveDict[nName] = self.curveDict[oName] del self.curveDict[oName] @@ -578,11 +580,11 @@ class dataHolder: return True elif self.lightManager.isLight(name): return True - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: return True - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: return True - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: return True elif (name == 'render')or(name == 'SEditor')or(name == 'Lights')or(name == 'camera'): return True @@ -596,7 +598,7 @@ class dataHolder: # using the node name as a reference to assosiate a list which contains all curves related to that node. ########################################################################### name = node.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: self.curveDict[name].append(curveCollection) return else: @@ -612,7 +614,7 @@ class dataHolder: # If the input node has not been bindedwith any curve, it will return None. ########################################################################### name = nodePath.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: return self.curveDict[name] else: return None @@ -626,7 +628,7 @@ class dataHolder: # This message will be caught by Property Window for this node. ########################################################################### name =nodePath.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: index = None for curve in self.curveDict[name]: if curve.getCurve(0).getName() == curveName: @@ -677,12 +679,12 @@ class dataHolder: elif self.isLight(name): type = 'Light' info['lightNode'] = self.lightManager.getLightNode(name) - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: type = 'dummy' - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: type = 'collisionNode' info['collisionNode'] = self.collisionDict[name] - if self.curveDict.has_key(name): + if name in self.curveDict: info['curveList'] = self.getCurveList(nodePath) return type, info @@ -794,7 +796,7 @@ class dataHolder: # The formate of thsi dictionary is # {"name of Blend Animation" : ["Animation A, Animation B, Effect(Float, 0~1)"]} ########################################################################### - if self.blendAnimDict.has_key(name): + if name in self.blendAnimDict: return self.blendAnimDict[name] else: return {} @@ -808,8 +810,8 @@ class dataHolder: # Also, if this blend is the first blend animation that the target actor has, # this function will add a "Blending" tag on this actor which is "True". ########################################################################### - if self.blendAnimDict.has_key(actorName): - if self.blendAnimDict[actorName].has_key(blendName): + if actorName in self.blendAnimDict: + if blendName in self.blendAnimDict[actorName]: ### replace the original setting self.blendAnimDict[actorName][blendName][0] = animNameA self.blendAnimDict[actorName][blendName][1] = animNameB @@ -832,7 +834,7 @@ class dataHolder: # it will also rewrite the data to the newest one. ########################################################################### self.removeBlendAnim(actorName,oName) - print self.blendAnimDict + print(self.blendAnimDict) return self.saveBlendAnim(actorName, nName, animNameA, animNameB, effect) def removeBlendAnim(self, actorName, blendName): @@ -844,8 +846,8 @@ class dataHolder: # Also, it will check that there is any blended animation remained for this actor, # If none, this function will clear the "Blending" tag of this object. ########################################################################### - if self.blendAnimDict.has_key(actorName): - if self.blendAnimDict[actorName].has_key(blendName): + if actorName in self.blendAnimDict: + if blendName in self.blendAnimDict[actorName]: ### replace the original setting del self.blendAnimDict[actorName][blendName] if len(self.blendAnimDict[actorName])==0: @@ -876,15 +878,15 @@ class dataHolder: ########################################################################### if name == 'camera': return camera - elif self.ModelDic.has_key(name): + elif name in self.ModelDic: return self.ModelDic[name] - elif self.ActorDic.has_key(name): + elif name in self.ActorDic: return self.ActorDic[name] - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: return self.collisionDict[name] - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: return self.dummyDict[name] - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: return self.particleNodes[name] elif self.lightManager.isLight(name): return self.lightManager.getLightNode(name) @@ -935,13 +937,13 @@ class dataHolder: ########################################################################### ### Ask for a filename - OpenFilename = tkFileDialog.askopenfilename(filetypes = [("PY","py")],title = "Load Scene") + OpenFilename = askopenfilename(filetypes = [("PY","py")],title = "Load Scene") if(not OpenFilename): return None f=Filename.fromOsSpecific(OpenFilename) fileName=f.getBasenameWoExtension() dirName=f.getFullpathWoExtension() - print "DATAHOLDER::" + dirName + print("DATAHOLDER::" + dirName) ############################################################################ # Append the path to this file to our sys path where python looks for modules # We do this so that we can use "import" on our saved scene code and execute it @@ -976,7 +978,7 @@ class dataHolder: self.ActorDic[actor]=self.Scene.ActorDic[actor] #self.ActorRefDic[actor]=self.Scene.ActorRefDic[actor] # Old way of doing absolute paths self.ActorRefDic[actor]=Filename(dirName + "/" + self.Scene.ActorRefDic[actor]) # Relative Paths - if(self.Scene.blendAnimDict.has_key(str(actor))): + if(str(actor) in self.Scene.blendAnimDict): self.blendAnimDict[actor]=self.Scene.blendAnimDict[actor] self.ActorNum=self.ActorNum+1 @@ -1006,7 +1008,7 @@ class dataHolder: atten=alight.getAttenuation() self.lightManager.create('spot',alight.getColor(),alight.getSpecularColor(),thenode.getPos(),thenode.getHpr(),atten.getX(),atten.getY(),atten.getZ(),alight.getExponent(),name=alight.getName(),tag=thenode.getTag("Metadata")) else: - print 'Invalid light type' + print('Invalid light type') ############################################################################ # Populate Dummy related Dictionaries diff --git a/contrib/src/sceneeditor/duplicateWindow.py b/contrib/src/sceneeditor/duplicateWindow.py index 24f20b7d09..b82a5449e1 100644 --- a/contrib/src/sceneeditor/duplicateWindow.py +++ b/contrib/src/sceneeditor/duplicateWindow.py @@ -45,7 +45,7 @@ class duplicateWindow(AppShell): self.parent.resizable(False,False) ## Disable the ability to resize for this Window. def appInit(self): - print '----SideWindow is Initialized!!' + print('----SideWindow is Initialized!!') def createInterface(self): # The interior of the toplevel panel @@ -122,7 +122,7 @@ class duplicateWindow(AppShell): # This message will be caught by sceneEditor. ################################################################# if not self.allEntryValid(): - print '---- Duplication Window: Invalid value!!' + print('---- Duplication Window: Invalid value!!') return x = self.move_x.getvalue() y = self.move_y.getvalue() diff --git a/contrib/src/sceneeditor/lightingPanel.py b/contrib/src/sceneeditor/lightingPanel.py index edca358d61..eeb8cafa20 100644 --- a/contrib/src/sceneeditor/lightingPanel.py +++ b/contrib/src/sceneeditor/lightingPanel.py @@ -7,9 +7,16 @@ from direct.tkwidgets.AppShell import AppShell from seColorEntry import * from direct.tkwidgets.VectorWidgets import Vector3Entry from direct.tkwidgets.Slider import Slider -from Tkinter import Frame, Button, Menubutton, Menu -import string, math, types, Pmw, Tkinter -from pandac.PandaModules import * +import sys, math, types, Pmw +from panda3d.core import * + +if sys.version_info >= (3, 0): + from tkinter import Frame, Button, Menubutton, Menu + import tkinter +else: + from Tkinter import Frame, Button, Menubutton, Menu + import Tkinter as tkinter + class lightingPanel(AppShell): ################################################################# @@ -51,25 +58,25 @@ class lightingPanel(AppShell): mainFrame = Frame(interior) self.listZone = Pmw.Group(mainFrame,tag_pyclass = None) - self.listZone.pack(expand=0, fill=Tkinter.X,padx=3,pady=3) + self.listZone.pack(expand=0, fill=tkinter.X,padx=3,pady=3) listFrame = self.listZone.interior() self.lightEntry = self.createcomponent( 'Lights List', (), None, Pmw.ComboBox, (listFrame,),label_text='Light :', - labelpos = Tkinter.W, entry_width = 25, selectioncommand = self.selectLight, + labelpos = tkinter.W, entry_width = 25, selectioncommand = self.selectLight, scrolledlist_items = self.lightList) - self.lightEntry.pack(side=Tkinter.LEFT) + self.lightEntry.pack(side=tkinter.LEFT) self.renameButton = self.createcomponent( 'Rename Light', (), None, Button, (listFrame,), text = ' Rename ', command = self.renameLight) - self.renameButton.pack(side=Tkinter.LEFT) + self.renameButton.pack(side=tkinter.LEFT) self.addLighZone = Pmw.Group(listFrame,tag_pyclass = None) - self.addLighZone.pack(side=Tkinter.LEFT) + self.addLighZone.pack(side=tkinter.LEFT) insideFrame = self.addLighZone.interior() self.lightsButton = Menubutton(insideFrame, text = 'Add light',borderwidth = 3, activebackground = '#909090') @@ -91,13 +98,13 @@ class lightingPanel(AppShell): Button, (listFrame,), text = ' Delete ', command = self.deleteLight) - self.deleteButton.pack(side=Tkinter.LEFT) + self.deleteButton.pack(side=tkinter.LEFT) self.lightColor = seColorEntry( mainFrame, text = 'Light Color', value=self.lightColor) self.lightColor['command'] = self.setLightingColorVec self.lightColor['resetValue'] = [0.3*255,0.3*255,0.3*255,0] - self.lightColor.pack(fill=Tkinter.X,expand=0) + self.lightColor.pack(fill=tkinter.X,expand=0) self.bind(self.lightColor, 'Set light color') # Notebook pages for light specific controls @@ -114,27 +121,27 @@ class lightingPanel(AppShell): self.dSpecularColor = seColorEntry( directionalPage, text = 'Specular Color') self.dSpecularColor['command'] = self.setSpecularColor - self.dSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.dSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.dSpecularColor, 'Set directional light specular color') self.dPosition = Vector3Entry( directionalPage, text = 'Position') self.dPosition['command'] = self.setPosition self.dPosition['resetValue'] = [0,0,0,0] - self.dPosition.pack(fill = Tkinter.X, expand = 0) + self.dPosition.pack(fill = tkinter.X, expand = 0) self.bind(self.dPosition, 'Set directional light position') self.dOrientation = Vector3Entry( directionalPage, text = 'Orientation') self.dOrientation['command'] = self.setOrientation self.dOrientation['resetValue'] = [0,0,0,0] - self.dOrientation.pack(fill = Tkinter.X, expand = 0) + self.dOrientation.pack(fill = tkinter.X, expand = 0) self.bind(self.dOrientation, 'Set directional light orientation') # Point light controls self.pSpecularColor = seColorEntry( pointPage, text = 'Specular Color') self.pSpecularColor['command'] = self.setSpecularColor - self.pSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.pSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.pSpecularColor, 'Set point light specular color') @@ -142,7 +149,7 @@ class lightingPanel(AppShell): pointPage, text = 'Position') self.pPosition['command'] = self.setPosition self.pPosition['resetValue'] = [0,0,0,0] - self.pPosition.pack(fill = Tkinter.X, expand = 0) + self.pPosition.pack(fill = tkinter.X, expand = 0) self.bind(self.pPosition, 'Set point light position') self.pConstantAttenuation = Slider( @@ -152,7 +159,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 1.0) self.pConstantAttenuation['command'] = self.setConstantAttenuation - self.pConstantAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pConstantAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pConstantAttenuation, 'Set point light constant attenuation') @@ -163,7 +170,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.pLinearAttenuation['command'] = self.setLinearAttenuation - self.pLinearAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pLinearAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pLinearAttenuation, 'Set point light linear attenuation') @@ -174,7 +181,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation - self.pQuadraticAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pQuadraticAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pQuadraticAttenuation, 'Set point light quadratic attenuation') @@ -182,7 +189,7 @@ class lightingPanel(AppShell): self.sSpecularColor = seColorEntry( spotPage, text = 'Specular Color') self.sSpecularColor['command'] = self.setSpecularColor - self.sSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.sSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.sSpecularColor, 'Set spot light specular color') @@ -193,7 +200,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 1.0) self.sConstantAttenuation['command'] = self.setConstantAttenuation - self.sConstantAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sConstantAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sConstantAttenuation, 'Set spot light constant attenuation') @@ -204,7 +211,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sLinearAttenuation['command'] = self.setLinearAttenuation - self.sLinearAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sLinearAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sLinearAttenuation, 'Set spot light linear attenuation') @@ -215,7 +222,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation - self.sQuadraticAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sQuadraticAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sQuadraticAttenuation, 'Set spot light quadratic attenuation') @@ -226,16 +233,16 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sExponent['command'] = self.setExponent - self.sExponent.pack(fill = Tkinter.X, expand = 0) + self.sExponent.pack(fill = tkinter.X, expand = 0) self.bind(self.sExponent, 'Set spot light exponent') # MRM: Add frustum controls self.lightNotebook.setnaturalsize() - self.lightNotebook.pack(expand = 1, fill = Tkinter.BOTH) + self.lightNotebook.pack(expand = 1, fill = tkinter.BOTH) - mainFrame.pack(expand=1, fill = Tkinter.BOTH) + mainFrame.pack(expand=1, fill = tkinter.BOTH) def onDestroy(self, event): messenger.send('LP_close') diff --git a/contrib/src/sceneeditor/propertyWindow.py b/contrib/src/sceneeditor/propertyWindow.py index 35f239eee5..d741324271 100644 --- a/contrib/src/sceneeditor/propertyWindow.py +++ b/contrib/src/sceneeditor/propertyWindow.py @@ -11,8 +11,7 @@ from direct.tkwidgets import Floater from direct.tkwidgets import Dial from direct.tkwidgets import Slider from direct.tkwidgets import VectorWidgets -from pandac.PandaModules import * -from Tkinter import * +from panda3d.core import * import Pmw class propertyWindow(AppShell,Pmw.MegaWidget): @@ -108,7 +107,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): self.curveFrame = None #### If nodePath has been binded with any curves - if self.info.has_key('curveList'): + if 'curveList' in self.info: self.createCurveFrame(self.contentFrame) ## Set all stuff done @@ -271,7 +270,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): # And, it will set the call back function to setNodeColorVec() ################################################################# color = self.nodePath.getColor() - print color + print(color) self.nodeColor = VectorWidgets.ColorEntry( contentFrame, text = 'Node Color', value=[color.getX()*255, color.getY()*255, @@ -725,7 +724,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): # But, not directly removed be this function. # This function will send out a message to notice dataHolder to remove this animation ################################################################# - print anim + print(anim) widget = self.widgetsDict[anim] self.accept('animRemovedFromNode',self.redrawAnimProperty) messenger.send('PW_removeAnimFromNode',[self.name, anim]) diff --git a/contrib/src/sceneeditor/quad.py b/contrib/src/sceneeditor/quad.py index 47524739ae..6f4fcf03d0 100644 --- a/contrib/src/sceneeditor/quad.py +++ b/contrib/src/sceneeditor/quad.py @@ -9,10 +9,8 @@ from direct.showbase.ShowBaseGlobal import * from direct.interval.IntervalGlobal import * from direct.showbase.DirectObject import DirectObject -from pandac.PandaModules import * +from panda3d.core import * import math -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import MouseWatcher class ViewPort: @@ -506,7 +504,7 @@ class QuadView(DirectObject): ansY=-1.0+y2 self.xy=[ansX,ansY] - print "Sent X:%f Sent Y:%f"%(ansX,ansY) + print("Sent X:%f Sent Y:%f"%(ansX,ansY)) #SEditor.iRay.pick(render,self.xy) SEditor.manipulationControl.manipulationStop(self.xy) #print "MouseX " + str(base.mouseWatcherNode.getMouseX()) + "MouseY " + str(base.mouseWatcherNode.getMouseY()) + "\n" @@ -550,28 +548,28 @@ class QuadView(DirectObject): dr.setDimensions(0.5,1,0,0.5) def setLeft(self): - print "LEFT" + print("LEFT") self.CurrentQuad=3 self.ChangeBaseDR() self.Left.setCam() #self.Left.setDR(self.mouseWatcherNode) def setTop(self): - print "TOP" + print("TOP") self.CurrentQuad=2 self.ChangeBaseDR() self.Top.setCam() #self.Top.setDR(self.mouseWatcherNode) def setPerspective(self): - print "PERSPECTIVE" + print("PERSPECTIVE") self.CurrentQuad=4 self.ChangeBaseDR() self.Perspective.setCam() #self.Perspective.setDR(self.mouseWatcherNode) def setFront(self): - print "FRONT" + print("FRONT") self.CurrentQuad=1 self.ChangeBaseDR() self.Front.setCam() diff --git a/contrib/src/sceneeditor/sceneEditor.py b/contrib/src/sceneeditor/sceneEditor.py index ca35baa92b..1565e9eaed 100644 --- a/contrib/src/sceneeditor/sceneEditor.py +++ b/contrib/src/sceneeditor/sceneEditor.py @@ -3,11 +3,19 @@ import sys try: import _tkinter except: sys.exit("Please install python module 'Tkinter'") -import direct -from direct.directbase.DirectStart import* +from direct.showbase.ShowBase import ShowBase + +ShowBase() + from direct.showbase.TkGlobal import spawnTkLoop -from Tkinter import * -from tkFileDialog import * + +if sys.version_info >= (3, 0): + from tkinter import * + from tkinter.filedialog import * +else: + from Tkinter import * + from tkFileDialog import * + from direct.directtools.DirectGlobals import * from direct.tkwidgets.AppShell import* @@ -251,7 +259,10 @@ class myLevelEditor(AppShell): for event in self.actionEvents: self.accept(event[0], event[1], extraArgs = event[2:]) - camera.toggleVis() + if camera.is_hidden(): + camera.show() + else: + camera.hide() self.selectNode(base.camera) ## Initially, we select camera as the first node... def appInit(self): @@ -386,31 +397,31 @@ class myLevelEditor(AppShell): self.showAbout() return elif buttonIndex==12: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==13: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==14: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==15: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==16: - print "Your scene will be eliminated within five seconds, Save your world!!!, Number %d."%buttonIndex + print("Your scene will be eliminated within five seconds, Save your world!!!, Number %d."%buttonIndex) return elif buttonIndex==17: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==18: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==19: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==20: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return return @@ -666,17 +677,17 @@ class myLevelEditor(AppShell): ################################################################# type, info = AllScene.getInfoOfThisNode(nodePath) name = nodePath.getName() - if not self.propertyWindow.has_key(name): + if name not in self.propertyWindow: self.propertyWindow[name] = propertyWindow(nodePath, type,info ) pass def closePropertyWindow(self, name): - if self.propertyWindow.has_key(name): + if name in self.propertyWindow: del self.propertyWindow[name] return def openMetadataPanel(self,nodePath=None): - print nodePath + print(nodePath) self.MetadataPanel=MetadataPanel(nodePath) pass @@ -685,7 +696,7 @@ class myLevelEditor(AppShell): # duplicate(self, nodePath = None) # This function will be called when user try to open the duplication window ################################################################# - print '----Duplication!!' + print('----Duplication!!') if nodePath != None: self.duplicateWindow = duplicateWindow(nodePath = nodePath) pass @@ -791,8 +802,8 @@ class myLevelEditor(AppShell): ################################################################# name = nodePath.getName() if AllScene.isActor(name): - if self.animPanel.has_key(name): - print '---- You already have an animation panel for this Actor!' + if name in self.animPanel: + print('---- You already have an animation panel for this Actor!') return else: Actor = AllScene.getActor(name) @@ -842,9 +853,9 @@ class myLevelEditor(AppShell): # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): + if currentModName in sys.modules: del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) + print(sys.getrefcount(AllScene.theScene)) del AllScene.theScene else: AllScene.resetAll() @@ -872,9 +883,9 @@ class myLevelEditor(AppShell): # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): + if currentModName in sys.modules: del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) + print(sys.getrefcount(AllScene.theScene)) del AllScene.theScene else: AllScene.resetAll() @@ -886,7 +897,7 @@ class myLevelEditor(AppShell): thefile=Filename(self.CurrentFileName) thedir=thefile.getFullpathWoExtension() - print "SCENE EDITOR::" + thedir + print("SCENE EDITOR::" + thedir) self.CurrentDirName=thedir if self.CurrentFileName != None: self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) @@ -934,7 +945,7 @@ class myLevelEditor(AppShell): theScene.writeBamFile(fileName) else: render.writeBamFile(fileName+".bad") - print " Scenegraph saved as :" +str(fileName) + print(" Scenegraph saved as :" +str(fileName)) def loadFromBam(self): fileName = tkFileDialog.askopenfilename(filetypes = [("BAM",".bam")],title = "Load Scenegraph from Bam file") @@ -959,7 +970,7 @@ class myLevelEditor(AppShell): ############################################################################### # !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!! ############################################################################### - if(sys.modules.has_key(fCheck.getBasenameWoExtension())): + if(fCheck.getBasenameWoExtension() in sys.modules): tkMessageBox.showwarning( "Save file", "Cannot save with this name because there is a system module with the same name. Please resave as something else." @@ -993,7 +1004,7 @@ class myLevelEditor(AppShell): if modelFilename: self.makeDirty() if not AllScene.loadModel(modelFilename, Filename.fromOsSpecific(modelFilename)): - print '----Error! No Such Model File!' + print('----Error! No Such Model File!') pass def loadActor(self): @@ -1016,12 +1027,12 @@ class myLevelEditor(AppShell): if ActorFilename: self.makeDirty() if not AllScene.loadActor(ActorFilename, Filename.fromOsSpecific(ActorFilename)): - print '----Error! No Such Model File!' + print('----Error! No Such Model File!') pass def importScene(self): self.makeDirty() - print '----God bless you Please Import!' + print('----God bless you Please Import!') pass @@ -1495,7 +1506,7 @@ class myLevelEditor(AppShell): return def animPanelClose(self, name): - if self.animPanel.has_key(name): + if name in self.animPanel: del self.animPanel[name] return @@ -1508,8 +1519,8 @@ class myLevelEditor(AppShell): ################################################################ name = nodePath.getName() if AllScene.isActor(name): - if self.animBlendPanel.has_key(name): - print '---- You already have an Blend Animation Panel for this Actor!' + if name in self.animBlendPanel: + print('---- You already have an Blend Animation Panel for this Actor!') return else: Actor = AllScene.getActor(name) @@ -1554,7 +1565,7 @@ class myLevelEditor(AppShell): # This function will be called when Blend panel has been closed. # Here we will reset the reference dictionary so it can be open again. ################################################################ - if self.animBlendPanel.has_key(name): + if name in self.animBlendPanel: del self.animBlendPanel[name] return @@ -1613,7 +1624,7 @@ class myLevelEditor(AppShell): def openAlignPanel(self, nodePath=None): name = nodePath.getName() - if not self.alignPanelDict.has_key(name): + if name not in self.alignPanelDict: list = AllScene.getAllObjNameAsList() if name in list: list.remove(name) @@ -1623,7 +1634,7 @@ class myLevelEditor(AppShell): return def closeAlignPanel(self, name=None): - if self.alignPanelDict.has_key(name): + if name in self.alignPanelDict: del self.alignPanelDict[name] def alignObject(self, nodePath, name, list): @@ -1705,4 +1716,4 @@ class myLevelEditor(AppShell): editor = myLevelEditor(parent = base.tkRoot) -run() +base.run() diff --git a/contrib/src/sceneeditor/seAnimPanel.py b/contrib/src/sceneeditor/seAnimPanel.py index 86c245a3ef..2dd3ceee53 100644 --- a/contrib/src/sceneeditor/seAnimPanel.py +++ b/contrib/src/sceneeditor/seAnimPanel.py @@ -5,12 +5,16 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import * from direct.showbase.TkGlobal import * -from tkSimpleDialog import askfloat import string import math import types from direct.task import Task +if sys.version_info >= (3, 0): + from tkinter.simpledialog import askfloat +else: + from tkSimpleDialog import askfloat + FRAMES = 0 SECONDS = 1 @@ -112,7 +116,7 @@ class AnimPanel(AppShell): self.playRateEntry.selectitem('1.0') ### Loop checkbox - Label(actorFrame, text= "Loop:", font=('MSSansSerif', 12)).place(x=420,y=05,anchor=NW) + Label(actorFrame, text= "Loop:", font=('MSSansSerif', 12)).place(x=420,y=5,anchor=NW) self.loopVar = IntVar() self.loopVar.set(0) @@ -250,7 +254,7 @@ class AnimPanel(AppShell): self['animList'] = self['actor'].getAnimNames() animL = self['actor'].getAnimNames() self.AnimEntry.setlist(animL) - print '-----',animL + print('-----',animL) return def loadAnimation(self): @@ -278,7 +282,7 @@ class AnimPanel(AppShell): taskMgr.add(self.playTask, self.id + '_UpdateTask') self.stopButton.config(state=NORMAL) else: - print '----Illegal Animaion name!!', self.animName + print('----Illegal Animaion name!!', self.animName) return def playTask(self, task): @@ -591,7 +595,7 @@ class LoadAnimPanel(AppShell): else: self.animList.append(name) self.AnimName_1.setlist(self.animList) - print self.animDic + print(self.animDic) return def ok_press(self): diff --git a/contrib/src/sceneeditor/seBlendAnimPanel.py b/contrib/src/sceneeditor/seBlendAnimPanel.py index 6895b81417..2ab28210c5 100644 --- a/contrib/src/sceneeditor/seBlendAnimPanel.py +++ b/contrib/src/sceneeditor/seBlendAnimPanel.py @@ -5,12 +5,16 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import * from direct.showbase.TkGlobal import * -from tkSimpleDialog import askfloat import string import math import types from direct.task import Task +if sys.version_info >= (3, 0): + from tkinter.simpledialog import askfloat +else: + from tkSimpleDialog import askfloat + FRAMES = 0 SECONDS = 1 @@ -304,7 +308,7 @@ class BlendAnimPanel(AppShell): taskMgr.add(self.playTask, self.id + '_UpdateTask') self.stopButton.config(state=NORMAL) else: - print '----Illegal Animaion name!!', self.animNameA + ', '+ self.animNameB + print('----Illegal Animaion name!!', self.animNameA + ', '+ self.animNameB) return def playTask(self, task): @@ -348,7 +352,7 @@ class BlendAnimPanel(AppShell): # setAnimation(self, animation, AB = 'a') # see play(self) ################################################################# - print 'OK!!!' + print('OK!!!') if AB == 'a': if self.animNameA != None: self['actor'].setControlEffect(self.animNameA, 1.0, 'modelRoot','lodRoot') @@ -519,7 +523,7 @@ class BlendAnimPanel(AppShell): # then this function will set Animation A to "a" and animation B # to "b" and set the ratio slider to "c" position. ################################################################# - if self.blendDict.has_key(name): + if name in self.blendDict: self.currentBlendName = name animA = self.blendDict[name][0] animB = self.blendDict[name][1] @@ -544,7 +548,7 @@ class BlendAnimPanel(AppShell): self.blendDict.clear() del self.blendDict self.blendDict = dict.copy() - print self.blendDict + print(self.blendDict) if len(self.blendDict)>0: self.blendList = self.blendDict.keys() else: diff --git a/contrib/src/sceneeditor/seCameraControl.py b/contrib/src/sceneeditor/seCameraControl.py index 31ab30ee9f..95237db8be 100644 --- a/contrib/src/sceneeditor/seCameraControl.py +++ b/contrib/src/sceneeditor/seCameraControl.py @@ -55,14 +55,14 @@ class DirectCameraControl(DirectObject): ['n', self.pickNextCOA], ['u', self.orbitUprightCam], ['shift-u', self.uprightCam], - [`1`, self.spawnMoveToView, 1], - [`2`, self.spawnMoveToView, 2], - [`3`, self.spawnMoveToView, 3], - [`4`, self.spawnMoveToView, 4], - [`5`, self.spawnMoveToView, 5], - [`6`, self.spawnMoveToView, 6], - [`7`, self.spawnMoveToView, 7], - [`8`, self.spawnMoveToView, 8], + ['1', self.spawnMoveToView, 1], + ['2', self.spawnMoveToView, 2], + ['3', self.spawnMoveToView, 3], + ['4', self.spawnMoveToView, 4], + ['5', self.spawnMoveToView, 5], + ['6', self.spawnMoveToView, 6], + ['7', self.spawnMoveToView, 7], + ['8', self.spawnMoveToView, 8], ['9', self.swingCamAboutWidget, -90.0, t], ['0', self.swingCamAboutWidget, 90.0, t], ['`', self.removeManipulateCameraTask], @@ -351,7 +351,7 @@ class DirectCameraControl(DirectObject): # MRM: Would be nice to be able to control this # At least display it dist = pow(10.0, self.nullHitPointCount) - SEditor.message('COA Distance: ' + `dist`) + SEditor.message('COA Distance: ' + repr(dist)) coa.set(0,dist,0) # Compute COA Dist coaDist = Vec3(coa - ZERO_POINT).length() @@ -392,8 +392,7 @@ class DirectCameraControl(DirectObject): sf = 0.1 self.coaMarker.setScale(sf) # Lerp color to fade out - self.coaMarker.lerpColor(VBase4(1,0,0,1), VBase4(1,0,0,0), 3.0, - task = 'fadeAway') + self.coaMarker.colorInterval(3.0, VBase4(1, 0, 0, 0), name='fadeAway').start() def homeCam(self): # Record undo point diff --git a/contrib/src/sceneeditor/seColorEntry.py b/contrib/src/sceneeditor/seColorEntry.py index 6cc14b27c6..9dcb3136f7 100644 --- a/contrib/src/sceneeditor/seColorEntry.py +++ b/contrib/src/sceneeditor/seColorEntry.py @@ -12,9 +12,15 @@ from direct.tkwidgets import Valuator from direct.tkwidgets import Floater from direct.tkwidgets import Slider -import string, Pmw, Tkinter, tkColorChooser +import sys, Pmw from direct.tkwidgets.VectorWidgets import VectorEntry +if sys.version_info >= (3, 0): + from tkinter.colorchooser import askcolor +else: + from tkColorChooser import askcolor + + class seColorEntry(VectorEntry): def __init__(self, parent = None, **kw): # Initialize options for the class (overriding some superclass options) @@ -41,7 +47,7 @@ class seColorEntry(VectorEntry): def popupColorPicker(self): # Can pass in current color with: color = (255, 0, 0) - color = tkColorChooser.askcolor( + color = askcolor( parent = self.interior(), # Initialize it to current color initialcolor = tuple(self.get()[:3]))[0] diff --git a/contrib/src/sceneeditor/seFileSaver.py b/contrib/src/sceneeditor/seFileSaver.py index 317c9427f2..9d58fa0580 100644 --- a/contrib/src/sceneeditor/seFileSaver.py +++ b/contrib/src/sceneeditor/seFileSaver.py @@ -3,7 +3,7 @@ # This code saves the scene out as python code... the scene is stored in the various dictionaries in "dataHolder.py" ...the class "AllScene" # #################################################################################################################################################### -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.ShowBaseGlobal import * import os @@ -42,7 +42,7 @@ class FileSaver: i1=" " # indentation i2=i1+i1 # double indentation out_file = open(filename,"w") - print "dirname:" + dirname + print("dirname:" + dirname) if( not os.path.isdir(dirname)): os.mkdir(dirname) savepathname=Filename(filename) @@ -176,7 +176,7 @@ class FileSaver: newtexpathF=Filename(newtexpath) newtexpathSpecific=newtexpathF.toOsSpecific() - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + print("TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific) if(oldtexpath != newtexpathSpecific): shutil.copyfile(oldtexpath,newtexpathSpecific) @@ -187,7 +187,7 @@ class FileSaver: # Copy the file over to the relative directory oldModelpath=AllScene.ModelRefDic[model].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific + print("FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific) if(oldModelpath!=newpathSpecific): shutil.copyfile(oldModelpath,newpathSpecific) @@ -197,7 +197,7 @@ class FileSaver: etc=EggTextureCollection() etc.extractTextures(e) for index in range(len(fnamelist)): - print fnamelist[index] + print(fnamelist[index]) tex=etc.findFilename(Filename(fnamelist[index])) fn=Filename(tex.getFilename()) fn.setDirname("") @@ -305,14 +305,14 @@ class FileSaver: newtexpath=dirname + "/" + texfilename.getBasename() newtexpathF=Filename(newtexpath) newtexpathSpecific=newtexpathF.toOsSpecific() - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + print("TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific) if(oldtexpath != newtexpathSpecific): shutil.copyfile(oldtexpath,newtexpathSpecific) # Copy the file over to the relative directory oldActorpath=AllScene.ActorRefDic[actor].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific + print("FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific) if(oldActorpath!=newpathSpecific): shutil.copyfile(oldActorpath,newpathSpecific) @@ -322,7 +322,7 @@ class FileSaver: etc=EggTextureCollection() etc.extractTextures(e) for index in range(len(actorfnamelist)): - print actorfnamelist[index] + print(actorfnamelist[index]) tex=etc.findFilename(Filename(actorfnamelist[index])) fn=Filename(tex.getFilename()) fn.setDirname("") @@ -362,12 +362,12 @@ class FileSaver: #out_file.write(i2+ "self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Old way with absolute paths #Manakel 2/12/2004: solve the not empty but not defined animation case if not animation is None: - print "ACTOR ANIMATIONS:" + ActorAnimations[animation] + print("ACTOR ANIMATIONS:" + ActorAnimations[animation]) oldAnimPath=Filename(ActorAnimations[animation]) oldAnim=oldAnimPath.toOsSpecific() dirOS=Filename(dirname) newAnim=dirOS.toOsSpecific() + "\\" + oldAnimPath.getBasename() - print "ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim + print("ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim) if(oldAnim!=newAnim): shutil.copyfile(oldAnim,newAnim) newAnimF=Filename.fromOsSpecific(newAnim) @@ -379,16 +379,16 @@ class FileSaver: out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Now with new relative paths out_file.write(i2+"else:\n") theloadAnimString=str(ActorAnimationsInvoke)# We hack the "self.executionpath" part into the dictionary as a variable using string replace - print "LOAD ANIM STRING BEFORE" + theloadAnimString + print("LOAD ANIM STRING BEFORE" + theloadAnimString) theloadAnimString=theloadAnimString.replace('\'self.executionpath +','self.executionpath + \'') - print "LOAD ANIM STRING AFTER" + theloadAnimString + print("LOAD ANIM STRING AFTER" + theloadAnimString) out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + theloadAnimString +")\n") # Now with new relative paths based on editor invocation out_file.write(i2+ "self.ActorDic[\'" + actorS + "\']=self." + AllScene.ActorDic[actor].getName()+"\n") #out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=Filename(\'"+AllScene.ActorRefDic[actor].getFullpath() +"\')\n") # Old way with absolute paths out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=\'"+ AllScene.ActorRefDic[actor].getBasename() +"\'\n")# Relative paths out_file.write(i2+ "self.ActorDic[\'"+ actorS + "\'].setName(\'"+ actorS +"\')\n") - if(AllScene.blendAnimDict.has_key(actor)): # Check if a dictionary of blended animations exists + if(actor in AllScene.blendAnimDict): # Check if a dictionary of blended animations exists out_file.write(i2+ "self.blendAnimDict[\"" + actorS +"\"]=" + str(AllScene.blendAnimDict[actor]) + "\n") @@ -458,7 +458,7 @@ class FileSaver: pass else: - print "Invalid Collision Node: " + nodetype + print("Invalid Collision Node: " + nodetype) out_file.write("\n") @@ -653,7 +653,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ modelS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ")\n") @@ -666,7 +666,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ dummyS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ")\n") @@ -680,7 +680,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ actorS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ")\n") @@ -698,7 +698,7 @@ class FileSaver: out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]="+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") else: #Manakel 2/12/2005: parent replaced by parent Name but why Parent name in partice and parent for other objects? - if(AllScene.particleDict.has_key(parentname)): + if(parentname in AllScene.particleDict): out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + "getEffect().attachNewNode(self." + collnodeS + "_Node)\n") else: out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") diff --git a/contrib/src/sceneeditor/seForceGroup.py b/contrib/src/sceneeditor/seForceGroup.py index 7d27c78ebd..87c08a4904 100644 --- a/contrib/src/sceneeditor/seForceGroup.py +++ b/contrib/src/sceneeditor/seForceGroup.py @@ -1,8 +1,6 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject from direct.showbase.PhysicsManagerGlobal import * -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import ForceNode from direct.directnotify import DirectNotifyGlobal import sys diff --git a/contrib/src/sceneeditor/seGeometry.py b/contrib/src/sceneeditor/seGeometry.py index 79115e5531..99afa62a1f 100644 --- a/contrib/src/sceneeditor/seGeometry.py +++ b/contrib/src/sceneeditor/seGeometry.py @@ -12,7 +12,7 @@ # ################################################################# -from pandac.PandaModules import * +from panda3d.core import * from direct.directtools.DirectGlobals import * from direct.directtools.DirectUtil import * import math @@ -41,10 +41,10 @@ class LineNodePath(NodePath): ls.setColor(colorVec) def moveTo( self, *_args ): - apply( self.lineSegs.moveTo, _args ) + self.lineSegs.moveTo(*_args) def drawTo( self, *_args ): - apply( self.lineSegs.drawTo, _args ) + self.lineSegs.drawTo(*_args) def create( self, frameAccurate = 0 ): self.lineSegs.create( self.lineNode, frameAccurate ) @@ -60,13 +60,13 @@ class LineNodePath(NodePath): self.lineSegs.setThickness( thickness ) def setColor( self, *_args ): - apply( self.lineSegs.setColor, _args ) + self.lineSegs.setColor(*_args) def setVertex( self, *_args): - apply( self.lineSegs.setVertex, _args ) + self.lineSegs.setVertex(*_args) def setVertexColor( self, vertex, *_args ): - apply( self.lineSegs.setVertexColor, (vertex,) + _args ) + self.lineSegs.setVertexColor(*(vertex,) + _args) def getCurrentPosition( self ): return self.lineSegs.getCurrentPosition() @@ -132,9 +132,9 @@ class LineNodePath(NodePath): Given a list of lists of points, draw a separate line for each list """ for pointList in lineList: - apply(self.moveTo, pointList[0]) + self.moveTo(*pointList[0]) for point in pointList[1:]: - apply(self.drawTo, point) + self.drawTo(*point) ## ## Given a point in space, and a direction, find the point of intersection diff --git a/contrib/src/sceneeditor/seLights.py b/contrib/src/sceneeditor/seLights.py index ccc58ce0cd..2353512af5 100644 --- a/contrib/src/sceneeditor/seLights.py +++ b/contrib/src/sceneeditor/seLights.py @@ -3,9 +3,8 @@ # Written by Yi-Hong Lin, yihhongl@andrew.cmu.edu, 2004 ################################################################# from direct.showbase.DirectObject import * -from string import lower from direct.directtools import DirectUtil -from pandac.PandaModules import * +from panda3d.core import * import string @@ -341,7 +340,7 @@ class seLightManager(NodePath): if type == 'ambient': self.ambientCount += 1 if(name=='DEFAULT_NAME'): - light = AmbientLight('ambient_' + `self.ambientCount`) + light = AmbientLight('ambient_' + repr(self.ambientCount)) else: light = AmbientLight(name) @@ -350,7 +349,7 @@ class seLightManager(NodePath): elif type == 'directional': self.directionalCount += 1 if(name=='DEFAULT_NAME'): - light = DirectionalLight('directional_' + `self.directionalCount`) + light = DirectionalLight('directional_' + repr(self.directionalCount)) else: light = DirectionalLight(name) @@ -360,7 +359,7 @@ class seLightManager(NodePath): elif type == 'point': self.pointCount += 1 if(name=='DEFAULT_NAME'): - light = PointLight('point_' + `self.pointCount`) + light = PointLight('point_' + repr(self.pointCount)) else: light = PointLight(name) @@ -371,7 +370,7 @@ class seLightManager(NodePath): elif type == 'spot': self.spotCount += 1 if(name=='DEFAULT_NAME'): - light = Spotlight('spot_' + `self.spotCount`) + light = Spotlight('spot_' + repr(self.spotCount)) else: light = Spotlight(name) @@ -382,7 +381,7 @@ class seLightManager(NodePath): light.setAttenuation(Vec3(constant, linear, quadratic)) light.setExponent(exponent) else: - print 'Invalid light type' + print('Invalid light type') return None # Create the seLight objects and put the light object we just created into it. @@ -411,7 +410,7 @@ class seLightManager(NodePath): # Attention!! # only Spotlight obj nneds to be specified a lens node first. i.e. setLens() first! ################################################################# - type = lower(light.getType().getName()) + type = light.getType().getName().lower() specularColor = VBase4(1) position = Point3(0,0,0) @@ -451,7 +450,7 @@ class seLightManager(NodePath): quadratic = Attenuation.getZ() exponent = light.getExponent() else: - print 'Invalid light type' + print('Invalid light type') return None lightNode = seLight(light,self,type, @@ -508,7 +507,7 @@ class seLightManager(NodePath): # isLight(self.name) # Use a string as a index to check if there existing a light named "name" ################################################################# - return self.lightDict.has_key(name) + return name in self.lightDict def rename(self,oName,nName): ################################################################# @@ -523,7 +522,7 @@ class seLightManager(NodePath): del self.lightDict[oName] return self.lightDict.keys(),lightNode else: - print '----Light Mnager: No such Light!' + print('----Light Mnager: No such Light!') def getLightNodeList(self): ################################################################# diff --git a/contrib/src/sceneeditor/seManipulation.py b/contrib/src/sceneeditor/seManipulation.py index e4d50d81dc..4d0c781b1e 100644 --- a/contrib/src/sceneeditor/seManipulation.py +++ b/contrib/src/sceneeditor/seManipulation.py @@ -520,7 +520,7 @@ class ObjectHandles(NodePath,DirectObject): # To avoid recreating a vec every frame self.hitPt = Vec3(0) # Get a handle on the components - self.xHandles = self.find('**/X') + self.xHandles = self.find('**/ohScalingNode') self.xPostGroup = self.xHandles.find('**/x-post-group') self.xPostCollision = self.xHandles.find('**/x-post') self.xRingGroup = self.xHandles.find('**/x-ring-group') diff --git a/contrib/src/sceneeditor/seMopathRecorder.py b/contrib/src/sceneeditor/seMopathRecorder.py index 7ba2ee52d7..dc8bbd8d22 100644 --- a/contrib/src/sceneeditor/seMopathRecorder.py +++ b/contrib/src/sceneeditor/seMopathRecorder.py @@ -25,10 +25,17 @@ from direct.tkwidgets.Slider import Slider from direct.tkwidgets.EntryScale import EntryScale from direct.tkwidgets.VectorWidgets import Vector2Entry, Vector3Entry from direct.tkwidgets.VectorWidgets import ColorEntry -from Tkinter import Button, Frame, Radiobutton, Checkbutton, Label -from Tkinter import StringVar, BooleanVar, Entry, Scale -import os, string, Tkinter, Pmw -import __builtin__ +import os, string, sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Button, Frame, Radiobutton, Checkbutton, Label + from tkinter import StringVar, BooleanVar, Entry, Scale + import tkinter +else: + from Tkinter import Button, Frame, Radiobutton, Checkbutton, Label + from Tkinter import StringVar, BooleanVar, Entry, Scale + import Tkinter as tkinter + PRF_UTILITIES = [ 'lambda: camera.lookAt(render)', @@ -123,7 +130,7 @@ class MopathRecorder(AppShell, DirectObject): self.postPoints = [] self.pointSetDict = {} self.pointSetCount = 0 - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) # User callback to call before recording point self.samplingMode = 'Continuous' self.preRecordFunc = None @@ -233,7 +240,7 @@ class MopathRecorder(AppShell, DirectObject): self.undoButton['state'] = 'normal' else: self.undoButton['state'] = 'disabled' - self.undoButton.pack(side = Tkinter.LEFT, expand = 0) + self.undoButton.pack(side = tkinter.LEFT, expand = 0) self.bind(self.undoButton, 'Undo last operation') self.redoButton = Button(self.menuFrame, text = 'Redo', @@ -242,19 +249,19 @@ class MopathRecorder(AppShell, DirectObject): self.redoButton['state'] = 'normal' else: self.redoButton['state'] = 'disabled' - self.redoButton.pack(side = Tkinter.LEFT, expand = 0) + self.redoButton.pack(side = tkinter.LEFT, expand = 0) self.bind(self.redoButton, 'Redo last operation') # Record button - mainFrame = Frame(interior, relief = Tkinter.SUNKEN, borderwidth = 2) + mainFrame = Frame(interior, relief = tkinter.SUNKEN, borderwidth = 2) frame = Frame(mainFrame) # Active node path # Button to select active node path widget = self.createButton(frame, 'Recording', 'Node Path:', 'Select Active Mopath Node Path', lambda s = self: SEditor.select(s.nodePath), - side = Tkinter.LEFT, expand = 0) - widget['relief'] = Tkinter.FLAT + side = tkinter.LEFT, expand = 0) + widget['relief'] = tkinter.FLAT self.nodePathMenu = Pmw.ComboBox( frame, entry_width = 20, selectioncommand = self.selectNodePathNamed, @@ -264,7 +271,7 @@ class MopathRecorder(AppShell, DirectObject): self.nodePathMenu.component('entryfield_entry')) self.nodePathMenuBG = ( self.nodePathMenuEntry.configure('background')[3]) - self.nodePathMenu.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.nodePathMenu.pack(side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.bind(self.nodePathMenu, 'Select active node path used for recording and playback') # Recording type @@ -285,81 +292,81 @@ class MopathRecorder(AppShell, DirectObject): 'Recording', 'Extend', ('Next record session extends existing path'), self.recordingType, 'Extend', expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) frame = Frame(mainFrame) widget = self.createCheckbutton( frame, 'Recording', 'Record', 'On: path is being recorded', self.toggleRecord, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 1) - widget.configure(foreground = 'Red', relief = Tkinter.RAISED, borderwidth = 2, - anchor = Tkinter.CENTER, width = 16) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 1) + widget.configure(foreground = 'Red', relief = tkinter.RAISED, borderwidth = 2, + anchor = tkinter.CENTER, width = 16) widget = self.createButton(frame, 'Recording', 'Add Keyframe', 'Add Keyframe To Current Path', self.addKeyframe, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget = self.createButton(frame, 'Recording', 'Bind Path to Node', 'Bind Motion Path to selected Object', self.bindMotionPathToNode, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) - frame.pack(fill = Tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) - mainFrame.pack(expand = 1, fill = Tkinter.X, pady = 3) + mainFrame.pack(expand = 1, fill = tkinter.X, pady = 3) # Playback controls - playbackFrame = Frame(interior, relief = Tkinter.SUNKEN, + playbackFrame = Frame(interior, relief = tkinter.SUNKEN, borderwidth = 2) Label(playbackFrame, text = 'PLAYBACK CONTROLS', - font=('MSSansSerif', 12, 'bold')).pack(fill = Tkinter.X) + font=('MSSansSerif', 12, 'bold')).pack(fill = tkinter.X) # Main playback control slider widget = self.createEntryScale( playbackFrame, 'Playback', 'Time', 'Set current playback time', - resolution = 0.01, command = self.playbackGoTo, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + resolution = 0.01, command = self.playbackGoTo, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE # Kill playback task if drag slider widget['preCallback'] = self.stopPlayback # Jam duration entry into entry scale self.createLabeledEntry(widget.labelFrame, 'Resample', 'Path Duration', 'Set total curve duration', command = self.setPathDuration, - side = Tkinter.LEFT, expand = 0) + side = tkinter.LEFT, expand = 0) # Start stop buttons frame = Frame(playbackFrame) widget = self.createButton(frame, 'Playback', '<<', 'Jump to start of playback', self.jumpToStartOfPlayback, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget['font'] = (('MSSansSerif', 12, 'bold')) widget = self.createCheckbutton(frame, 'Playback', 'Play', 'Start/Stop playback', self.startStopPlayback, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 1) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 1) widget.configure(anchor = 'center', justify = 'center', - relief = Tkinter.RAISED, font = ('MSSansSerif', 12, 'bold')) + relief = tkinter.RAISED, font = ('MSSansSerif', 12, 'bold')) widget = self.createButton(frame, 'Playback', '>>', 'Jump to end of playback', self.jumpToEndOfPlayback, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget['font'] = (('MSSansSerif', 12, 'bold')) self.createCheckbutton(frame, 'Playback', 'Loop', 'On: loop playback', self.setLoopPlayback, self.loopPlayback, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 0) + frame.pack(fill = tkinter.X, expand = 1) # Speed control frame = Frame(playbackFrame) - widget = Button(frame, text = 'PB Speed Vernier', relief = Tkinter.FLAT, + widget = Button(frame, text = 'PB Speed Vernier', relief = tkinter.FLAT, command = lambda s = self: s.setSpeedScale(1.0)) - widget.pack(side = Tkinter.LEFT, expand = 0) + widget.pack(side = tkinter.LEFT, expand = 0) self.speedScale = Scale(frame, from_ = -1, to = 1, resolution = 0.01, showvalue = 0, width = 10, orient = 'horizontal', command = self.setPlaybackSF) - self.speedScale.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.speedScale.pack(side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.speedVar = StringVar() self.speedVar.set("0.00") self.speedEntry = Entry(frame, textvariable = self.speedVar, @@ -368,14 +375,14 @@ class MopathRecorder(AppShell, DirectObject): '', lambda e = None, s = self: s.setSpeedScale( string.atof(s.speedVar.get()))) - self.speedEntry.pack(side = Tkinter.LEFT, expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + self.speedEntry.pack(side = tkinter.LEFT, expand = 0) + frame.pack(fill = tkinter.X, expand = 1) - playbackFrame.pack(fill = Tkinter.X, pady = 2) + playbackFrame.pack(fill = tkinter.X, pady = 2) # Create notebook pages self.mainNotebook = Pmw.NoteBook(interior) - self.mainNotebook.pack(fill = Tkinter.BOTH, expand = 1) + self.mainNotebook.pack(fill = tkinter.BOTH, expand = 1) self.resamplePage = self.mainNotebook.add('Resample') self.refinePage = self.mainNotebook.add('Refine') self.extendPage = self.mainNotebook.add('Extend') @@ -386,35 +393,35 @@ class MopathRecorder(AppShell, DirectObject): ## RESAMPLE PAGE label = Label(self.resamplePage, text = 'RESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) # Resample resampleFrame = Frame( - self.resamplePage, relief = Tkinter.SUNKEN, borderwidth = 2) + self.resamplePage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(resampleFrame, text = 'RESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')).pack() widget = self.createSlider( resampleFrame, 'Resample', 'Num. Samples', 'Number of samples in resampled curve', resolution = 1, min = 2, max = 1000, command = self.setNumSamples) - widget.component('hull')['relief'] = Tkinter.RIDGE + widget.component('hull')['relief'] = tkinter.RIDGE widget['postCallback'] = self.sampleCurve frame = Frame(resampleFrame) self.createButton( frame, 'Resample', 'Make Even', 'Apply timewarp so resulting path has constant velocity', - self.makeEven, side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.makeEven, side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.createButton( frame, 'Resample', 'Face Forward', 'Compute HPR so resulting hpr curve faces along xyz tangent', - self.faceForward, side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) - frame.pack(fill = Tkinter.X, expand = 0) - resampleFrame.pack(fill = Tkinter.X, expand = 0, pady = 2) + self.faceForward, side = tkinter.LEFT, fill = tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 0) + resampleFrame.pack(fill = tkinter.X, expand = 0, pady = 2) # Desample desampleFrame = Frame( - self.resamplePage, relief = Tkinter.SUNKEN, borderwidth = 2) + self.resamplePage, relief = tkinter.SUNKEN, borderwidth = 2) Label(desampleFrame, text = 'DESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')).pack() widget = self.createSlider( @@ -422,16 +429,16 @@ class MopathRecorder(AppShell, DirectObject): 'Specify number of points to skip between samples', min = 1, max = 100, resolution = 1, command = self.setDesampleFrequency) - widget.component('hull')['relief'] = Tkinter.RIDGE + widget.component('hull')['relief'] = tkinter.RIDGE widget['postCallback'] = self.desampleCurve - desampleFrame.pack(fill = Tkinter.X, expand = 0, pady = 2) + desampleFrame.pack(fill = tkinter.X, expand = 0, pady = 2) ## REFINE PAGE ## - refineFrame = Frame(self.refinePage, relief = Tkinter.SUNKEN, + refineFrame = Frame(self.refinePage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(refineFrame, text = 'REFINE CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider(refineFrame, 'Refine Page', 'Refine From', @@ -460,14 +467,14 @@ class MopathRecorder(AppShell, DirectObject): command = self.setRefineStop) widget['preCallback'] = self.setRefineMode widget['postCallback'] = self.getPostPoints - refineFrame.pack(fill = Tkinter.X) + refineFrame.pack(fill = tkinter.X) ## EXTEND PAGE ## - extendFrame = Frame(self.extendPage, relief = Tkinter.SUNKEN, + extendFrame = Frame(self.extendPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(extendFrame, text = 'EXTEND CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider(extendFrame, 'Extend Page', 'Extend From', @@ -483,14 +490,14 @@ class MopathRecorder(AppShell, DirectObject): resolution = 0.01, command = self.setControlStart) widget['preCallback'] = self.setExtendMode - extendFrame.pack(fill = Tkinter.X) + extendFrame.pack(fill = tkinter.X) ## CROP PAGE ## - cropFrame = Frame(self.cropPage, relief = Tkinter.SUNKEN, + cropFrame = Frame(self.cropPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(cropFrame, text = 'CROP CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider( cropFrame, @@ -508,11 +515,11 @@ class MopathRecorder(AppShell, DirectObject): self.createButton(cropFrame, 'Crop Page', 'Crop Curve', 'Crop curve to specified from to times', - self.cropCurve, fill = Tkinter.NONE) - cropFrame.pack(fill = Tkinter.X) + self.cropCurve, fill = tkinter.NONE) + cropFrame.pack(fill = tkinter.X) ## DRAW PAGE ## - drawFrame = Frame(self.drawPage, relief = Tkinter.SUNKEN, + drawFrame = Frame(self.drawPage, relief = tkinter.SUNKEN, borderwidth = 2) self.sf = Pmw.ScrolledFrame(self.drawPage, horizflex = 'elastic') @@ -521,57 +528,57 @@ class MopathRecorder(AppShell, DirectObject): label = Label(sfFrame, text = 'CURVE RENDERING STYLE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) frame = Frame(sfFrame) - Label(frame, text = 'SHOW:').pack(side = Tkinter.LEFT, expand = 0) + Label(frame, text = 'SHOW:').pack(side = tkinter.LEFT, expand = 0) widget = self.createCheckbutton( frame, 'Style', 'Path', 'On: path is visible', self.setPathVis, 1, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Knots', 'On: path knots are visible', self.setKnotVis, 1, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'CVs', 'On: path CVs are visible', self.setCvVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Hull', 'On: path hull is visible', self.setHullVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Trace', 'On: record is visible', self.setTraceVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Marker', 'On: playback marker is visible', self.setMarkerVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) - frame.pack(fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) # Sliders widget = self.createSlider( sfFrame, 'Style', 'Num Segs', 'Set number of segments used to approximate each parametric unit', min = 1.0, max = 400, resolution = 1.0, value = 40, - command = self.setNumSegs, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setNumSegs, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE widget = self.createSlider( sfFrame, 'Style', 'Num Ticks', 'Set number of tick marks drawn for each unit of time', min = 0.0, max = 10.0, resolution = 1.0, value = 0.0, - command = self.setNumTicks, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setNumTicks, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE widget = self.createSlider( sfFrame, 'Style', 'Tick Scale', 'Set visible size of time tick marks', min = 0.01, max = 100.0, resolution = 0.01, value = 5.0, - command = self.setTickScale, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setTickScale, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE self.createColorEntry( sfFrame, 'Style', 'Path Color', 'Color of curve', @@ -598,14 +605,14 @@ class MopathRecorder(AppShell, DirectObject): command = self.setHullColor, value = [255.0,128.0,128.0,255.0]) - #drawFrame.pack(fill = Tkinter.X) + #drawFrame.pack(fill = tkinter.X) ## OPTIONS PAGE ## - optionsFrame = Frame(self.optionsPage, relief = Tkinter.SUNKEN, + optionsFrame = Frame(self.optionsPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(optionsFrame, text = 'RECORDING OPTIONS', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) # Hooks frame = Frame(optionsFrame) widget = self.createLabeledEntry( @@ -614,7 +621,7 @@ class MopathRecorder(AppShell, DirectObject): value = self.startStopHook, command = self.setStartStopHook)[0] label = self.getWidget('Recording', 'Record Hook-Label') - label.configure(width = 16, anchor = Tkinter.W) + label.configure(width = 16, anchor = tkinter.W) self.setStartStopHook() widget = self.createLabeledEntry( frame, 'Recording', 'Keyframe Hook', @@ -622,9 +629,9 @@ class MopathRecorder(AppShell, DirectObject): value = self.keyframeHook, command = self.setKeyframeHook)[0] label = self.getWidget('Recording', 'Keyframe Hook-Label') - label.configure(width = 16, anchor = Tkinter.W) + label.configure(width = 16, anchor = tkinter.W) self.setKeyframeHook() - frame.pack(expand = 1, fill = Tkinter.X) + frame.pack(expand = 1, fill = tkinter.X) # PreRecordFunc frame = Frame(optionsFrame) widget = self.createComboBox( @@ -632,17 +639,17 @@ class MopathRecorder(AppShell, DirectObject): 'Function called before sampling each point', PRF_UTILITIES, self.setPreRecordFunc, history = 1, expand = 1) - widget.configure(label_width = 16, label_anchor = Tkinter.W) + widget.configure(label_width = 16, label_anchor = tkinter.W) widget.configure(entryfield_entry_state = 'normal') # Initialize preRecordFunc self.preRecordFunc = eval(PRF_UTILITIES[0]) self.createCheckbutton(frame, 'Recording', 'PRF Active', 'On: Pre Record Func enabled', None, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 0) - frame.pack(expand = 1, fill = Tkinter.X) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 0) + frame.pack(expand = 1, fill = tkinter.X) # Pack record frame - optionsFrame.pack(fill = Tkinter.X, pady = 2) + optionsFrame.pack(fill = tkinter.X, pady = 2) self.mainNotebook.setnaturalsize() @@ -682,16 +689,16 @@ class MopathRecorder(AppShell, DirectObject): marker if subnode selected """ taskMgr.remove(self.name + '-curveEditTask') - print nodePath.id() - if nodePath.id() in self.playbackMarkerIds: + print(nodePath.get_key()) + if nodePath.get_key() in self.playbackMarkerIds: SEditor.select(self.playbackMarker) - elif nodePath.id() in self.tangentMarkerIds: + elif nodePath.get_key() in self.tangentMarkerIds: SEditor.select(self.tangentMarker) - elif nodePath.id() == self.playbackMarker.id(): + elif nodePath.get_key() == self.playbackMarker.get_key(): self.tangentGroup.show() taskMgr.add(self.curveEditTask, self.name + '-curveEditTask') - elif nodePath.id() == self.tangentMarker.id(): + elif nodePath.get_key() == self.tangentMarker.get_key(): self.tangentGroup.show() taskMgr.add(self.curveEditTask, self.name + '-curveEditTask') @@ -699,7 +706,7 @@ class MopathRecorder(AppShell, DirectObject): self.tangentGroup.hide() def getChildIds(self, nodePath): - ids = [nodePath.id()] + ids = [nodePath.get_key()] kids = nodePath.getChildren() for kid in kids: ids += self.getChildIds(kid) @@ -710,14 +717,14 @@ class MopathRecorder(AppShell, DirectObject): Hook called upon deselection of a node path used to select playback marker if subnode selected """ - if ((nodePath.id() == self.playbackMarker.id()) or - (nodePath.id() == self.tangentMarker.id())): + if ((nodePath.get_key() == self.playbackMarker.get_key()) or + (nodePath.get_key() == self.tangentMarker.get_key())): self.tangentGroup.hide() def curveEditTask(self,state): if self.curveCollection != None: # Update curve position - if self.manipulandumId == self.playbackMarker.id(): + if self.manipulandumId == self.playbackMarker.get_key(): # Show playback marker self.playbackMarker.getChild(0).show() pos = Point3(0) @@ -731,7 +738,7 @@ class MopathRecorder(AppShell, DirectObject): # Note: this calls recompute on the curves self.nurbsCurveDrawer.draw() # Update tangent - if self.manipulandumId == self.tangentMarker.id(): + if self.manipulandumId == self.tangentMarker.get_key(): # If manipulating marker, update tangent # Hide playback marker self.playbackMarker.getChild(0).hide() @@ -766,10 +773,10 @@ class MopathRecorder(AppShell, DirectObject): def manipulateObjectStartHook(self): self.manipulandumId = None if SEditor.selected.last: - if SEditor.selected.last.id() == self.playbackMarker.id(): - self.manipulandumId = self.playbackMarker.id() - elif SEditor.selected.last.id() == self.tangentMarker.id(): - self.manipulandumId = self.tangentMarker.id() + if SEditor.selected.last.get_key() == self.playbackMarker.get_key(): + self.manipulandumId = self.playbackMarker.get_key() + elif SEditor.selected.last.get_key() == self.tangentMarker.get_key(): + self.manipulandumId = self.tangentMarker.get_key() def manipulateObjectCleanupHook(self): # Clear flag @@ -799,7 +806,7 @@ class MopathRecorder(AppShell, DirectObject): def createNewPointSet(self, curveName = None): if curveName == None: - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) else: self.pointSetName = curveName # Update dictionary and record pointer to new point set @@ -1137,7 +1144,7 @@ class MopathRecorder(AppShell, DirectObject): def computeCurves(self): # Check to make sure curve fitters have points if (self.curveFitter.getNumSamples() == 0): - print 'MopathRecorder.computeCurves: Must define curve first' + print('MopathRecorder.computeCurves: Must define curve first') return # Create curves # XYZ @@ -1282,8 +1289,8 @@ class MopathRecorder(AppShell, DirectObject): dictName = name else: # Generate a unique name for the dict - dictName = name # + '-' + `nodePath.id()` - if not dict.has_key(dictName): + dictName = name # + '-' + repr(nodePath.get_key()) + if dictName not in dict: # Update combo box to include new item names.append(dictName) listbox = menu.component('scrolledlist') @@ -1386,7 +1393,7 @@ class MopathRecorder(AppShell, DirectObject): def desampleCurve(self): if (self.curveFitter.getNumSamples() == 0): - print 'MopathRecorder.desampleCurve: Must define curve first' + print('MopathRecorder.desampleCurve: Must define curve first') return # NOTE: This is destructive, points will be deleted from curve fitter self.curveFitter.desample(self.desampleFrequency) @@ -1400,7 +1407,7 @@ class MopathRecorder(AppShell, DirectObject): def sampleCurve(self, fCompute = 1, curveName = None): if self.curveCollection == None: - print 'MopathRecorder.sampleCurve: Must define curve first' + print('MopathRecorder.sampleCurve: Must define curve first') return # Reset curve fitters self.curveFitter.reset() @@ -1617,7 +1624,7 @@ class MopathRecorder(AppShell, DirectObject): def cropCurve(self): if self.pointSet == None: - print 'Empty Point Set' + print('Empty Point Set') return # Keep handle on old points oldPoints = self.pointSet @@ -1653,15 +1660,15 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'MopathRecorder Info: Empty Model Path!' - print 'Using current directory' + print('MopathRecorder Info: Empty Model Path!') + print('Using current directory') path = '.' mopathFilename = askopenfilename( defaultextension = '.egg', @@ -1692,15 +1699,15 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'MopathRecorder Info: Empty Model Path!' - print 'Using current directory' + print('MopathRecorder Info: Empty Model Path!') + print('Using current directory') path = '.' mopathFilename = asksaveasfilename( defaultextension = '.egg', @@ -1734,28 +1741,28 @@ class MopathRecorder(AppShell, DirectObject): def createLabeledEntry(self, parent, category, text, balloonHelp, value = '', command = None, - relief = 'sunken', side = Tkinter.LEFT, + relief = 'sunken', side = tkinter.LEFT, expand = 1, width = 12): frame = Frame(parent) variable = StringVar() variable.set(value) label = Label(frame, text = text) - label.pack(side = Tkinter.LEFT, fill = Tkinter.X) + label.pack(side = tkinter.LEFT, fill = tkinter.X) self.bind(label, balloonHelp) self.widgetDict[category + '-' + text + '-Label'] = label entry = Entry(frame, width = width, relief = relief, textvariable = variable) - entry.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = expand) + entry.pack(side = tkinter.LEFT, fill = tkinter.X, expand = expand) self.bind(entry, balloonHelp) self.widgetDict[category + '-' + text] = entry self.variableDict[category + '-' + text] = variable if command: entry.bind('', command) - frame.pack(side = side, fill = Tkinter.X, expand = expand) + frame.pack(side = side, fill = tkinter.X, expand = expand) return (frame, label, entry) def createButton(self, parent, category, text, balloonHelp, command, - side = 'top', expand = 0, fill = Tkinter.X): + side = 'top', expand = 0, fill = tkinter.X): widget = Button(parent, text = text) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1766,10 +1773,10 @@ class MopathRecorder(AppShell, DirectObject): def createCheckbutton(self, parent, category, text, balloonHelp, command, initialState, - side = 'top', fill = Tkinter.X, expand = 0): + side = 'top', fill = tkinter.X, expand = 0): bool = BooleanVar() bool.set(initialState) - widget = Checkbutton(parent, text = text, anchor = Tkinter.W, + widget = Checkbutton(parent, text = text, anchor = tkinter.W, variable = bool) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1781,8 +1788,8 @@ class MopathRecorder(AppShell, DirectObject): def createRadiobutton(self, parent, side, category, text, balloonHelp, variable, value, - command = None, fill = Tkinter.X, expand = 0): - widget = Radiobutton(parent, text = text, anchor = Tkinter.W, + command = None, fill = tkinter.X, expand = 0): + widget = Radiobutton(parent, text = text, anchor = tkinter.W, variable = variable, value = value) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1798,10 +1805,10 @@ class MopathRecorder(AppShell, DirectObject): kw['min'] = min kw['maxVelocity'] = maxVelocity kw['resolution'] = resolution - widget = apply(Floater, (parent,), kw) + widget = Floater(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1809,10 +1816,10 @@ class MopathRecorder(AppShell, DirectObject): def createAngleDial(self, parent, category, text, balloonHelp, command = None, **kw): kw['text'] = text - widget = apply(AngleDial,(parent,), kw) + widget = AngleDial(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1820,13 +1827,13 @@ class MopathRecorder(AppShell, DirectObject): def createSlider(self, parent, category, text, balloonHelp, command = None, min = 0.0, max = 1.0, resolution = None, - side = Tkinter.TOP, fill = Tkinter.X, expand = 1, **kw): + side = tkinter.TOP, fill = tkinter.X, expand = 1, **kw): kw['text'] = text kw['min'] = min kw['max'] = max kw['resolution'] = resolution #widget = apply(EntryScale, (parent,), kw) - widget = apply(Slider, (parent,), kw) + widget = Slider(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(side = side, fill = fill, expand = expand) @@ -1837,12 +1844,12 @@ class MopathRecorder(AppShell, DirectObject): def createEntryScale(self, parent, category, text, balloonHelp, command = None, min = 0.0, max = 1.0, resolution = None, - side = Tkinter.TOP, fill = Tkinter.X, expand = 1, **kw): + side = tkinter.TOP, fill = tkinter.X, expand = 1, **kw): kw['text'] = text kw['min'] = min kw['max'] = max kw['resolution'] = resolution - widget = apply(EntryScale, (parent,), kw) + widget = EntryScale(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(side = side, fill = fill, expand = expand) @@ -1854,10 +1861,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector2Entry, (parent,), kw) + widget = Vector2Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1866,10 +1873,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector3Entry, (parent,), kw) + widget = Vector3Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1878,10 +1885,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(ColorEntry, (parent,) ,kw) + widget = ColorEntry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1891,13 +1898,13 @@ class MopathRecorder(AppShell, DirectObject): optionVar = StringVar() if len(items) > 0: optionVar.set(items[0]) - widget = Pmw.OptionMenu(parent, labelpos = Tkinter.W, label_text = text, + widget = Pmw.OptionMenu(parent, labelpos = tkinter.W, label_text = text, label_width = 12, menu_tearoff = 1, menubutton_textvariable = optionVar, items = items) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget.component('menubutton'), balloonHelp) self.widgetDict[category + '-' + text] = widget self.variableDict[category + '-' + text] = optionVar @@ -1905,9 +1912,9 @@ class MopathRecorder(AppShell, DirectObject): def createComboBox(self, parent, category, text, balloonHelp, items, command, history = 0, - side = Tkinter.LEFT, expand = 0, fill = Tkinter.X): + side = tkinter.LEFT, expand = 0, fill = tkinter.X): widget = Pmw.ComboBox(parent, - labelpos = Tkinter.W, + labelpos = tkinter.W, label_text = text, label_anchor = 'e', label_width = 12, @@ -1959,14 +1966,14 @@ class MopathRecorder(AppShell, DirectObject): def bindMotionPathToNode(self): if self.curveCollection == None: - print '----Error: you need to select or create a curve first!' + print('----Error: you need to select or create a curve first!') return self.accept('MP_checkName', self.bindMotionPath) self.askName = namePathPanel(MopathRecorder.count) return def bindMotionPath(self,name=None,test=None): - print test + print(test) self.ignore('MP_checkName') del self.askName self.curveCollection.getCurve(0).setName(name) @@ -1993,7 +2000,7 @@ class MopathRecorder(AppShell, DirectObject): If the list is not None, it will put the vurve back into the curve list. else, do nothing. ''' - print curveList + print(curveList) self.ignore('curveListFor'+self.name) if curveList != None: for collection in curveList: @@ -2037,8 +2044,8 @@ class namePathPanel(AppShell): dataFrame = Frame(mainFrame) label = Label(dataFrame, text='This name will be used as a reference for this Path.',font=('MSSansSerif', 10)) - label.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X) - dataFrame.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X, padx=5, pady=10) + label.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X) + dataFrame.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X, padx=5, pady=10) dataFrame = Frame(mainFrame) self.inputZone = Pmw.EntryField(dataFrame, labelpos='w', label_text = 'Name Selected Path: ', @@ -2046,14 +2053,14 @@ class namePathPanel(AppShell): label_font=('MSSansSerif', 10), validate = None, entry_width = 20) - self.inputZone.pack(side = Tkinter.LEFT, fill=Tkinter.X,expand=0) + self.inputZone.pack(side = tkinter.LEFT, fill=tkinter.X,expand=0) self.button_ok = Button(dataFrame, text="OK", command=self.ok_press,width=10) - self.button_ok.pack(fill=Tkinter.X,expand=0,side=Tkinter.LEFT, padx = 3) + self.button_ok.pack(fill=tkinter.X,expand=0,side=tkinter.LEFT, padx = 3) - dataFrame.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X, padx=10, pady=10) + dataFrame.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X, padx=10, pady=10) - mainFrame.pack(expand = 1, fill = Tkinter.BOTH) + mainFrame.pack(expand = 1, fill = tkinter.BOTH) diff --git a/contrib/src/sceneeditor/seParticleEffect.py b/contrib/src/sceneeditor/seParticleEffect.py index 068f8f234e..a36f7d4025 100644 --- a/contrib/src/sceneeditor/seParticleEffect.py +++ b/contrib/src/sceneeditor/seParticleEffect.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * import seParticles import seForceGroup from direct.directnotify import DirectNotifyGlobal @@ -209,9 +209,9 @@ class ParticleEffect(NodePath): """loadConfig(filename)""" #try: # if vfs: - print vfs.readFile(filename) - exec vfs.readFile(filename) - print "Particle Effect Reading using VFS" + print(vfs.readFile(filename)) + exec(vfs.readFile(filename)) + print("Particle Effect Reading using VFS") # else: # execfile(filename.toOsSpecific()) # print "Shouldnt be wrong" diff --git a/contrib/src/sceneeditor/seParticlePanel.py b/contrib/src/sceneeditor/seParticlePanel.py index 099e31012d..3c359e2628 100644 --- a/contrib/src/sceneeditor/seParticlePanel.py +++ b/contrib/src/sceneeditor/seParticlePanel.py @@ -2,9 +2,7 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import AppShell -from tkFileDialog import * -from tkSimpleDialog import askstring -import os, Pmw, Tkinter +import os, Pmw, sys from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Floater import Floater from direct.tkwidgets.Slider import Slider @@ -15,6 +13,15 @@ import seForceGroup import seParticles import seParticleEffect + +if sys.version_info >= (3, 0): + from tkinter.filedialog import * + from tkinter.simpledialog import askstring +else: + from tkFileDialog import * + from tkSimpleDialog import askstring + + class ParticlePanel(AppShell): # Override class variables appname = 'Particle Panel' @@ -774,7 +781,7 @@ class ParticlePanel(AppShell): kw['min'] = min kw['resolution'] = resolution kw['numDigits'] = numDigits - widget = apply(Floater, (parent,), kw) + widget = Floater(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -786,7 +793,7 @@ class ParticlePanel(AppShell): command = None, **kw): kw['text'] = text kw['style'] = 'mini' - widget = apply(AngleDial,(parent,), kw) + widget = AngleDial(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -801,7 +808,7 @@ class ParticlePanel(AppShell): kw['min'] = min kw['max'] = max kw['resolution'] = resolution - widget = apply(Slider, (parent,), kw) + widget = Slider(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -813,7 +820,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector2Entry, (parent,), kw) + widget = Vector2Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -825,7 +832,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector3Entry, (parent,), kw) + widget = Vector3Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -837,7 +844,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(ColorEntry, (parent,) ,kw) + widget = ColorEntry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -992,7 +999,7 @@ class ParticlePanel(AppShell): self.mainNotebook.selectpage('System') self.updateInfo('System') else: - print 'ParticlePanel: No effect named ' + name + print('ParticlePanel: No effect named ' + name) def toggleEffect(self, effect, var): if var.get(): @@ -1041,15 +1048,15 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'ParticlePanel Warning: Invalid default DNA directory!' - print 'Using current directory' + print('ParticlePanel Warning: Invalid default DNA directory!') + print('Using current directory') path = '.' particleFilename = askopenfilename( defaultextension = '.ptf', @@ -1070,15 +1077,15 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'ParticlePanel Warning: Invalid default DNA directory!' - print 'Using current directory' + print('ParticlePanel Warning: Invalid default DNA directory!') + print('Using current directory') path = '.' particleFilename = asksaveasfilename( defaultextension = '.ptf', @@ -1654,7 +1661,7 @@ class ParticlePanel(AppShell): def setRendererSpriteNonAnimatedTheta(self, theta): self.particles.renderer.setNonanimatedTheta(theta) def setRendererSpriteBlendMethod(self, blendMethod): - print blendMethod + print(blendMethod) if blendMethod == 'PP_NO_BLEND': bMethod = BaseParticleRenderer.PPNOBLEND elif blendMethod == 'PP_BLEND_LINEAR': @@ -1863,7 +1870,7 @@ class ParticlePanel(AppShell): count, force): def setVec(vec, f = force): f.setVector(vec[0], vec[1], vec[2]) - forceName = 'Vector Force-' + `count` + forceName = 'Vector Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) vec = force.getLocalVector() @@ -1875,7 +1882,7 @@ class ParticlePanel(AppShell): def createLinearRandomForceWidget(self, forcePage, pageName, count, force, type): - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createForceActiveWidget(frame, pageName, forceName, force) @@ -1884,7 +1891,7 @@ class ParticlePanel(AppShell): count, force): def setCoef(coef, f = force): f.setCoef(coef) - forceName = 'Friction Force-' + `count` + forceName = 'Friction Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createFloater(frame, pageName, forceName + ' Coef', @@ -1895,7 +1902,7 @@ class ParticlePanel(AppShell): def createLinearCylinderVortexForceWidget(self, forcePage, pageName, count, force): - forceName = 'Vortex Force-' + `count` + forceName = 'Vortex Force-' + repr(count) def setCoef(coef, f = force): f.setCoef(coef) def setLength(length, f = force): @@ -1934,7 +1941,7 @@ class ParticlePanel(AppShell): f.setForceCenter(Point3(vec[0], vec[1], vec[2])) def setRadius(radius, f = force): f.setRadius(radius) - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) var = self.createOptionMenu( diff --git a/contrib/src/sceneeditor/seParticles.py b/contrib/src/sceneeditor/seParticles.py index b062a3e00a..a4f0d0e5d6 100644 --- a/contrib/src/sceneeditor/seParticles.py +++ b/contrib/src/sceneeditor/seParticles.py @@ -1,28 +1,8 @@ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.physics import * from direct.particles.ParticleManagerGlobal import * from direct.showbase.PhysicsManagerGlobal import * -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import ParticleSystem -from pandac.PandaModules import BaseParticleFactory -from pandac.PandaModules import PointParticleFactory -from pandac.PandaModules import ZSpinParticleFactory #import OrientedParticleFactory -from pandac.PandaModules import BaseParticleRenderer -from pandac.PandaModules import PointParticleRenderer -from pandac.PandaModules import LineParticleRenderer -from pandac.PandaModules import GeomParticleRenderer -from pandac.PandaModules import SparkleParticleRenderer -from pandac.PandaModules import SpriteParticleRenderer -from pandac.PandaModules import BaseParticleEmitter -from pandac.PandaModules import BoxEmitter -from pandac.PandaModules import DiscEmitter -from pandac.PandaModules import LineEmitter -from pandac.PandaModules import PointEmitter -from pandac.PandaModules import RectangleEmitter -from pandac.PandaModules import RingEmitter -from pandac.PandaModules import SphereSurfaceEmitter -from pandac.PandaModules import SphereVolumeEmitter -from pandac.PandaModules import TangentRingEmitter import string import os from direct.directnotify import DirectNotifyGlobal @@ -113,7 +93,7 @@ class Particles(ParticleSystem): elif (type == "OrientedParticleFactory"): self.factory = OrientedParticleFactory.OrientedParticleFactory() else: - print "unknown factory type: %s" % type + print("unknown factory type: %s" % type) return None self.factory.setLifespanBase(0.5) ParticleSystem.ParticleSystem.setFactory(self, self.factory) @@ -152,7 +132,7 @@ class Particles(ParticleSystem): # See sourceFileName and sourceNodeName in SpriteParticleRenderer-extensions.py self.renderer.setTextureFromNode() else: - print "unknown renderer type: %s" % type + print("unknown renderer type: %s" % type) return None ParticleSystem.ParticleSystem.setRenderer(self, self.renderer) @@ -183,7 +163,7 @@ class Particles(ParticleSystem): elif (type == "TangentRingEmitter"): self.emitter = TangentRingEmitter.TangentRingEmitter() else: - print "unknown emitter type: %s" % type + print("unknown emitter type: %s" % type) return None ParticleSystem.ParticleSystem.setEmitter(self, self.emitter) diff --git a/contrib/src/sceneeditor/sePlacer.py b/contrib/src/sceneeditor/sePlacer.py index 108ef7fbc6..15804629a7 100644 --- a/contrib/src/sceneeditor/sePlacer.py +++ b/contrib/src/sceneeditor/sePlacer.py @@ -5,9 +5,16 @@ from direct.directtools.DirectGlobals import * from direct.tkwidgets.AppShell import AppShell from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Floater import Floater -from Tkinter import Button, Menubutton, Menu, StringVar -from pandac.PandaModules import * -import Tkinter, Pmw +from panda3d.core import * +import sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Button, Menubutton, Menu, StringVar + import tkinter +else: + from Tkinter import Button, Menubutton, Menu, StringVar + import Tkinter as tkinter + """ TODO: Task to monitor pose @@ -84,7 +91,7 @@ class Placer(AppShell): def createInterface(self): # The interior of the toplevel panel interior = self.interior() - interior['relief'] = Tkinter.FLAT + interior['relief'] = tkinter.FLAT # Add placer commands to menubar self.menuBar.addmenu('Placer', 'Placer Panel Operations') self.menuBar.addmenuitem('Placer', 'command', @@ -113,7 +120,7 @@ class Placer(AppShell): # Get a handle to the menu frame menuFrame = self.menuFrame self.nodePathMenu = Pmw.ComboBox( - menuFrame, labelpos = Tkinter.W, label_text = 'Node Path:', + menuFrame, labelpos = tkinter.W, label_text = 'Node Path:', entry_width = 20, selectioncommand = self.selectNodePathNamed, scrolledlist_items = self.nodePathNames) @@ -168,7 +175,7 @@ class Placer(AppShell): tag_text = 'Position', tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) posMenubutton = posGroup.component('tag') self.bind(posMenubutton, 'Position menu operations') posMenu = Menu(posMenubutton, tearoff = 0) @@ -182,7 +189,7 @@ class Placer(AppShell): # Create the dials self.posX = self.createcomponent('posX', (), None, Floater, (posInterior,), - text = 'X', relief = Tkinter.FLAT, + text = 'X', relief = tkinter.FLAT, value = 0.0, label_foreground = 'Red') self.posX['commandData'] = ['x'] @@ -193,7 +200,7 @@ class Placer(AppShell): self.posY = self.createcomponent('posY', (), None, Floater, (posInterior,), - text = 'Y', relief = Tkinter.FLAT, + text = 'Y', relief = tkinter.FLAT, value = 0.0, label_foreground = '#00A000') self.posY['commandData'] = ['y'] @@ -204,7 +211,7 @@ class Placer(AppShell): self.posZ = self.createcomponent('posZ', (), None, Floater, (posInterior,), - text = 'Z', relief = Tkinter.FLAT, + text = 'Z', relief = tkinter.FLAT, value = 0.0, label_foreground = 'Blue') self.posZ['commandData'] = ['z'] @@ -219,7 +226,7 @@ class Placer(AppShell): tag_text = 'Orientation', tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) hprMenubutton = hprGroup.component('tag') self.bind(hprMenubutton, 'Orientation menu operations') hprMenu = Menu(hprMenubutton, tearoff = 0) @@ -234,7 +241,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'H', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = 'blue') self.hprH['commandData'] = ['h'] self.hprH['preCallback'] = self.xformStart @@ -246,7 +253,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'P', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = 'red') self.hprP['commandData'] = ['p'] self.hprP['preCallback'] = self.xformStart @@ -258,7 +265,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'R', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = '#00A000') self.hprR['commandData'] = ['r'] self.hprR['preCallback'] = self.xformStart @@ -276,7 +283,7 @@ class Placer(AppShell): tag_pyclass = Menubutton, tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) self.scaleMenubutton = scaleGroup.component('tag') self.bind(self.scaleMenubutton, 'Scale menu operations') self.scaleMenubutton['textvariable'] = self.scalingMode @@ -302,7 +309,7 @@ class Placer(AppShell): self.scaleX = self.createcomponent('scaleX', (), None, Floater, (scaleInterior,), text = 'X Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = 'Red') @@ -315,7 +322,7 @@ class Placer(AppShell): self.scaleY = self.createcomponent('scaleY', (), None, Floater, (scaleInterior,), text = 'Y Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = '#00A000') @@ -328,7 +335,7 @@ class Placer(AppShell): self.scaleZ = self.createcomponent('scaleZ', (), None, Floater, (scaleInterior,), text = 'Z Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = 'Blue') @@ -428,7 +435,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.get_key() == self['nodePath'].get_key())): # Yes they are, use temp CS as ref # This calls updatePlacer self.setReferenceNodePath(self.tempCS) @@ -473,7 +480,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.get_key() == self['nodePath'].get_key()): # Yes they are, use temp CS and update listbox accordingly nodePath = self.tempCS self.refNodePathMenu.selectitem('parent') @@ -508,8 +515,8 @@ class Placer(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.id()` - if not dict.has_key(dictName): + dictName = name + '-' + repr(nodePath.get_key()) + if dictName not in dict: # Update combo box to include new item names.append(dictName) listbox = menu.component('scrolledlist') @@ -769,12 +776,12 @@ class Placer(AppShell): posString = '%.2f, %.2f, %.2f' % (pos[0], pos[1], pos[2]) hprString = '%.2f, %.2f, %.2f' % (hpr[0], hpr[1], hpr[2]) scaleString = '%.2f, %.2f, %.2f' % (scale[0], scale[1], scale[2]) - print 'NodePath: %s' % name - print 'Pos: %s' % posString - print 'Hpr: %s' % hprString - print 'Scale: %s' % scaleString - print ('%s.setPosHprScale(%s, %s, %s)' % - (name, posString, hprString, scaleString)) + print('NodePath: %s' % name) + print('Pos: %s' % posString) + print('Hpr: %s' % hprString) + print('Scale: %s' % scaleString) + print(('%s.setPosHprScale(%s, %s, %s)' % + (name, posString, hprString, scaleString))) def onDestroy(self, event): # Remove hooks diff --git a/contrib/src/sceneeditor/seSceneGraphExplorer.py b/contrib/src/sceneeditor/seSceneGraphExplorer.py index a864d11e90..163287965c 100644 --- a/contrib/src/sceneeditor/seSceneGraphExplorer.py +++ b/contrib/src/sceneeditor/seSceneGraphExplorer.py @@ -9,9 +9,16 @@ # ################################################################# from direct.showbase.DirectObject import DirectObject -from Tkinter import IntVar, Frame, Label from seTree import TreeNode, TreeItem -import Pmw, Tkinter + +import Pmw, sys + +if sys.version_info >= (3, 0): + from tkinter import IntVar, Frame, Label + import tkinter +else: + from Tkinter import IntVar, Frame, Label + import Tkinter as tkinter # changing these strings requires changing sceneEditor.py SGE_ strs too! # This list of items will be showed on the pop out window when user right click on @@ -57,7 +64,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): # Setup up container interior = self.interior() - interior.configure(relief = Tkinter.GROOVE, borderwidth = 2) + interior.configure(relief = tkinter.GROOVE, borderwidth = 2) # Create a label and an entry self._scrolledCanvas = self.createcomponent( @@ -69,7 +76,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): self._canvas = self._scrolledCanvas.component('canvas') self._canvas['scrollregion'] = ('0i', '0i', '2i', '4i') self._scrolledCanvas.resizescrollregion() - self._scrolledCanvas.pack(padx = 3, pady = 3, expand=1, fill = Tkinter.BOTH) + self._scrolledCanvas.pack(padx = 3, pady = 3, expand=1, fill = tkinter.BOTH) self._canvas.bind('', self.mouse2Down) self._canvas.bind('', self.mouse2Motion) @@ -91,8 +98,8 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): (), None, Label, (interior,), text = 'Active Reparent Target: ', - anchor = Tkinter.W, justify = Tkinter.LEFT) - self._label.pack(fill = Tkinter.X) + anchor = tkinter.W, justify = tkinter.LEFT) + self._label.pack(fill = tkinter.X) # Add update parent label def updateLabel(nodePath = None, s = self): @@ -141,11 +148,11 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): self._node.deselecttree() def selectNodePath(self,nodePath, callBack=True): - item = self._node.find(nodePath.id()) + item = self._node.find(nodePath.get_key()) if item!= None: item.select(callBack) else: - print '----SGE: Error Selection' + print('----SGE: Error Selection') class SceneGraphExplorerItem(TreeItem): @@ -164,7 +171,7 @@ class SceneGraphExplorerItem(TreeItem): return name def GetKey(self): - return self.nodePath.id() + return self.nodePath.get_key() def IsEditable(self): # All nodes' names can be edited nowadays. diff --git a/contrib/src/sceneeditor/seSelection.py b/contrib/src/sceneeditor/seSelection.py index 73cdb1ea46..b7d9b260dc 100644 --- a/contrib/src/sceneeditor/seSelection.py +++ b/contrib/src/sceneeditor/seSelection.py @@ -11,7 +11,7 @@ # (If we do change original directools, it will force user has to install the latest version of OUR Panda) # ################################################################# -from pandac.PandaModules import GeomNode +from panda3d.core import GeomNode from direct.directtools.DirectGlobals import * from direct.directtools.DirectUtil import * from seGeometry import * @@ -70,7 +70,7 @@ class SelectedNodePaths(DirectObject): """ Select the specified node path. Multiselect as required """ # Do nothing if nothing selected if not nodePath: - print 'Nothing selected!!' + print('Nothing selected!!') return None # Reset selected objects and highlight if multiSelect is false @@ -78,7 +78,7 @@ class SelectedNodePaths(DirectObject): self.deselectAll() # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # First see if its already in the selected dictionary dnp = self.getSelectedDict(id) # If so, we're done @@ -96,7 +96,7 @@ class SelectedNodePaths(DirectObject): # Show its bounding box dnp.highlight() # Add it to the selected dictionary - self.selectedDict[dnp.id()] = dnp + self.selectedDict[dnp.get_key()] = dnp # And update last __builtins__["last"] = self.last = dnp return dnp @@ -104,7 +104,7 @@ class SelectedNodePaths(DirectObject): def deselect(self, nodePath): """ Deselect the specified node path """ # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # See if it is in the selected dictionary dnp = self.getSelectedDict(id) if dnp: @@ -124,7 +124,7 @@ class SelectedNodePaths(DirectObject): Return a list of all selected node paths. No verification of connectivity is performed on the members of the list """ - return self.selectedDict.values()[:] + return list(self.selectedDict.values()) def __getitem__(self,index): return self.getSelectedAsList()[index] @@ -141,7 +141,7 @@ class SelectedNodePaths(DirectObject): return None def getDeselectedAsList(self): - return self.deselectedDict.values()[:] + return list(self.deselectedDict.values()) def getDeselectedDict(self, id): """ @@ -204,15 +204,24 @@ class SelectedNodePaths(DirectObject): # Remove all selected nodePaths from the Scene Graph self.forEachSelectedNodePathDo(NodePath.remove) + def toggleVis(self, nodePath): + if nodePath.is_hidden(): + nodePath.show() + else: + nodePath.hide() + def toggleVisSelected(self): selected = self.last # Toggle visibility of selected node paths if selected: - selected.toggleVis() + if selected.is_hidden(): + selected.show() + else: + selected.hide() def toggleVisAll(self): # Toggle viz for all selected node paths - self.forEachSelectedNodePathDo(NodePath.toggleVis) + self.forEachSelectedNodePathDo(self.toggleVis) def isolateSelected(self): selected = self.last @@ -221,7 +230,7 @@ class SelectedNodePaths(DirectObject): def getDirectNodePath(self, nodePath): # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # First check selected dict dnp = self.getSelectedDict(id) if dnp: @@ -376,7 +385,7 @@ class DirectBoundingBox: return '%.2f %.2f %.2f' % (vec[0], vec[1], vec[2]) def __repr__(self): - return (`self.__class__` + + return (repr(self.__class__) + '\nNodePath:\t%s\n' % self.nodePath.getName() + 'Min:\t\t%s\n' % self.vecAsString(self.min) + 'Max:\t\t%s\n' % self.vecAsString(self.max) + diff --git a/contrib/src/sceneeditor/seSession.py b/contrib/src/sceneeditor/seSession.py index 95f235829b..c8e7a1a20f 100644 --- a/contrib/src/sceneeditor/seSession.py +++ b/contrib/src/sceneeditor/seSession.py @@ -388,7 +388,7 @@ class SeSession(DirectObject): ### Customized DirectSession messenger.send('DIRECT_preSelectNodePath', [dnp]) if fResetAncestry: # Update ancestry - self.ancestry = dnp.getAncestors() + self.ancestry = list(dnp.getAncestors()) self.ancestry.reverse() self.ancestryIndex = 0 # Update the selectedNPReadout @@ -479,8 +479,8 @@ class SeSession(DirectObject): ### Customized DirectSession def isNotCycle(self, nodePath, parent): - if nodePath.id() == parent.id(): - print 'DIRECT.reparent: Invalid parent' + if nodePath.get_key() == parent.get_key(): + print('DIRECT.reparent: Invalid parent') return 0 elif parent.hasParent(): return self.isNotCycle(nodePath, parent.getParent()) @@ -520,7 +520,10 @@ class SeSession(DirectObject): ### Customized DirectSession nodePath = self.selected.last if nodePath: # Now toggle node path's visibility state - nodePath.toggleVis() + if nodePath.is_hidden(): + nodePath.show() + else: + nodePath.hide() def removeNodePath(self, nodePath = 'None Given'): if nodePath == 'None Given': @@ -732,8 +735,8 @@ class SeSession(DirectObject): ### Customized DirectSession hprB = base.camera.getHpr() posE = Point3((radius*-1.41)+center.getX(), (radius*-1.41)+center.getY(), (radius*1.41)+center.getZ()) hprE = Point3(-45, -38, 0) - print posB, hprB - print posE, hprE + print(posB, hprB) + print(posE, hprE) posInterval1 = base.camera.posInterval(time, posE, bakeInStart = 1) posInterval2 = base.camera.posInterval(time, posB, bakeInStart = 1) diff --git a/contrib/src/sceneeditor/seTree.py b/contrib/src/sceneeditor/seTree.py index 018d6af410..9927c11112 100644 --- a/contrib/src/sceneeditor/seTree.py +++ b/contrib/src/sceneeditor/seTree.py @@ -12,15 +12,21 @@ # ################################################################# -import os, sys, string, Pmw, Tkinter +import os, sys, string, Pmw from direct.showbase.DirectObject import DirectObject -from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry -from pandac.PandaModules import * +from panda3d.core import * + +if sys.version_info >= (3, 0): + import tkinter + from tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry +else: + import Tkinter as tkinter + from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry # Initialize icon directory ICONDIR = getModelPath().findFile(Filename('icons')).toOsSpecific() if not os.path.isdir(ICONDIR): - raise RuntimeError, "can't find DIRECT icon directory (%s)" % `ICONDIR` + raise RuntimeError("can't find DIRECT icon directory (%r)" % ICONDIR) class TreeNode: @@ -187,9 +193,9 @@ class TreeNode: oldcursor = self.canvas['cursor'] self.canvas['cursor'] = "watch" self.canvas.update() - self.canvas.delete(Tkinter.ALL) # XXX could be more subtle + self.canvas.delete(tkinter.ALL) # XXX could be more subtle self.draw(7, 2) - x0, y0, x1, y1 = self.canvas.bbox(Tkinter.ALL) + x0, y0, x1, y1 = self.canvas.bbox(tkinter.ALL) self.canvas.configure(scrollregion=(0, 0, x1, y1)) self.canvas['cursor'] = oldcursor @@ -208,7 +214,7 @@ class TreeNode: self.kidKeys = [] for item in sublist: key = item.GetKey() - if self.children.has_key(key): + if key in self.children: child = self.children[key] else: child = TreeNode(self.canvas, self, item, self.menuList) @@ -309,7 +315,7 @@ class TreeNode: def edit(self, event=None): self.entry = Entry(self.label, bd=0, highlightthickness=1, width=0) self.entry.insert(0, self.label['text']) - self.entry.selection_range(0, Tkinter.END) + self.entry.selection_range(0, tkinter.END) self.entry.pack(ipadx=5) self.entry.focus_set() self.entry.bind("", self.edit_finish) @@ -344,7 +350,7 @@ class TreeNode: for item in sublist: key = item.GetKey() # Use existing child or create new TreeNode if none exists - if self.children.has_key(key): + if key in self.children: child = self.children[key] else: child = TreeNode(self.canvas, self, item, self.menuList) diff --git a/direct/src/dcparse/dcparse.cxx b/direct/src/dcparse/dcparse.cxx index 9fbd4ef063..b12323bb4a 100644 --- a/direct/src/dcparse/dcparse.cxx +++ b/direct/src/dcparse/dcparse.cxx @@ -19,6 +19,9 @@ #include "indent.h" #include "panda_getopt.h" +using std::cerr; +using std::cout; + void usage() { cerr << diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index b8101128bd..2f2ea69932 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -16,6 +16,8 @@ #include "dcClassParameter.h" #include "hashGenerator.h" +using std::string; + /** * */ @@ -201,13 +203,13 @@ validate_num_nested_fields(int num_nested_fields) const { * identifier. */ void DCArrayParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { - ostringstream strm; + std::ostringstream strm; strm << "["; _array_size_range.output(strm); diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index c3f0dc365b..3efebfa2d6 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -19,6 +19,8 @@ #include +using std::string; + /** * */ @@ -151,7 +153,7 @@ get_element_divisor(int n) const { * */ void DCAtomicField:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << _name << "("; if (!_elements.empty()) { @@ -174,7 +176,7 @@ output(ostream &out, bool brief) const { * stream. */ void DCAtomicField:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level); output(out, brief); out << ";"; @@ -270,7 +272,7 @@ do_check_match_atomic_field(const DCAtomicField *other) const { * */ void DCAtomicField:: -output_element(ostream &out, bool brief, DCParameter *element) const { +output_element(std::ostream &out, bool brief, DCParameter *element) const { element->output(out, brief); if (!brief && element->has_default_value()) { diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 3d311e6506..4c428db595 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -25,6 +25,10 @@ #include "py_panda.h" #endif +using std::ostream; +using std::ostringstream; +using std::string; + #ifdef WITHIN_PANDA #include "pStatTimer.h" @@ -177,9 +181,9 @@ DCField *DCClass:: get_field(int n) const { #ifndef NDEBUG //[ if (n < 0 || n >= (int)_fields.size()) { - cerr << *this << " " + std::cerr << *this << " " << "n:" << n << " _fields.size():" - << (int)_fields.size() << endl; + << (int)_fields.size() << std::endl; // __asm { int 3 } } #endif //] @@ -749,7 +753,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, if (result == nullptr) { // We don't set this as an exception, since presumably the Python method // itself has already triggered a Python exception. - cerr << "Error when calling " << getter_name << "\n"; + std::cerr << "Error when calling " << getter_name << "\n"; return false; } diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index 379dbb5961..a3bc68d5eb 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -128,8 +128,8 @@ get_nested_field(int n) const { * identifier. */ void DCClassParameter:: -output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const { +output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); diff --git a/direct/src/dcparser/dcDeclaration.cxx b/direct/src/dcparser/dcDeclaration.cxx index 7da467a44a..bf8830f046 100644 --- a/direct/src/dcparser/dcDeclaration.cxx +++ b/direct/src/dcparser/dcDeclaration.cxx @@ -57,7 +57,7 @@ as_switch() const { * Write a string representation of this instance to . */ void DCDeclaration:: -output(ostream &out) const { +output(std::ostream &out) const { output(out, true); } @@ -65,6 +65,6 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DCDeclaration:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write(out, false, indent_level); } diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index eeace485c6..4f255dea7d 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -26,6 +26,8 @@ #include "pStatTimer.h" #endif +using std::string; + /** * */ @@ -232,7 +234,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { } if (!Notify::ptr()->has_assert_failed()) { - ostringstream strm; + std::ostringstream strm; PyObject *exc_type = PyExc_Exception; if (as_parameter() != nullptr) { @@ -303,7 +305,7 @@ unpack_args(DCPacker &packer) const { } if (!Notify::ptr()->has_assert_failed()) { - ostringstream strm; + std::ostringstream strm; PyObject *exc_type = PyExc_Exception; if (packer.had_pack_error()) { @@ -315,7 +317,7 @@ unpack_args(DCPacker &packer) const { dg.dump_hex(strm); size_t error_byte = packer.get_num_unpacked_bytes() - start_byte; strm << "Error detected on byte " << error_byte - << " (" << hex << error_byte << dec << " hex)"; + << " (" << std::hex << error_byte << std::dec << " hex)"; exc_type = PyExc_RuntimeError; } else { @@ -562,7 +564,7 @@ refresh_default_value() { packer.begin_pack(this); packer.pack_default_value(); if (!packer.end_pack()) { - cerr << "Error while packing default value for " << get_name() << "\n"; + std::cerr << "Error while packing default value for " << get_name() << "\n"; } else { _default_value.assign(packer.get_data(), packer.get_length()); } diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 43301e4615..be69b4b18c 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -28,6 +28,9 @@ #include "configVariableList.h" #endif +using std::cerr; +using std::string; + /** * @@ -122,7 +125,7 @@ read(Filename filename) { #ifdef WITHIN_PANDA filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { cerr << "Cannot open " << filename << " for reading.\n"; return false; @@ -163,7 +166,7 @@ read(Filename filename) { * (in which case the file might have been partially read). */ bool DCFile:: -read(istream &in, const string &filename) { +read(std::istream &in, const string &filename) { cerr << "DCFile::read of " << filename << "\n"; dc_init_parser(in, filename, *this); dcyyparse(); @@ -203,7 +206,7 @@ write(Filename filename, bool brief) const { * Returns true if the description is successfully written, false otherwise. */ bool DCFile:: -write(ostream &out, bool brief) const { +write(std::ostream &out, bool brief) const { if (!_imports.empty()) { Imports::const_iterator ii; for (ii = _imports.begin(); ii != _imports.end(); ++ii) { diff --git a/direct/src/dcparser/dcKeyword.cxx b/direct/src/dcparser/dcKeyword.cxx index 17dcab8df2..ef9c497b7d 100644 --- a/direct/src/dcparser/dcKeyword.cxx +++ b/direct/src/dcparser/dcKeyword.cxx @@ -19,7 +19,7 @@ * */ DCKeyword:: -DCKeyword(const string &name, int historical_flag) : +DCKeyword(const std::string &name, int historical_flag) : _name(name), _historical_flag(historical_flag) { @@ -35,7 +35,7 @@ DCKeyword:: /** * Returns the name of this keyword. */ -const string &DCKeyword:: +const std::string &DCKeyword:: get_name() const { return _name; } @@ -64,7 +64,7 @@ clear_historical_flag() { * Write a string representation of this instance to . */ void DCKeyword:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << "keyword " << _name; } @@ -72,7 +72,7 @@ output(ostream &out, bool brief) const { * */ void DCKeyword:: -write(ostream &out, bool, int indent_level) const { +write(std::ostream &out, bool, int indent_level) const { indent(out, indent_level) << "keyword " << _name << ";\n"; } diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx index c2cba110b6..cdfdd4f7f5 100644 --- a/direct/src/dcparser/dcKeywordList.cxx +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -57,7 +57,7 @@ DCKeywordList:: * Returns true if this list includes the indicated keyword, false otherwise. */ bool DCKeywordList:: -has_keyword(const string &name) const { +has_keyword(const std::string &name) const { return (_keywords_by_name.find(name) != _keywords_by_name.end()); } @@ -92,7 +92,7 @@ get_keyword(int n) const { * is no keyword in the list with that name. */ const DCKeyword *DCKeywordList:: -get_keyword_by_name(const string &name) const { +get_keyword_by_name(const std::string &name) const { KeywordsByName::const_iterator ni; ni = _keywords_by_name.find(name); if (ni != _keywords_by_name.end()) { @@ -148,7 +148,7 @@ clear_keywords() { * */ void DCKeywordList:: -output_keywords(ostream &out) const { +output_keywords(std::ostream &out) const { Keywords::const_iterator ki; for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) { out << " " << (*ki)->get_name(); diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index f99b920f81..660f96b5cb 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -610,11 +610,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. -static string dc_filename; +static std::string dc_filename; // This is the initial token state returned by the lexer. It allows // the yacc grammar to start from initial points. @@ -626,7 +626,7 @@ static int initial_token; //////////////////////////////////////////////////////////////////// void -dc_init_lexer(istream &in, const string &filename) { +dc_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ dc_filename = filename; line_number = 0; @@ -671,7 +671,9 @@ dcyywrap(void) { } void -dcyyerror(const string &msg) { +dcyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -686,7 +688,9 @@ dcyyerror(const string &msg) { } void -dcyywarning(const string &msg) { +dcyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -740,7 +744,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -762,9 +766,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -884,9 +888,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static string +static std::string scan_hex_string() { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -916,7 +920,7 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return string(); + return std::string(); } odd = !odd; @@ -930,10 +934,10 @@ scan_hex_string() { if (c == EOF) { dcyyerror("This hex string is unterminated."); - return string(); + return std::string(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return string(); + return std::string(); } line_number = line; diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index b2d83dad47..3c20a69b5f 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -35,11 +35,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. -static string dc_filename; +static std::string dc_filename; // This is the initial token state returned by the lexer. It allows // the yacc grammar to start from initial points. @@ -51,7 +51,7 @@ static int initial_token; //////////////////////////////////////////////////////////////////// void -dc_init_lexer(istream &in, const string &filename) { +dc_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ dc_filename = filename; line_number = 0; @@ -96,7 +96,9 @@ dcyywrap(void) { } void -dcyyerror(const string &msg) { +dcyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -111,7 +113,9 @@ dcyyerror(const string &msg) { } void -dcyywarning(const string &msg) { +dcyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -165,7 +169,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -187,9 +191,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -309,9 +313,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static string +static std::string scan_hex_string() { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -341,7 +345,7 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return string(); + return std::string(); } odd = !odd; @@ -355,10 +359,10 @@ scan_hex_string() { if (c == EOF) { dcyyerror("This hex string is unterminated."); - return string(); + return std::string(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return string(); + return std::string(); } line_number = line; diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index 178c86ad2e..b5e18094a9 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -22,7 +22,7 @@ * */ DCMolecularField:: -DCMolecularField(const string &name, DCClass *dclass) : DCField(name, dclass) { +DCMolecularField(const std::string &name, DCClass *dclass) : DCField(name, dclass) { _got_keywords = false; } @@ -109,7 +109,7 @@ add_atomic(DCAtomicField *atomic) { * */ void DCMolecularField:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << _name; if (!_fields.empty()) { @@ -130,7 +130,7 @@ output(ostream &out, bool brief) const { * stream. */ void DCMolecularField:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level); output(out, brief); if (!brief) { diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 119add847e..ebab348f6f 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -23,6 +23,12 @@ #include "py_panda.h" #endif +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr; int DCPacker::StackElement::_num_ever_allocated = 0; @@ -786,7 +792,7 @@ pack_object(PyObject *object) { pack_object(element); Py_DECREF(element); } else { - cerr << "Unable to extract item " << i << " from sequence.\n"; + std::cerr << "Unable to extract item " << i << " from sequence.\n"; } } pop(); @@ -903,7 +909,7 @@ unpack_object() { // constructor, create the class object instead of just a tuple. object = unpack_class_object(dclass); if (object == nullptr) { - cerr << "Unable to construct object of class " + std::cerr << "Unable to construct object of class " << dclass->get_name() << "\n"; } else { break; diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index 0eda4197b6..594c7b6742 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -16,6 +16,8 @@ #include "dcPacker.h" #include "dcSwitchParameter.h" +using std::string; + /** * The catalog is created only by DCPackerInterface::get_catalog(). */ diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index dd6e4ae482..d17ff1f7b7 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -17,6 +17,8 @@ #include "dcParserDefs.h" #include "dcLexerDefs.h" +using std::string; + /** * */ @@ -139,7 +141,7 @@ bool DCPackerInterface:: check_match(const string &description, DCFile *dcfile) const { bool match = false; - istringstream strm(description); + std::istringstream strm(description); dc_init_parser_parameter_description(strm, "check_match", dcfile); dcyyparse(); dc_cleanup_parser(); diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index ef1c50997f..61b13ff04a 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -17,6 +17,9 @@ #include "dcindent.h" #include "dcTypedef.h" +using std::ostream; +using std::string; + /** * */ diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index a7f911e452..80df4b2b09 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -101,6 +101,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + DCFile *dc_file = (DCFile *)NULL; static DCClass *current_class = (DCClass *)NULL; static DCSwitch *current_switch = (DCSwitch *)NULL; diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 8b9c7e40ad..0a5c3d6aa0 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -29,6 +29,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + DCFile *dc_file = nullptr; static DCClass *current_class = nullptr; static DCSwitch *current_switch = nullptr; diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index 34f4e7e402..bd2cb05534 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -20,6 +20,8 @@ #include "hashGenerator.h" #include +using std::string; + DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr; @@ -2171,7 +2173,7 @@ unpack_skip(const char *data, size_t length, size_t &p, * identifier. */ void DCSimpleParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); diff --git a/direct/src/dcparser/dcSubatomicType.cxx b/direct/src/dcparser/dcSubatomicType.cxx index 1489fe3a3f..841edf7155 100644 --- a/direct/src/dcparser/dcSubatomicType.cxx +++ b/direct/src/dcparser/dcSubatomicType.cxx @@ -13,8 +13,8 @@ #include "dcSubatomicType.h" -ostream & -operator << (ostream &out, DCSubatomicType type) { +std::ostream & +operator << (std::ostream &out, DCSubatomicType type) { switch (type) { case ST_int8: return out << "int8"; diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index ee3c70f7c5..5b23505209 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -18,6 +18,9 @@ #include "dcindent.h" #include "dcPacker.h" +using std::ostream; +using std::string; + /** * The key_parameter must be recently allocated via new; it will be deleted * via delete when the switch destructs. diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index 8f3b7ccf00..d4f2c10394 100644 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -15,6 +15,8 @@ #include "dcSwitch.h" #include "hashGenerator.h" +using std::string; + /** * */ @@ -153,7 +155,7 @@ apply_switch(const char *value_data, size_t length) const { * identifier. */ void DCSwitchParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); @@ -168,7 +170,7 @@ output_instance(ostream &out, bool brief, const string &prename, * identifier. */ void DCSwitchParameter:: -write_instance(ostream &out, bool brief, int indent_level, +write_instance(std::ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { diff --git a/direct/src/dcparser/dcTypedef.cxx b/direct/src/dcparser/dcTypedef.cxx index cc45f74d49..a83f68e895 100644 --- a/direct/src/dcparser/dcTypedef.cxx +++ b/direct/src/dcparser/dcTypedef.cxx @@ -16,6 +16,8 @@ #include "dcSimpleParameter.h" #include "dcindent.h" +using std::string; + /** * The DCTypedef object becomes the owner of the supplied parameter pointer * and will delete it upon destruction. @@ -72,7 +74,7 @@ get_name() const { */ string DCTypedef:: get_description() const { - ostringstream strm; + std::ostringstream strm; _parameter->output(strm, true); return strm.str(); } @@ -122,7 +124,7 @@ set_number(int number) { * Write a string representation of this instance to . */ void DCTypedef:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << "typedef "; _parameter->output(out, false); } @@ -131,7 +133,7 @@ output(ostream &out, bool brief) const { * */ void DCTypedef:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level) << "typedef "; diff --git a/direct/src/dcparser/dcindent.cxx b/direct/src/dcparser/dcindent.cxx index ae466667ac..b7b9f20793 100644 --- a/direct/src/dcparser/dcindent.cxx +++ b/direct/src/dcparser/dcindent.cxx @@ -18,8 +18,8 @@ /** * */ -ostream & -indent(ostream &out, int indent_level) { +std::ostream & +indent(std::ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { out << ' '; } diff --git a/direct/src/dcparser/hashGenerator.cxx b/direct/src/dcparser/hashGenerator.cxx index b5a092f95c..900fd4bf42 100644 --- a/direct/src/dcparser/hashGenerator.cxx +++ b/direct/src/dcparser/hashGenerator.cxx @@ -48,9 +48,9 @@ add_int(int num) { * Adds a string to the hash, by breaking it down into a sequence of integers. */ void HashGenerator:: -add_string(const string &str) { +add_string(const std::string &str) { add_int(str.length()); - string::const_iterator si; + std::string::const_iterator si; for (si = str.begin(); si != str.end(); ++si) { add_int(*si); } diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index 727f10f9b3..d15ad745c6 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -95,7 +95,7 @@ mark_position() { LVector3 pos_delta = _sample._pos - _smooth_pos; LVecBase3 hpr_delta = _sample._hpr - _smooth_hpr; double age = timestamp - _smooth_timestamp; - age = min(age, _max_position_age); + age = std::min(age, _max_position_age); set_smooth_pos(_sample._pos, _sample._hpr, timestamp); if (age != 0.0) { @@ -272,13 +272,13 @@ compute_smooth_position(double timestamp) { // Find the newest of the points before the indicated time. Assume that // this will be no older than _last_point_before. - i = max(0, _last_point_before); + i = std::max(0, _last_point_before); while (i < num_points && _points[i]._timestamp < timestamp) { point_before = i; timestamp_before = _points[i]._timestamp; ++i; } - point_way_before = max(point_before - 1, -1); + point_way_before = std::max(point_before - 1, -1); // Now the next point is presumably the oldest point after the indicated // time. @@ -527,7 +527,7 @@ get_latest_position() { * */ void SmoothMover:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points."; } @@ -535,7 +535,7 @@ output(ostream &out) const { * */ void SmoothMover:: -write(ostream &out) const { +write(std::ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points:\n"; int num_points = _points.size(); for (int i = 0; i < num_points; i++) { diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 027236579d..817706acb5 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -34,6 +34,11 @@ #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined #endif +using std::cerr; +using std::cout; +using std::endl; +using std::string; + namespace { // ...This section is part of the old stuff from the original // implementation. The new stuff that uses job objects doesn't need this @@ -148,7 +153,7 @@ DirectD::~DirectD() { int DirectD::client_ready(const string& server_host, int port, const string& cmd) { - stringstream ss; + std::stringstream ss; ss<<"!"<= 0x03030000 PyObject *exc_type = PyExc_ConnectionError; @@ -884,7 +887,7 @@ handle_update_field_owner() { * description on the indicated output stream. */ void CConnectionRepository:: -describe_message(ostream &out, const string &prefix, +describe_message(std::ostream &out, const string &prefix, const Datagram &dg) const { DCPacker packer; diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 37c69daaca..67e273644f 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -268,7 +268,7 @@ broadcast_pos_hpr_xy() { * indicated field name, up until the arguments. */ void CDistributedSmoothNodeBase:: -begin_send_update(DCPacker &packer, const string &field_name) { +begin_send_update(DCPacker &packer, const std::string &field_name) { DCField *field = _dclass->get_field_by_name(field_name); nassertv(field != nullptr); @@ -325,14 +325,14 @@ finish_send_update(DCPacker &packer) { } else { #ifndef NDEBUG if (packer.had_range_error()) { - ostringstream error; + std::ostringstream error; error << "Node position out of range for DC file: " << _node_path << " pos = " << _store_xyz << " hpr = " << _store_hpr << " zoneId = " << _currL[0]; #ifdef HAVE_PYTHON - string message = error.str(); + std::string message = error.str(); distributed_cat.warning() << message << "\n"; PyErr_SetString(PyExc_ValueError, message.c_str()); @@ -364,5 +364,5 @@ set_curr_l(uint64_t l) { void CDistributedSmoothNodeBase:: print_curr_l() { - cout << "printCurrL: sent l: " << _currL[1] << " last set l: " << _currL[0] << "\n"; + std::cout << "printCurrL: sent l: " << _currL[1] << " last set l: " << _currL[0] << "\n"; } diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index 259d7f66a3..4f31c9839d 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -573,7 +573,23 @@ class MetaInterval(CMetaInterval): out = ostream CMetaInterval.timeline(self, out) - + add_sequence = addSequence + add_parallel = addParallel + add_parallel_end_together = addParallelEndTogether + add_track = addTrack + add_interval = addInterval + set_manager = setManager + get_manager = getManager + set_t = setT + resume_until = resumeUntil + clear_to_initial = clearToInitial + clear_intervals = clearIntervals + set_play_rate = setPlayRate + priv_do_event = privDoEvent + priv_post_event = privPostEvent + set_interval_start_time = setIntervalStartTime + get_interval_start_time = getIntervalStartTime + get_duration = getDuration class Sequence(MetaInterval): diff --git a/direct/src/interval/cConstrainHprInterval.cxx b/direct/src/interval/cConstrainHprInterval.cxx index bfd6f6d86d..0cd3e26a35 100644 --- a/direct/src/interval/cConstrainHprInterval.cxx +++ b/direct/src/interval/cConstrainHprInterval.cxx @@ -26,7 +26,7 @@ TypeHandle CConstrainHprInterval::_type_handle; * node's local orientation will be copied unaltered. */ CConstrainHprInterval:: -CConstrainHprInterval(const string &name, double duration, +CConstrainHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 hprOffset) : CConstraintInterval(name, duration), @@ -69,7 +69,7 @@ priv_step(double t) { * */ void CConstrainHprInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainPosHprInterval.cxx b/direct/src/interval/cConstrainPosHprInterval.cxx index 7b0944c3e4..4e30d9f56e 100644 --- a/direct/src/interval/cConstrainPosHprInterval.cxx +++ b/direct/src/interval/cConstrainPosHprInterval.cxx @@ -27,7 +27,7 @@ TypeHandle CConstrainPosHprInterval::_type_handle; * unaltered. */ CConstrainPosHprInterval:: -CConstrainPosHprInterval(const string &name, double duration, +CConstrainPosHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset, const LVecBase3 hprOffset) : @@ -72,7 +72,7 @@ priv_step(double t) { * */ void CConstrainPosHprInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainPosInterval.cxx b/direct/src/interval/cConstrainPosInterval.cxx index fe8f235654..1cc967617c 100644 --- a/direct/src/interval/cConstrainPosInterval.cxx +++ b/direct/src/interval/cConstrainPosInterval.cxx @@ -26,7 +26,7 @@ TypeHandle CConstrainPosInterval::_type_handle; * node's local position will be copied unaltered. */ CConstrainPosInterval:: -CConstrainPosInterval(const string &name, double duration, +CConstrainPosInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset) : CConstraintInterval(name, duration), @@ -73,7 +73,7 @@ priv_step(double t) { * */ void CConstrainPosInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainTransformInterval.cxx b/direct/src/interval/cConstrainTransformInterval.cxx index f816f3bbc1..a21c109bde 100644 --- a/direct/src/interval/cConstrainTransformInterval.cxx +++ b/direct/src/interval/cConstrainTransformInterval.cxx @@ -27,7 +27,7 @@ TypeHandle CConstrainTransformInterval::_type_handle; * local transform will be copied unaltered. */ CConstrainTransformInterval:: -CConstrainTransformInterval(const string &name, double duration, +CConstrainTransformInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt) : CConstraintInterval(name, duration), @@ -72,7 +72,7 @@ priv_step(double t) { * */ void CConstrainTransformInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstraintInterval.cxx b/direct/src/interval/cConstraintInterval.cxx index 708caed9fa..71ac457cb4 100644 --- a/direct/src/interval/cConstraintInterval.cxx +++ b/direct/src/interval/cConstraintInterval.cxx @@ -19,7 +19,7 @@ TypeHandle CConstraintInterval::_type_handle; * */ CConstraintInterval:: -CConstraintInterval(const string &name, double duration) : +CConstraintInterval(const std::string &name, double duration) : CInterval(name, duration, true) { } diff --git a/direct/src/interval/cInterval.cxx b/direct/src/interval/cInterval.cxx index 84325720ab..0e7dba1554 100644 --- a/direct/src/interval/cInterval.cxx +++ b/direct/src/interval/cInterval.cxx @@ -19,6 +19,9 @@ #include "eventQueue.h" #include "pStatTimer.h" +using std::ostream; +using std::string; + PStatCollector CInterval::_root_pcollector("App:Show code:ivalLoop"); TypeHandle CInterval::_type_handle; @@ -41,7 +44,7 @@ CInterval(const string &name, double duration, bool open_ended) : _curr_t(0.0), _name(name), _pname(get_pstats_name(name)), - _duration(max(duration, 0.0)), + _duration(std::max(duration, 0.0)), _open_ended(open_ended), _dirty(false), _ival_pcollector(_root_pcollector, _pname) diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index 104c9e0953..137f30c0ff 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -108,7 +108,7 @@ add_c_interval(CInterval *interval, bool external) { * interval, or -1 if there is not. */ int CIntervalManager:: -find_c_interval(const string &name) const { +find_c_interval(const std::string &name) const { MutexHolder holder(_lock); NameIndex::const_iterator ni = _name_index.find(name); @@ -351,7 +351,7 @@ get_next_removal() { * */ void CIntervalManager:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "CIntervalManager, " << (int)_name_index.size() << " intervals."; @@ -361,7 +361,7 @@ output(ostream &out) const { * */ void CIntervalManager:: -write(ostream &out) const { +write(std::ostream &out) const { MutexHolder holder(_lock); // We need to write this line so that it's clear what's going on when there diff --git a/direct/src/interval/cLerpAnimEffectInterval.cxx b/direct/src/interval/cLerpAnimEffectInterval.cxx index d91bf8612e..4f7986a7c4 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.cxx +++ b/direct/src/interval/cLerpAnimEffectInterval.cxx @@ -43,7 +43,7 @@ priv_step(double t) { * */ void CLerpAnimEffectInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ": "; if (_controls.empty()) { diff --git a/direct/src/interval/cLerpInterval.cxx b/direct/src/interval/cLerpInterval.cxx index b1eec3a135..43a291f94e 100644 --- a/direct/src/interval/cLerpInterval.cxx +++ b/direct/src/interval/cLerpInterval.cxx @@ -21,7 +21,7 @@ TypeHandle CLerpInterval::_type_handle; * string, or BT_invalid if the string doesn't match anything. */ CLerpInterval::BlendType CLerpInterval:: -string_blend_type(const string &blend_type) { +string_blend_type(const std::string &blend_type) { if (blend_type == "easeIn") { return BT_ease_in; } else if (blend_type == "easeOut") { @@ -49,7 +49,7 @@ compute_delta(double t) const { return 1.0; } t /= duration; - t = min(max(t, 0.0), 1.0); + t = std::min(std::max(t, 0.0), 1.0); switch (_blend_type) { case BT_ease_in: diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 12286ce3d8..2fbc8a7e75 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -47,7 +47,7 @@ TypeHandle CLerpNodePathInterval::_type_handle; * otherwise, it is reset. */ CLerpNodePathInterval:: -CLerpNodePathInterval(const string &name, double duration, +CLerpNodePathInterval(const std::string &name, double duration, CLerpInterval::BlendType blend_type, bool bake_in_start, bool fluid, const NodePath &node, const NodePath &other) : @@ -544,7 +544,7 @@ priv_reverse_instant() { * */ void CLerpNodePathInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; if ((_flags & F_end_pos) != 0) { diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index 2b764187bc..08f8887706 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -21,6 +21,8 @@ #include // for log10() #include // for sprintf() +using std::string; + TypeHandle CMetaInterval::_type_handle; /** @@ -669,7 +671,7 @@ pop_event() { * */ void CMetaInterval:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { recompute(); // How many digits of precision should we output for time? @@ -677,7 +679,7 @@ write(ostream &out, int indent_level) const { int total_digits = num_decimals + 4; static const int max_digits = 32; // totally arbitrary nassertv(total_digits <= max_digits); - char format_str[12]; + char format_str[16]; sprintf(format_str, "%%%d.%df", total_digits, num_decimals); indent(out, indent_level) << get_name() << ":\n"; @@ -698,7 +700,7 @@ write(ostream &out, int indent_level) const { * Outputs a list of all events in the order in which they occur. */ void CMetaInterval:: -timeline(ostream &out) const { +timeline(std::ostream &out) const { recompute(); // How many digits of precision should we output for time? @@ -706,7 +708,7 @@ timeline(ostream &out) const { int total_digits = num_decimals + 4; static const int max_digits = 32; // totally arbitrary nassertv(total_digits <= max_digits); - char format_str[12]; + char format_str[16]; sprintf(format_str, "%%%d.%df", total_digits, num_decimals); int extra_indent_level = 0; @@ -1124,7 +1126,7 @@ recompute_level(int n, int level_begin, int &level_end) { previous_begin = begin_time; previous_end = end_time; - level_end = max(level_end, end_time); + level_end = std::max(level_end, end_time); n++; } @@ -1169,7 +1171,7 @@ get_begin_time(const CMetaInterval::IntervalDef &def, int level_begin, * Formats an event for output, for write() or timeline(). */ void CMetaInterval:: -write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, +write_event_desc(std::ostream &out, const CMetaInterval::IntervalDef &def, int &extra_indent_level) const { switch (def._type) { case DT_c_interval: diff --git a/direct/src/interval/hideInterval.cxx b/direct/src/interval/hideInterval.cxx index ed335dc307..46498800e0 100644 --- a/direct/src/interval/hideInterval.cxx +++ b/direct/src/interval/hideInterval.cxx @@ -20,13 +20,13 @@ TypeHandle HideInterval::_type_handle; * */ HideInterval:: -HideInterval(const NodePath &node, const string &name) : +HideInterval(const NodePath &node, const std::string &name) : CInterval(name, 0.0, true), _node(node) { nassertv(!node.is_empty()); if (_name.empty()) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "HideInterval-" << node.node()->get_name() << "-" << ++_unique_index; _name = name_strm.str(); diff --git a/direct/src/interval/showInterval.cxx b/direct/src/interval/showInterval.cxx index 53bc7d2346..b014100f2f 100644 --- a/direct/src/interval/showInterval.cxx +++ b/direct/src/interval/showInterval.cxx @@ -20,13 +20,13 @@ TypeHandle ShowInterval::_type_handle; * */ ShowInterval:: -ShowInterval(const NodePath &node, const string &name) : +ShowInterval(const NodePath &node, const std::string &name) : CInterval(name, 0.0, true), _node(node) { nassertv(!node.is_empty()); if (_name.empty()) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "ShowInterval-" << node.node()->get_name() << "-" << ++_unique_index; _name = name_strm.str(); diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index 4840a2c1e2..7dc4a60268 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -15,6 +15,11 @@ #include "p3d_lock.h" #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + static const bool debug_xml_output = false; static LOCK xml_lock; diff --git a/direct/src/plugin/binaryXml.h b/direct/src/plugin/binaryXml.h index 664c7fb5e6..477c51e83f 100644 --- a/direct/src/plugin/binaryXml.h +++ b/direct/src/plugin/binaryXml.h @@ -18,8 +18,6 @@ #include "handleStream.h" #include -using namespace std; - // A pair of functions to input and output the TinyXml constructs on the // indicated streams. We could, of course, use the TinyXml output operators, // but this is a smidge more efficient and gives us more control. diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index 29f22e9899..c291bfc14a 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -33,6 +33,11 @@ #endif +using std::istream; +using std::ostream; +using std::string; +using std::wstring; + /** * */ @@ -325,10 +330,10 @@ read_hash(const string &pathname) { #ifdef _WIN32 wstring pathname_w; if (string_to_wstring(pathname_w, pathname)) { - stream.open(pathname_w.c_str(), ios::in | ios::binary); + stream.open(pathname_w.c_str(), std::ios::in | std::ios::binary); } #else // _WIN32 - stream.open(pathname.c_str(), ios::in | ios::binary); + stream.open(pathname.c_str(), std::ios::in | std::ios::binary); #endif // _WIN32 if (!stream) { diff --git a/direct/src/plugin/fileSpec.h b/direct/src/plugin/fileSpec.h index e393b680fa..3a661ab603 100644 --- a/direct/src/plugin/fileSpec.h +++ b/direct/src/plugin/fileSpec.h @@ -16,7 +16,6 @@ #include "get_tinyxml.h" #include -using namespace std; /** * This simple class is used both within the core API in this module, as well diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index d15362bfd0..7d20461aa9 100644 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -27,6 +27,10 @@ #include #endif +using std::cerr; +using std::string; +using std::wstring; + #ifdef _WIN32 // From KnownFolders.h (part of Vista SDK): #define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ diff --git a/direct/src/plugin/find_root_dir.h b/direct/src/plugin/find_root_dir.h index 977a64cc37..e76be59af3 100644 --- a/direct/src/plugin/find_root_dir.h +++ b/direct/src/plugin/find_root_dir.h @@ -16,7 +16,6 @@ #include #include -using namespace std; std::string find_root_dir(); diff --git a/direct/src/plugin/find_root_dir_assist.mm b/direct/src/plugin/find_root_dir_assist.mm index e4eed157a6..f27693d147 100644 --- a/direct/src/plugin/find_root_dir_assist.mm +++ b/direct/src/plugin/find_root_dir_assist.mm @@ -70,7 +70,7 @@ get_osx_home_directory() { /** * */ -string +std::string find_osx_root_dir() { string result = call_NSSearchPathForDirectories(NSCachesDirectory, NSUserDomainMask); if (!result.empty()) { diff --git a/direct/src/plugin/handleStreamBuf.cxx b/direct/src/plugin/handleStreamBuf.cxx index c2adbd2f62..55e74977b5 100644 --- a/direct/src/plugin/handleStreamBuf.cxx +++ b/direct/src/plugin/handleStreamBuf.cxx @@ -28,6 +28,10 @@ #include #endif // !_WIN32 && !__APPLE__ && !__FreeBSD__ +using std::cerr; +using std::dec; +using std::hex; + static const size_t handle_buffer_size = 4096; /** diff --git a/direct/src/plugin/handleStreamBuf.h b/direct/src/plugin/handleStreamBuf.h index 19610a0c45..da3448d4d3 100644 --- a/direct/src/plugin/handleStreamBuf.h +++ b/direct/src/plugin/handleStreamBuf.h @@ -18,8 +18,6 @@ #include "p3d_lock.h" #include -using namespace std; - /** * */ diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index f46cb7355d..75def4fc10 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -24,6 +24,8 @@ #include #endif +using std::string; + #ifdef _WIN32 static const string dll_ext = ".dll"; #elif defined(__APPLE__) @@ -132,7 +134,7 @@ load_plugin(const string &p3d_plugin_filename, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile) { + const string &start_dir, std::ostream &logfile) { if (plugin_loaded) { return true; } @@ -161,7 +163,7 @@ load_plugin(const string &p3d_plugin_filename, } SetErrorMode(0); - wstring filename_w; + std::wstring filename_w; if (string_to_wstring(filename_w, filename)) { module = LoadLibraryW(filename_w.c_str()); } @@ -273,7 +275,7 @@ init_plugin(const string &contents_filename, const string &host_url, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile) { + const string &start_dir, std::ostream &logfile) { // Ensure that all of the function pointers have been found. if (P3D_initialize_ptr == nullptr || @@ -392,7 +394,7 @@ init_plugin(const string &contents_filename, const string &host_url, * the pointers. */ void -unload_plugin(ostream &logfile) { +unload_plugin(std::ostream &logfile) { if (!plugin_loaded) { return; } diff --git a/direct/src/plugin/load_plugin.h b/direct/src/plugin/load_plugin.h index 58f160ef7d..2e462ed9cd 100644 --- a/direct/src/plugin/load_plugin.h +++ b/direct/src/plugin/load_plugin.h @@ -17,7 +17,6 @@ #include "p3d_plugin.h" #include -using namespace std; extern P3D_initialize_func *P3D_initialize_ptr; extern P3D_finalize_func *P3D_finalize_ptr; diff --git a/direct/src/plugin/mkdir_complete.cxx b/direct/src/plugin/mkdir_complete.cxx index 8b721f1fa8..6689584198 100644 --- a/direct/src/plugin/mkdir_complete.cxx +++ b/direct/src/plugin/mkdir_complete.cxx @@ -26,6 +26,10 @@ #include #endif +using std::ostream; +using std::string; +using std::wstring; + /** * Returns the directory component of the indicated pathname, or the empty * string if there is no directory prefix. diff --git a/direct/src/plugin/mkdir_complete.h b/direct/src/plugin/mkdir_complete.h index 5ba165e6be..be79cf7e8e 100644 --- a/direct/src/plugin/mkdir_complete.h +++ b/direct/src/plugin/mkdir_complete.h @@ -16,7 +16,6 @@ #include #include -using namespace std; bool mkdir_complete(const std::string &dirname, std::ostream &logfile); bool mkfile_complete(const std::string &dirname, std::ostream &logfile); diff --git a/direct/src/plugin/p3dAuthSession.cxx b/direct/src/plugin/p3dAuthSession.cxx index 15363647f9..e76bbe0a07 100644 --- a/direct/src/plugin/p3dAuthSession.cxx +++ b/direct/src/plugin/p3dAuthSession.cxx @@ -30,6 +30,8 @@ #include #endif +using std::string; + /** * */ @@ -178,7 +180,7 @@ start_p3dcert() { nullptr }; - wstring env_w; + std::wstring env_w; for (int ki = 0; keep[ki] != nullptr; ++ki) { wchar_t *value = _wgetenv(keep[ki]); @@ -369,7 +371,7 @@ win_create_process() { // Construct the command-line string, containing the quoted command-line // arguments. - ostringstream stream; + std::ostringstream stream; stream << "\"" << _p3dcert_exe << "\" \"" << _cert_filename->get_filename() << "\" \"" << _cert_dir << "\""; @@ -432,7 +434,7 @@ posix_create_process() { } // build up an array of char strings for the environment. - vector ptrs; + std::vector ptrs; size_t p = 0; size_t zero = _env.find('\0', p); while (zero != string::npos) { diff --git a/direct/src/plugin/p3dBoolObject.cxx b/direct/src/plugin/p3dBoolObject.cxx index 87736ba216..7740c2f669 100644 --- a/direct/src/plugin/p3dBoolObject.cxx +++ b/direct/src/plugin/p3dBoolObject.cxx @@ -59,7 +59,7 @@ get_int() { * to a string. */ void P3DBoolObject:: -make_string(string &value) { +make_string(std::string &value) { if (_value) { value = "True"; } else { diff --git a/direct/src/plugin/p3dCert.cxx b/direct/src/plugin/p3dCert.cxx index f47723d466..e6868bdb80 100644 --- a/direct/src/plugin/p3dCert.cxx +++ b/direct/src/plugin/p3dCert.cxx @@ -46,6 +46,10 @@ #include #endif +using std::cerr; +using std::string; +using std::wstring; + static LanguageIndex li = LI_default; #if defined(_WIN32) diff --git a/direct/src/plugin/p3dCert.h b/direct/src/plugin/p3dCert.h index 1583727565..3c856c6ec3 100644 --- a/direct/src/plugin/p3dCert.h +++ b/direct/src/plugin/p3dCert.h @@ -25,7 +25,6 @@ #include #include #include -using namespace std; class ViewCertDialog; diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index d2e5a78801..125732adda 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -20,6 +20,8 @@ #include "ca_bundle_data_src.c" +using std::cerr; + static const wxString self_signed_cert_text = _T("This Panda3D application uses a self-signed certificate. ") @@ -132,7 +134,7 @@ END_EVENT_TABLE() * */ AuthDialog:: -AuthDialog(const string &cert_filename, const string &cert_dir) : +AuthDialog(const std::string &cert_filename, const std::string &cert_dir) : // I hate stay-on-top dialogs, but if we don't set this flag, it doesn't // come to the foreground on OSX, and might be lost behind the browser // window. @@ -216,7 +218,7 @@ approve_cert() { size_t buf_length = _cert_dir.length() + 100; char *buf = new char[buf_length]; #ifdef _WIN32 - wstring buf_w; + std::wstring buf_w; #endif // _WIN32 while (true) { @@ -262,10 +264,10 @@ approve_cert() { * line into _cert and _stack. */ void AuthDialog:: -read_cert_file(const string &cert_filename) { +read_cert_file(const std::string &cert_filename) { FILE *fp = nullptr; #ifdef _WIN32 - wstring cert_filename_w; + std::wstring cert_filename_w; if (string_to_wstring(cert_filename_w, cert_filename)) { fp = _wfopen(cert_filename_w.c_str(), L"r"); } @@ -612,5 +614,5 @@ layout() { // Make sure the resulting window is at least a certain size. int width, height; GetSize(&width, &height); - SetSize(max(width, 600), max(height, 400)); + SetSize(std::max(width, 600), std::max(height, 400)); } diff --git a/direct/src/plugin/p3dCert_wx.h b/direct/src/plugin/p3dCert_wx.h index bced0ec91f..1ea8765a17 100644 --- a/direct/src/plugin/p3dCert_wx.h +++ b/direct/src/plugin/p3dCert_wx.h @@ -24,7 +24,6 @@ #include #include #include -using namespace std; class ViewCertDialog; diff --git a/direct/src/plugin/p3dConcreteSequence.cxx b/direct/src/plugin/p3dConcreteSequence.cxx index 2dd6dbf29e..ec4291cb7b 100644 --- a/direct/src/plugin/p3dConcreteSequence.cxx +++ b/direct/src/plugin/p3dConcreteSequence.cxx @@ -62,8 +62,8 @@ get_bool() { * to a string. */ void P3DConcreteSequence:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << "["; if (!_elements.empty()) { strm << *_elements[0]; @@ -81,7 +81,7 @@ make_string(string &value) { * new-reference P3D_object, or NULL on error. */ P3D_object *P3DConcreteSequence:: -get_property(const string &property) { +get_property(const std::string &property) { // We only understand integer "property" names. char *endptr; int index = strtoul(property.c_str(), &endptr, 10); @@ -97,7 +97,7 @@ get_property(const string &property) { * object. Returns true on success, false on failure. */ bool P3DConcreteSequence:: -set_property(const string &property, P3D_object *value) { +set_property(const std::string &property, P3D_object *value) { // We only understand integer "property" names. char *endptr; int index = strtoul(property.c_str(), &endptr, 10); diff --git a/direct/src/plugin/p3dConcreteStruct.cxx b/direct/src/plugin/p3dConcreteStruct.cxx index 753bcb2b83..fa9917d955 100644 --- a/direct/src/plugin/p3dConcreteStruct.cxx +++ b/direct/src/plugin/p3dConcreteStruct.cxx @@ -13,6 +13,8 @@ #include "p3dConcreteStruct.h" +using std::string; + /** * */ @@ -53,7 +55,7 @@ get_bool() { */ void P3DConcreteStruct:: make_string(string &value) { - ostringstream strm; + std::ostringstream strm; strm << "{"; if (!_elements.empty()) { Elements::iterator ei; @@ -105,7 +107,7 @@ set_property(const string &property, P3D_object *value) { } else { // Replace or insert an element. P3D_OBJECT_INCREF(value); - pair result = _elements.insert(Elements::value_type(property, value)); + std::pair result = _elements.insert(Elements::value_type(property, value)); if (!result.second) { // Replacing an element. Elements::iterator ei = result.first; diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index 6423b4d9a7..3b6a6cca7a 100644 --- a/direct/src/plugin/p3dDownload.cxx +++ b/direct/src/plugin/p3dDownload.cxx @@ -60,7 +60,7 @@ P3DDownload:: * Supplies the source URL for the download. */ void P3DDownload:: -set_url(const string &url) { +set_url(const std::string &url) { _url = url; } @@ -119,7 +119,7 @@ feed_url_stream(P3D_result_code result_code, _total_data += this_data_size; } - total_expected_data = max(total_expected_data, _total_data); + total_expected_data = std::max(total_expected_data, _total_data); if (total_expected_data > _total_expected_data) { // If the expected data grows during the download, we don't really know // how much we're getting. diff --git a/direct/src/plugin/p3dFileDownload.cxx b/direct/src/plugin/p3dFileDownload.cxx index 2d1a85497e..a978c3640e 100644 --- a/direct/src/plugin/p3dFileDownload.cxx +++ b/direct/src/plugin/p3dFileDownload.cxx @@ -38,7 +38,7 @@ P3DFileDownload(const P3DFileDownload ©) : * success, false on failure. */ bool P3DFileDownload:: -set_filename(const string &filename) { +set_filename(const std::string &filename) { _filename = filename; return open_file(); @@ -57,12 +57,12 @@ open_file() { _file.clear(); #ifdef _WIN32 - wstring filename_w; + std::wstring filename_w; if (string_to_wstring(filename_w, _filename)) { - _file.open(filename_w.c_str(), ios::out | ios::trunc | ios::binary); + _file.open(filename_w.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); } #else // _WIN32 - _file.open(_filename.c_str(), ios::out | ios::trunc | ios::binary); + _file.open(_filename.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #endif // _WIN32 if (!_file) { nout << "Failed to open " << _filename << " in write mode\n"; diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index 1be229e3bb..a32ede4b95 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -14,6 +14,8 @@ #include "p3dFileParams.h" #include +using std::string; + /** * */ diff --git a/direct/src/plugin/p3dFloatObject.cxx b/direct/src/plugin/p3dFloatObject.cxx index 2581c44282..3262d45a54 100644 --- a/direct/src/plugin/p3dFloatObject.cxx +++ b/direct/src/plugin/p3dFloatObject.cxx @@ -67,8 +67,8 @@ get_float() { * to a string. */ void P3DFloatObject:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << _value; value = strm.str(); } diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 028af6bef0..991a66df3e 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -25,6 +25,11 @@ #include #endif +using std::ios; +using std::ostringstream; +using std::string; +using std::wstring; + /** * Use P3DInstanceManager::get_host() to construct a new P3DHost. */ @@ -200,11 +205,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { _contents_spec.read_hash(contents_filename); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } nout << "read contents.xml, max_age = " << max_age - << ", expires in " << max(_contents_expiration, now) - now + << ", expires in " << std::max(_contents_expiration, now) - now << " s\n"; TiXmlElement *xhost = _xcontents->FirstChildElement("host"); @@ -631,10 +636,10 @@ migrate_package_host(P3DPackage *package, const string &alt_host, P3DHost *new_h * elements in the list, adds only as many mirrors as we can get. */ void P3DHost:: -choose_random_mirrors(vector &result, int num_mirrors) { - vector selected; +choose_random_mirrors(std::vector &result, int num_mirrors) { + std::vector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -846,7 +851,7 @@ copy_file(const string &from_filename, const string &to_filename) { char buffer[buffer_size]; in.read(buffer, buffer_size); - streamsize count = in.gcount(); + std::streamsize count = in.gcount(); while (count != 0) { out.write(buffer, count); if (out.fail()) { diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 21e608d5a5..220e28c667 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -34,6 +34,14 @@ #include #include +using std::max; +using std::min; +using std::ostream; +using std::ostringstream; +using std::stringstream; +using std::string; +using std::vector; + // Lifted from NSEvent.h (which is Objective-C). enum { NSAlphaShiftKeyMask = 1 << 16, @@ -1472,7 +1480,7 @@ uninstall_host() { uninstall_packages(); // Collect the set of hosts referenced by this instance. - set hosts; + std::set hosts; Packages::const_iterator pi; for (pi = _packages.begin(); pi != _packages.end(); ++pi) { P3DPackage *package = (*pi); @@ -1484,7 +1492,7 @@ uninstall_host() { nout << "Uninstalling " << hosts.size() << " hosts\n"; // Uninstall all of them. - set::iterator hi; + std::set::iterator hi; for (hi = hosts.begin(); hi != hosts.end(); ++hi) { P3DHost *host = (*hi); host->uninstall(); diff --git a/direct/src/plugin/p3dInstanceManager.cxx b/direct/src/plugin/p3dInstanceManager.cxx index 3b8c52ba15..93e2ffcfc2 100644 --- a/direct/src/plugin/p3dInstanceManager.cxx +++ b/direct/src/plugin/p3dInstanceManager.cxx @@ -50,8 +50,12 @@ #include +using std::string; +using std::vector; +using std::wstring; + static ofstream logfile; -ostream *nout_stream = &logfile; +std::ostream *nout_stream = &logfile; P3DInstanceManager *P3DInstanceManager::_global_ptr; @@ -285,7 +289,7 @@ initialize(int api_version, const string &contents_filename, if (root_dir.empty()) { _root_dir = find_root_dir(); if (_root_dir.empty()) { - cerr << "Could not find root directory.\n"; + std::cerr << "Could not find root directory.\n"; return false; } } else { @@ -1306,19 +1310,19 @@ append_safe_dir(string &root, const string &basename) { */ void P3DInstanceManager:: create_runtime_environment() { - mkdir_complete(_log_directory, cerr); + mkdir_complete(_log_directory, std::cerr); logfile.close(); logfile.clear(); #ifdef _WIN32 wstring log_pathname_w; string_to_wstring(log_pathname_w, _log_pathname); - logfile.open(log_pathname_w.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname_w.c_str(), std::ios::out | std::ios::trunc); #else - logfile.open(_log_pathname.c_str(), ios::out | ios::trunc); + logfile.open(_log_pathname.c_str(), std::ios::out | std::ios::trunc); #endif // _WIN32 if (logfile) { - logfile.setf(ios::unitbuf); + logfile.setf(std::ios::unitbuf); nout_stream = &logfile; } diff --git a/direct/src/plugin/p3dIntObject.cxx b/direct/src/plugin/p3dIntObject.cxx index 4fa4b14aaf..05ad970128 100644 --- a/direct/src/plugin/p3dIntObject.cxx +++ b/direct/src/plugin/p3dIntObject.cxx @@ -59,8 +59,8 @@ get_int() { * to a string. */ void P3DIntObject:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << _value; value = strm.str(); } diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index adda6129d6..2fd8dba33d 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -18,6 +18,11 @@ #include "p3dStringObject.h" #include "p3dInstanceManager.h" +using std::ios; +using std::max; +using std::streamsize; +using std::string; + /** * */ @@ -231,7 +236,7 @@ call(const string &method_name, bool needs_response, * This is intended for developer assistance. */ void P3DMainObject:: -output(ostream &out) { +output(std::ostream &out) { out << "P3DMainObject"; } @@ -459,7 +464,7 @@ P3D_object *P3DMainObject:: read_log(const string &log_pathname, P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); string log_directory = inst_mgr->get_log_directory(); - ostringstream log_data; + std::ostringstream log_data; // Check the first parameter, if any--if given, it specifies the last n // bytes to retrieve. @@ -512,7 +517,7 @@ read_log(const string &log_pathname, P3D_object *params[], int num_params) { } // Read matching files - vector all_logs; + std::vector all_logs; int log_matches_found = 0; string log_matching_pathname; inst_mgr->scan_directory(log_directory, all_logs); @@ -544,7 +549,7 @@ read_log(const string &log_pathname, P3D_object *params[], int num_params) { void P3DMainObject:: read_log_file(const string &log_pathname, size_t tail_bytes, size_t head_bytes, - ostringstream &log_data) { + std::ostringstream &log_data) { // Get leaf name string log_leafname = log_pathname; diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index dfaf4d8a2d..e47400bdb6 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -23,6 +23,13 @@ #include #endif +using std::ios; +using std::max; +using std::min; +using std::streampos; +using std::streamsize; +using std::string; + // This sequence of bytes begins each Multifile to identify it as a Multifile. const char P3DMultifileReader::_header[] = "pmf\0\n\r"; const size_t P3DMultifileReader::_header_size = 6; @@ -99,7 +106,7 @@ extract_all(const string &to_dir, P3DPackage *package, ofstream out; #ifdef _WIN32 - wstring output_pathname_w; + std::wstring output_pathname_w; if (string_to_wstring(output_pathname_w, output_pathname)) { out.open(output_pathname_w.c_str(), ios::out | ios::binary); } @@ -140,7 +147,7 @@ extract_all(const string &to_dir, P3DPackage *package, * stream. Returns true on success, false on failure. */ bool P3DMultifileReader:: -extract_one(ostream &out, const string &filename) { +extract_one(std::ostream &out, const string &filename) { assert(_is_open); if (_in.fail()) { return false; @@ -202,7 +209,7 @@ read_header(const string &pathname) { _signatures.clear(); #ifdef _WIN32 - wstring pathname_w; + std::wstring pathname_w; if (string_to_wstring(pathname_w, pathname)) { _in.open(pathname_w.c_str(), ios::in | ios::binary); } @@ -341,7 +348,7 @@ read_index() { * Returns true on success, false on failure. */ bool P3DMultifileReader:: -extract_subfile(ostream &out, const Subfile &s) { +extract_subfile(std::ostream &out, const Subfile &s) { _in.seekg(s._data_start + _read_offset); static const streamsize buffer_size = 4096; diff --git a/direct/src/plugin/p3dNoneObject.cxx b/direct/src/plugin/p3dNoneObject.cxx index 0245b61174..2a1653a2b8 100644 --- a/direct/src/plugin/p3dNoneObject.cxx +++ b/direct/src/plugin/p3dNoneObject.cxx @@ -41,6 +41,6 @@ get_bool() { * to a string. */ void P3DNoneObject:: -make_string(string &value) { +make_string(std::string &value) { value = "None"; } diff --git a/direct/src/plugin/p3dObject.cxx b/direct/src/plugin/p3dObject.cxx index a8393a6c11..f34f2d6d2d 100644 --- a/direct/src/plugin/p3dObject.cxx +++ b/direct/src/plugin/p3dObject.cxx @@ -19,6 +19,8 @@ #include "p3dInstanceManager.h" #include // strncpy +using std::string; + // The following functions are C-style wrappers around the below P3DObject // virtual methods; they are defined to allow us to create the C-style // P3D_class_definition method table to store in the P3D_object structure. @@ -231,7 +233,7 @@ get_string(char *buffer, int buffer_length) { */ int P3DObject:: get_repr(char *buffer, int buffer_length) { - ostringstream strm; + std::ostringstream strm; output(strm); string result = strm.str(); strncpy(buffer, result.c_str(), buffer_length); @@ -292,7 +294,7 @@ eval(const string &expression) { * This is intended for developer assistance. */ void P3DObject:: -output(ostream &out) { +output(std::ostream &out) { string value; make_string(value); out << value; diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index d504d58671..4139a9629d 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -26,6 +26,8 @@ #endif #endif +using std::string; + /** * */ @@ -580,7 +582,7 @@ paint_image(CGContextRef context, const OsxImageData &image) { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; double y_scale = (double)_win_height / (double)image._height; - double scale = min(x_scale, y_scale); + double scale = std::min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 1efead479b..fad2dd97f2 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -29,6 +29,12 @@ #include // chmod() #endif +using std::ios; +using std::ostream; +using std::ostringstream; +using std::string; +using std::vector; + // Weight factors for computing download progress. This attempts to reflect // the relative time-per-byte of each of these operations. const double P3DPackage::_download_factor = 1.0; @@ -1147,7 +1153,7 @@ void P3DPackage:: report_progress(P3DPackage::InstallStep *step) { if (_computed_plan_size) { double size = _total_plan_completed + _current_step_effort * step->get_progress(); - _download_progress = min(size / _total_plan_size, 1.0); + _download_progress = std::min(size / _total_plan_size, 1.0); Instances::iterator ii; for (ii = _instances.begin(); ii != _instances.end(); ++ii) { @@ -1780,7 +1786,7 @@ thread_step() { ifstream source; #ifdef _WIN32 - wstring source_pathname_w; + std::wstring source_pathname_w; if (string_to_wstring(source_pathname_w, source_pathname)) { source.open(source_pathname_w.c_str(), ios::in | ios::binary); } @@ -1798,7 +1804,7 @@ thread_step() { ofstream target; #ifdef _WIN32 - wstring target_pathname_w; + std::wstring target_pathname_w; if (string_to_wstring(target_pathname_w, target_pathname)) { target.open(target_pathname_w.c_str(), ios::out | ios::binary); } @@ -1829,7 +1835,7 @@ thread_step() { int flush = 0; source.read(decompress_buffer, decompress_buffer_size); - streamsize read_count = source.gcount(); + std::streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); z.next_in = (Bytef *)decompress_buffer; @@ -1844,7 +1850,7 @@ thread_step() { while (true) { if (z.avail_in == 0 && !eof) { source.read(decompress_buffer, decompress_buffer_size); - streamsize read_count = source.gcount(); + std::streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); z.next_in = (Bytef *)decompress_buffer; diff --git a/direct/src/plugin/p3dPatchFinder.cxx b/direct/src/plugin/p3dPatchFinder.cxx index 044953b3af..fbc109fe8c 100644 --- a/direct/src/plugin/p3dPatchFinder.cxx +++ b/direct/src/plugin/p3dPatchFinder.cxx @@ -13,6 +13,8 @@ #include "p3dPatchFinder.h" +using std::string; + /** * */ @@ -116,7 +118,7 @@ operator < (const PackageVersionKey &other) const { * */ void P3DPatchFinder::PackageVersionKey:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _package_name << ", " << _platform << ", " << _version << ", " << _host_url << ", "; _file.output_hash(out); diff --git a/direct/src/plugin/p3dPatchfileReader.cxx b/direct/src/plugin/p3dPatchfileReader.cxx index 255bed8477..14ede5e9f9 100644 --- a/direct/src/plugin/p3dPatchfileReader.cxx +++ b/direct/src/plugin/p3dPatchfileReader.cxx @@ -14,6 +14,9 @@ #include "p3dPatchfileReader.h" #include "wstring_encode.h" +using std::ios; +using std::string; + /** * */ @@ -55,7 +58,7 @@ open_read() { string patch_pathname = _patchfile.get_pathname(_package_dir); _patch_in.clear(); #ifdef _WIN32 - wstring patch_pathname_w; + std::wstring patch_pathname_w; if (string_to_wstring(patch_pathname_w, patch_pathname)) { _patch_in.open(patch_pathname_w.c_str(), ios::in | ios::binary); } @@ -66,7 +69,7 @@ open_read() { string source_pathname = _source.get_pathname(_package_dir); _source_in.clear(); #ifdef _WIN32 - wstring source_pathname_w; + std::wstring source_pathname_w; if (string_to_wstring(source_pathname_w, source_pathname)) { _source_in.open(source_pathname_w.c_str(), ios::in | ios::binary); } @@ -77,7 +80,7 @@ open_read() { mkfile_complete(_output_pathname, nout); _target_out.clear(); #ifdef _WIN32 - wstring output_pathname_w; + std::wstring output_pathname_w; if (string_to_wstring(output_pathname_w, _output_pathname)) { _target_out.open(output_pathname_w.c_str(), ios::in | ios::binary); } @@ -247,13 +250,13 @@ close() { * have enough bytes. */ bool P3DPatchfileReader:: -copy_bytes(istream &in, size_t copy_byte_count) { +copy_bytes(std::istream &in, size_t copy_byte_count) { static const size_t buffer_size = 8192; char buffer[buffer_size]; - streamsize read_size = min(copy_byte_count, buffer_size); + std::streamsize read_size = std::min(copy_byte_count, buffer_size); in.read(buffer, read_size); - streamsize count = in.gcount(); + std::streamsize count = in.gcount(); while (count != 0) { _target_out.write(buffer, count); _bytes_written += (size_t)count; @@ -267,7 +270,7 @@ copy_bytes(istream &in, size_t copy_byte_count) { copy_byte_count -= (size_t)count; count = 0; if (copy_byte_count != 0) { - read_size = min(copy_byte_count, buffer_size); + read_size = std::min(copy_byte_count, buffer_size); in.read(buffer, read_size); count = in.gcount(); } diff --git a/direct/src/plugin/p3dPythonMain.cxx b/direct/src/plugin/p3dPythonMain.cxx index 3d8bbdc9e8..b5d11e6052 100644 --- a/direct/src/plugin/p3dPythonMain.cxx +++ b/direct/src/plugin/p3dPythonMain.cxx @@ -18,7 +18,6 @@ #include #include #include // strrchr -using namespace std; #if defined(_WIN32) && defined(NON_CONSOLE) // On Windows, we may need to build p3dpythonw.exe, a non-console version of @@ -34,7 +33,7 @@ static char * parse_quoted_arg(char *&p) { char quote = *p; ++p; - string result; + std::string result; while (*p != '\0' && *p != quote) { // TODO: handle escape characters? Not sure if we need to. @@ -51,7 +50,7 @@ parse_quoted_arg(char *&p) { // beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { - string result; + std::string result; while (*p != '\0' && !isspace(*p)) { result += *p; ++p; @@ -63,7 +62,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); - vector argv; + std::vector argv; char *p = command_line; while (*p != '\0') { @@ -113,13 +112,13 @@ main(int argc, char *argv[]) { } if (archive_file == nullptr || *archive_file == '\0') { - cerr << "No archive filename specified on command line.\n"; + std::cerr << "No archive filename specified on command line.\n"; return 1; } FHandle input_handle = invalid_fhandle; if (input_handle_str != nullptr && *input_handle_str) { - stringstream stream(input_handle_str); + std::stringstream stream(input_handle_str); stream >> input_handle; if (!stream) { input_handle = invalid_fhandle; @@ -128,7 +127,7 @@ main(int argc, char *argv[]) { FHandle output_handle = invalid_fhandle; if (output_handle_str != nullptr && *output_handle_str) { - stringstream stream(output_handle_str); + std::stringstream stream(output_handle_str); stream >> output_handle; if (!stream) { output_handle = invalid_fhandle; @@ -137,7 +136,7 @@ main(int argc, char *argv[]) { bool interactive_console = false; if (interactive_console_str != nullptr && *interactive_console_str) { - stringstream stream(interactive_console_str); + std::stringstream stream(interactive_console_str); int flag; stream >> flag; if (!stream.fail()) { @@ -148,7 +147,7 @@ main(int argc, char *argv[]) { int status = run_p3dpython(program_name, archive_file, input_handle, output_handle, nullptr, interactive_console); if (status != 0) { - cerr << "Failure on startup.\n"; + std::cerr << "Failure on startup.\n"; } return status; } diff --git a/direct/src/plugin/p3dPythonObject.cxx b/direct/src/plugin/p3dPythonObject.cxx index fb52163b71..58a2d0348f 100644 --- a/direct/src/plugin/p3dPythonObject.cxx +++ b/direct/src/plugin/p3dPythonObject.cxx @@ -13,6 +13,8 @@ #include "p3dPythonObject.h" +using std::string; + /** * */ @@ -178,7 +180,7 @@ set_property_insecure(const string &property, bool needs_response, bool P3DPythonObject:: has_method(const string &method_name) { // First, check the cache. - pair cresult = _has_method.insert(HasMethod::value_type(method_name, false)); + std::pair cresult = _has_method.insert(HasMethod::value_type(method_name, false)); HasMethod::iterator hi = cresult.first; if (!cresult.second) { // Already cached. @@ -281,7 +283,7 @@ call_insecure(const string &method_name, bool needs_response, * This is intended for developer assistance. */ void P3DPythonObject:: -output(ostream &out) { +output(std::ostream &out) { P3D_object *result = call("__repr__", true, nullptr, 0); out << "Python " << _object_id; if (result != nullptr) { diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 3d657597fe..b9e4c5655e 100644 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -20,6 +20,8 @@ #include "py_panda.h" +using std::string; + extern "C" { // This has been compiled-in by the build system, if all is well. extern struct _frozen _PyImport_FrozenModules[]; @@ -118,7 +120,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, f.set_text(); if (f.open_write(_error_log)) { // Set up the indicated error log as the Notify output. - _error_log.setf(ios::unitbuf); + _error_log.setf(std::ios::unitbuf); Notify::ptr()->set_ostream_ptr(&_error_log, false); } } @@ -155,7 +157,7 @@ P3DPythonRun:: // Restore the notify stream in case it tries to write to anything else // after our shutdown. - Notify::ptr()->set_ostream_ptr(&cerr, false); + Notify::ptr()->set_ostream_ptr(&std::cerr, false); } /** @@ -1439,7 +1441,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { const char *parent_cstr = xwparams->Attribute("parent_xwindow"); if (parent_cstr != nullptr) { long window; - istringstream strm(parent_cstr); + std::istringstream strm(parent_cstr); strm >> window; parent_window_handle = NativeWindowHandle::make_x11((X11_Window)window); } diff --git a/direct/src/plugin/p3dPythonRun.h b/direct/src/plugin/p3dPythonRun.h index e478670cca..ee3fbc3d00 100644 --- a/direct/src/plugin/p3dPythonRun.h +++ b/direct/src/plugin/p3dPythonRun.h @@ -41,8 +41,6 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif -using namespace std; - /** * This class is used to run, and communicate with, embedded Python in a sub- * process. It is compiled and launched as a separate executable from the diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index cb0fb58d78..4a769ec9e1 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -43,6 +43,9 @@ #include #endif +using std::string; +using std::wstring; + /** * Creates a new session, corresponding to a new subprocess with its own copy * of Python. The initial parameters for the session are taken from the @@ -1047,7 +1050,7 @@ start_p3dpython(P3DInstance *inst) { // Check if we want to keep copies of recent logs on disk. if (!log_basename.empty()) { // Get a list of all logs on disk - vector all_logs; + std::vector all_logs; string log_directory = inst_mgr->get_log_directory(); inst_mgr->scan_directory(log_directory, all_logs); @@ -1067,7 +1070,7 @@ start_p3dpython(P3DInstance *inst) { // Remove all but the most recent log_history timestamped logs string log_basename_dash = (log_basename + string("-")); string log_matching_pathname; - vector matching_logs; + std::vector matching_logs; for (int i=0; i<(int)all_logs.size(); ++i) { if ((all_logs[i].size() > 4) && (all_logs[i].find(log_basename_dash) == 0) && @@ -1457,7 +1460,7 @@ win_create_process() { // Construct the command-line string, containing the quoted command-line // arguments. - ostringstream stream; + std::ostringstream stream; stream << "\"" << _p3dpython_exe << "\" \"" << _mf_filename << "\" \"" << _input_handle << "\" \"" << _output_handle << "\" \"" << _interactive_console << "\""; @@ -1569,7 +1572,7 @@ posix_create_process() { } // build up an array of char strings for the environment. - vector ptrs; + std::vector ptrs; size_t p = 0; size_t zero = _env.find('\0', p); while (zero != string::npos) { @@ -1579,11 +1582,11 @@ posix_create_process() { } ptrs.push_back(nullptr); - stringstream input_handle_stream; + std::stringstream input_handle_stream; input_handle_stream << _input_handle; string input_handle_str = input_handle_stream.str(); - stringstream output_handle_stream; + std::stringstream output_handle_stream; output_handle_stream << _output_handle; string output_handle_str = output_handle_stream.str(); diff --git a/direct/src/plugin/p3dSplashWindow.cxx b/direct/src/plugin/p3dSplashWindow.cxx index 2660cb2b3e..13bcc09ff2 100644 --- a/direct/src/plugin/p3dSplashWindow.cxx +++ b/direct/src/plugin/p3dSplashWindow.cxx @@ -20,6 +20,10 @@ #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" +using std::max; +using std::min; +using std::string; + // The number of pixels to move the block per byte downloaded, when we don't // know the actual file size we're downloading. const double P3DSplashWindow::_unknown_progress_rate = 1.0 / 4096; diff --git a/direct/src/plugin/p3dStringObject.cxx b/direct/src/plugin/p3dStringObject.cxx index d0188a65af..8d87a2dc8c 100644 --- a/direct/src/plugin/p3dStringObject.cxx +++ b/direct/src/plugin/p3dStringObject.cxx @@ -17,7 +17,7 @@ * */ P3DStringObject:: -P3DStringObject(const string &value) : _value(value) { +P3DStringObject(const std::string &value) : _value(value) { } /** @@ -65,7 +65,7 @@ get_bool() { * to a string. */ void P3DStringObject:: -make_string(string &value) { +make_string(std::string &value) { value = _value; } @@ -74,9 +74,9 @@ make_string(string &value) { * This is intended for developer assistance. */ void P3DStringObject:: -output(ostream &out) { +output(std::ostream &out) { out << '"'; - for (string::const_iterator si = _value.begin(); si != _value.end(); ++si) { + for (std::string::const_iterator si = _value.begin(); si != _value.end(); ++si) { if (isprint(*si)) { switch (*si) { case '"': diff --git a/direct/src/plugin/p3dTemporaryFile.cxx b/direct/src/plugin/p3dTemporaryFile.cxx index ca7abe701a..bb7c8ca7a1 100644 --- a/direct/src/plugin/p3dTemporaryFile.cxx +++ b/direct/src/plugin/p3dTemporaryFile.cxx @@ -18,7 +18,7 @@ * Constructs a new, unique temporary filename. */ P3DTemporaryFile:: -P3DTemporaryFile(const string &extension) { +P3DTemporaryFile(const std::string &extension) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _filename = inst_mgr->make_temp_filename(extension); } diff --git a/direct/src/plugin/p3dUndefinedObject.cxx b/direct/src/plugin/p3dUndefinedObject.cxx index 80cbb5897d..0ed227573f 100644 --- a/direct/src/plugin/p3dUndefinedObject.cxx +++ b/direct/src/plugin/p3dUndefinedObject.cxx @@ -41,6 +41,6 @@ get_bool() { * to a string. */ void P3DUndefinedObject:: -make_string(string &value) { +make_string(std::string &value) { value = "Undefined"; } diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index 5cc189b31c..256acb5eb8 100644 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -95,7 +95,7 @@ set_visible(bool visible) { * the splash window. */ void P3DWinSplashWindow:: -set_image_filename(const string &image_filename, ImagePlacement image_placement) { +set_image_filename(const std::string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << ", thread_id = " << _thread_id << "\n"; WinImageData *image = nullptr; switch (image_placement) { @@ -141,7 +141,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) * Specifies the text that is displayed above the install progress bar. */ void P3DWinSplashWindow:: -set_install_label(const string &install_label) { +set_install_label(const std::string &install_label) { ACQUIRE_LOCK(_install_lock); if (_install_label != install_label) { _install_label = install_label; @@ -493,7 +493,7 @@ update_image(WinImageData &image) { InvalidateRect(_hwnd, nullptr, TRUE); // Go read the image. - string data; + std::string data; if (!read_image_data(image, data, image._filename)) { return; } @@ -715,7 +715,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; double y_scale = (double)_win_height / (double)image._height; - double scale = min(x_scale, y_scale); + double scale = std::min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); diff --git a/direct/src/plugin/p3dWindowParams.cxx b/direct/src/plugin/p3dWindowParams.cxx index e6e9b750e4..29ed954823 100644 --- a/direct/src/plugin/p3dWindowParams.cxx +++ b/direct/src/plugin/p3dWindowParams.cxx @@ -78,7 +78,7 @@ make_xml(P3DInstance *inst) { // TinyXml doesn't support a "long" attribute. We'll use stringstream to // do it ourselves. { - ostringstream strm; + std::ostringstream strm; assert(_parent_window._window_handle_type == P3D_WHT_x11_window); strm << _parent_window._handle._x11_window._xwindow; xwparams->SetAttribute("parent_xwindow", strm.str()); diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index 2e1bbcb66e..07e5fc4d99 100644 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -24,6 +24,9 @@ #include #include +using std::string; +using std::vector; + /** * */ @@ -1284,7 +1287,7 @@ scale_image(vector &image0, int &image0_width, int &image0_height } else { // Yuck, the bad case - we need to scale it down. - double scale = min((double)_win_width / (double)image._width, + double scale = std::min((double)_win_width / (double)image._width, (double)_win_height / (double)image._height); image0_width = (int)(image._width * scale); image0_height = (int)(image._height * scale); @@ -1335,8 +1338,8 @@ compose_two_images(vector &image0, int &image0_width, int &image0 const vector &image1, int image1_width, int image1_height, const vector &image2, int image2_width, int image2_height) { // First, the resulting image size is the larger of the two. - image0_width = max(image1_width, image2_width); - image0_height = max(image1_height, image2_height); + image0_width = std::max(image1_width, image2_width); + image0_height = std::max(image1_height, image2_height); int new_row_stride = image0_width * 4; int new_data_length = image0_height * new_row_stride; diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 5cddf55b31..7e6c01108b 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/direct/src/plugin/p3d_plugin.cxx @@ -448,7 +448,7 @@ P3D_new_string_object(const char *str, int length) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); - P3D_object *result = new P3DStringObject(string(str, length)); + P3D_object *result = new P3DStringObject(std::string(str, length)); RELEASE_LOCK(_api_lock); return result; diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index 748005c48d..6ddd0e057c 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -34,8 +34,6 @@ #include #include -using namespace std; - // Appears in p3dInstanceManager.cxx. extern std::ostream *nout_stream; #define nout (*nout_stream) diff --git a/direct/src/plugin/parse_color.cxx b/direct/src/plugin/parse_color.cxx index e3094e9d40..4a5f12b587 100644 --- a/direct/src/plugin/parse_color.cxx +++ b/direct/src/plugin/parse_color.cxx @@ -22,7 +22,7 @@ static bool parse_hexdigit(int &result, char digit); * in the range 0..255. On failure, r, g, b are undefined. */ bool -parse_color(int &r, int &g, int &b, const string &color) { +parse_color(int &r, int &g, int &b, const std::string &color) { if (color.empty() || color[0] != '#') { return false; } diff --git a/direct/src/plugin/parse_color.h b/direct/src/plugin/parse_color.h index ba5dd152a8..794abf2055 100644 --- a/direct/src/plugin/parse_color.h +++ b/direct/src/plugin/parse_color.h @@ -15,7 +15,6 @@ #define PARSE_COLOR_H #include -using namespace std; bool parse_color(int &r, int &g, int &b, const std::string &color); diff --git a/direct/src/plugin/wstring_encode.cxx b/direct/src/plugin/wstring_encode.cxx index 3766e7dc10..e844d643bd 100644 --- a/direct/src/plugin/wstring_encode.cxx +++ b/direct/src/plugin/wstring_encode.cxx @@ -21,13 +21,12 @@ #include #endif // _WIN32 - #ifdef _WIN32 /** * Encodes std::wstring to std::string using UTF-8. */ bool -wstring_to_string(string &result, const wstring &source) { +wstring_to_string(std::string &result, const std::wstring &source) { bool success = false; int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), nullptr, 0, nullptr, nullptr); @@ -51,7 +50,7 @@ wstring_to_string(string &result, const wstring &source) { * Decodes std::string to std::wstring using UTF-8. */ bool -string_to_wstring(wstring &result, const string &source) { +string_to_wstring(std::wstring &result, const std::string &source) { bool success = false; int size = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), nullptr, 0); diff --git a/direct/src/plugin/wstring_encode.h b/direct/src/plugin/wstring_encode.h index 5d5ebab4de..b9641bd43d 100644 --- a/direct/src/plugin/wstring_encode.h +++ b/direct/src/plugin/wstring_encode.h @@ -15,7 +15,6 @@ #define WSTRING_ENCODE_H #include -using namespace std; // Presently, these two functions are implemented only for Windows, which is // the only place they are needed. (Only Windows requires wstrings for diff --git a/direct/src/plugin/xml_helpers.cxx b/direct/src/plugin/xml_helpers.cxx index 20da4ce7ca..9a997189da 100644 --- a/direct/src/plugin/xml_helpers.cxx +++ b/direct/src/plugin/xml_helpers.cxx @@ -21,7 +21,7 @@ * empty. */ bool -parse_bool_attrib(TiXmlElement *xelem, const string &attrib, +parse_bool_attrib(TiXmlElement *xelem, const std::string &attrib, bool default_value) { const char *value = xelem->Attribute(attrib.c_str()); if (value == nullptr || *value == '\0') { diff --git a/direct/src/plugin_npapi/nppanda3d_common.h b/direct/src/plugin_npapi/nppanda3d_common.h index a3bb8f0191..c1b7cd61af 100644 --- a/direct/src/plugin_npapi/nppanda3d_common.h +++ b/direct/src/plugin_npapi/nppanda3d_common.h @@ -30,8 +30,6 @@ #include #include -using namespace std; - // Appears in startup.cxx. extern std::ostream *nout_stream; #define nout (*nout_stream) diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 9655295141..17104b9e6c 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -16,6 +16,8 @@ #include #include // strncpy +using std::string; + // The following functions are C-style wrappers around the above // PPBrowserObject methods; they are defined to allow us to create the C-style // P3D_class_definition method table to store in the P3D_object structure. @@ -105,7 +107,7 @@ PPBrowserObject:: */ int PPBrowserObject:: get_repr(char *buffer, int buffer_length) const { - ostringstream strm; + std::ostringstream strm; strm << "NPObject " << _npobj; string result = strm.str(); strncpy(buffer, result.c_str(), buffer_length); diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 8e3281c405..6a3d961e32 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -41,6 +41,12 @@ #include #endif // HAVE_X11 +using std::ios; +using std::ostream; +using std::ostringstream; +using std::string; +using std::vector; + PPInstance::FileDatas PPInstance::_file_datas; @@ -1154,7 +1160,7 @@ void PPInstance:: choose_random_mirrors(vector &result, int num_mirrors) { vector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -1313,11 +1319,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { xorig->Attribute("expiration", &expiration); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } nout << "read contents.xml, max_age = " << max_age - << ", expires in " << max(_contents_expiration, now) - now + << ", expires in " << std::max(_contents_expiration, now) - now << " s\n"; // Look for the entry; it might point us at a different download @@ -2411,7 +2417,7 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, * returns result.c_str(). */ const wchar_t *PPInstance:: -make_ansi_string(wstring &result, NPNSString *ns_string) { +make_ansi_string(std::wstring &result, NPNSString *ns_string) { result.clear(); if (ns_string != nullptr) { diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index f85ef43407..e4e4854c3f 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/direct/src/plugin_npapi/ppPandaObject.cxx @@ -13,6 +13,8 @@ #include "ppPandaObject.h" +using std::string; + NPClass PPPandaObject::_object_class = { NP_CLASS_STRUCT_VERSION, &PPPandaObject::NPAllocate, @@ -304,7 +306,7 @@ identifier_to_string(NPIdentifier ident) { // Firefox does, but Safari doesn't appear to use integer identifiers and // just sends everything as a string identifier. So to make things // consistent internally, we also send everything as a string. - ostringstream strm; + std::ostringstream strm; strm << browser->intfromidentifier(ident); return strm.str(); } diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index 0c6a99c258..315a21f8cc 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -23,8 +23,10 @@ #include #endif +using std::string; + static ofstream logfile; -ostream *nout_stream = &logfile; +std::ostream *nout_stream = &logfile; string global_root_dir; bool has_plugin_thread_async_call; @@ -62,7 +64,7 @@ open_logfile() { if (log_directory.empty()) { log_directory = global_root_dir + "/log"; } - mkdir_complete(log_directory, cerr); + mkdir_complete(log_directory, std::cerr); // Ensure that the log directory ends with a slash. if (!log_directory.empty() && log_directory[log_directory.size() - 1] != '/') { @@ -92,13 +94,13 @@ open_logfile() { logfile.close(); logfile.clear(); #ifdef _WIN32 - wstring log_pathname_w; + std::wstring log_pathname_w; string_to_wstring(log_pathname_w, log_pathname); - logfile.open(log_pathname_w.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname_w.c_str(), std::ios::out | std::ios::trunc); #else - logfile.open(log_pathname.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname.c_str(), std::ios::out | std::ios::trunc); #endif // _WIN32 - logfile.setf(ios::unitbuf); + logfile.setf(std::ios::unitbuf); } // If we didn't have a logfile name compiled in, we throw away log output diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index 14903aa600..1d191e9c22 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -17,6 +17,9 @@ #include "load_plugin.h" #include "find_root_dir.h" +using std::cerr; +using std::string; + /** * */ @@ -36,7 +39,7 @@ P3DEmbed(bool console_environment) : Panda3DBase(console_environment) { * offset. */ int P3DEmbed:: -run_embedded(streampos read_offset, int argc, char *argv[]) { +run_embedded(std::streampos read_offset, int argc, char *argv[]) { // Check to see if we've actually got an application embedded. If we do, // read_offset will have been modified to contain a different value than the // one we compiled in, above. We test against read_offset + 1, because any @@ -46,8 +49,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { // We also have to store this computation in a member variable, to work // around a compiler optimization that might otherwise remove the + 1 from // the test. - _read_offset_check = read_offset + (streampos)1; - if (_read_offset_check == (streampos)0xFF3D3D01) { + _read_offset_check = read_offset + (std::streampos)1; + if (_read_offset_check == (std::streampos)0xFF3D3D01) { cerr << "This program is not intended to be run directly.\nIt is used " "by pdeploy to construct an embedded Panda3D application.\n"; return 1; diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 8710d92696..d21933a441 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -29,6 +29,10 @@ #include #endif +using std::cerr; +using std::cout; +using std::string; + /** * */ @@ -410,7 +414,7 @@ download_contents_file(const Filename &contents_filename) { if (!success) { // Go download contents.xml from the actual host. - ostringstream strm; + std::ostringstream strm; strm << _host_url_prefix << "contents.xml"; // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; that's @@ -498,7 +502,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { xorig->Attribute("expiration", &expiration); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } // Look for the entry; it might point us at a different download @@ -670,7 +674,7 @@ void Panda3D:: choose_random_mirrors(vector_string &result, int num_mirrors) { pvector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -740,7 +744,7 @@ get_core_api() { #endif // Format the coreapi_timestamp as a string, for passing as a parameter. - ostringstream stream; + std::ostringstream stream; stream << _coreapi_dll.get_timestamp(); string coreapi_timestamp = stream.str(); @@ -765,7 +769,7 @@ download_core_api() { // Our last act of desperation: hit the original host, with a query // uniquifier, to break through any caches. - ostringstream strm; + std::ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() << "?" << time(nullptr); url = strm.str(); diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index 07f86fb18a..cfdaeb1350 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -35,6 +35,9 @@ #include #include +using std::cerr; +using std::string; + // The amount of time in seconds to wait for new messages. static const double wait_cycle = 0.2; @@ -436,7 +439,7 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { string p3d_info; mf->read_subfile(si, p3d_info); - istringstream strm(p3d_info); + std::istringstream strm(p3d_info); TiXmlDocument doc; strm >> doc; if (strm.fail() && !strm.eof()) { diff --git a/direct/src/plugin_standalone/panda3dMac.cxx b/direct/src/plugin_standalone/panda3dMac.cxx index 06877b9af0..5a87c60d3e 100644 --- a/direct/src/plugin_standalone/panda3dMac.cxx +++ b/direct/src/plugin_standalone/panda3dMac.cxx @@ -16,7 +16,6 @@ #include #include -using namespace std; // Having a global Panda3DMac object just makes things easier. static Panda3DMac *this_prog; @@ -48,7 +47,7 @@ open_p3d_file(FSRef *ref) { UInt8 filename[buffer_size]; err = FSRefMakePath(ref, filename, buffer_size); if (err) { - cerr << "Couldn't get filename\n"; + std::cerr << "Couldn't get filename\n"; return; } diff --git a/direct/src/plugin_standalone/panda3dWinMain.cxx b/direct/src/plugin_standalone/panda3dWinMain.cxx index dbf951da4c..ec7b8e630c 100644 --- a/direct/src/plugin_standalone/panda3dWinMain.cxx +++ b/direct/src/plugin_standalone/panda3dWinMain.cxx @@ -22,7 +22,7 @@ static char * parse_quoted_arg(char *&p) { char quote = *p; ++p; - string result; + std::string result; while (*p != '\0' && *p != quote) { // TODO: handle escape characters? Not sure if we need to. @@ -39,7 +39,7 @@ parse_quoted_arg(char *&p) { // beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { - string result; + std::string result; while (*p != '\0' && !isspace(*p)) { result += *p; ++p; @@ -51,7 +51,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); - vector argv; + std::vector argv; char *p = command_line; while (*p != '\0') { diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index 5c449c6997..9e05daad3e 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -89,7 +89,7 @@ class Transitions: self.fade.setBin('unsorted', 0) self.fade.setColor(0,0,0,0) - def getFadeInIval(self, t=0.5, finishIval=None): + def getFadeInIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Returns an interval without starting it. This is particularly useful in cutscenes, so when the cutsceneIval is escaped out of we can finish the fade immediately @@ -103,6 +103,7 @@ class Transitions: self.lerpFunc(self.fade, t, self.alphaOff, # self.alphaOn, + blendType=blendType ), Func(self.fade.detachNode), name = self.fadeTaskName, @@ -111,7 +112,7 @@ class Transitions: transitionIval.append(finishIval) return transitionIval - def getFadeOutIval(self, t=0.5, finishIval=None): + def getFadeOutIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Create a sequence that lerps the color out, then parents the fade to hidden @@ -125,6 +126,7 @@ class Transitions: self.lerpFunc(self.fade, t, self.alphaOn, # self.alphaOff, + blendType=blendType ), name = self.fadeTaskName, ) @@ -132,7 +134,7 @@ class Transitions: transitionIval.append(finishIval) return transitionIval - def fadeIn(self, t=0.5, finishIval=None): + def fadeIn(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play a fade in transition over t seconds. Places a polygon on the aspect2d plane then lerps the color @@ -159,13 +161,13 @@ class Transitions: else: # Create a sequence that lerps the color out, then # parents the fade to hidden - self.transitionIval = self.getFadeInIval(t, finishIval) + self.transitionIval = self.getFadeInIval(t, finishIval, blendType) self.transitionIval.append(Func(self.__finishTransition)) self.__transitionFuture = AsyncFuture() self.transitionIval.start() return self.__transitionFuture - def fadeOut(self, t=0.5, finishIval=None): + def fadeOut(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play a fade out transition over t seconds. Places a polygon on the aspect2d plane then lerps the color @@ -189,7 +191,7 @@ class Transitions: else: # Create a sequence that lerps the color out, then # parents the fade to hidden - self.transitionIval = self.getFadeOutIval(t, finishIval) + self.transitionIval = self.getFadeOutIval(t, finishIval, blendType) self.transitionIval.append(Func(self.__finishTransition)) self.__transitionFuture = AsyncFuture() self.transitionIval.start() @@ -264,7 +266,7 @@ class Transitions: self.iris = loader.loadModel(self.IrisModelName) self.iris.setPos(0, 0, 0) - def irisIn(self, t=0.5, finishIval=None): + def irisIn(self, t=0.5, finishIval=None, blendType = 'noBlend'): """ Play an iris in transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale @@ -284,7 +286,8 @@ class Transitions: scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale = scale, - startScale = 0.01), + startScale = 0.01, + blendType=blendType), Func(self.iris.detachNode), Func(self.__finishTransition), name = self.irisTaskName, @@ -295,7 +298,7 @@ class Transitions: self.transitionIval.start() return self.__transitionFuture - def irisOut(self, t=0.5, finishIval=None): + def irisOut(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play an iris out transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale @@ -318,7 +321,8 @@ class Transitions: scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale = 0.01, - startScale = scale), + startScale = scale, + blendType=blendType), Func(self.iris.detachNode), # Use the fade to cover up the hole that the iris would leave Func(self.fadeOut, 0), @@ -441,7 +445,7 @@ class Transitions: self.__letterboxFuture.setResult(None) self.__letterboxFuture = None - def letterboxOn(self, t=0.25, finishIval=None): + def letterboxOn(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars in over t seconds. """ @@ -461,11 +465,13 @@ class Transitions: t, pos = Vec3(0, 0, -1), #startPos = Vec3(0, 0, -1.2), + blendType=blendType ), LerpPosInterval(self.letterboxTop, t, pos = Vec3(0, 0, 0.8), # startPos = Vec3(0, 0, 1), + blendType=blendType ), ), Func(self.__finishLetterbox), @@ -476,7 +482,7 @@ class Transitions: self.letterboxIval.start() return self.__letterboxFuture - def letterboxOff(self, t=0.25, finishIval=None): + def letterboxOff(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars away over t seconds. """ @@ -495,11 +501,13 @@ class Transitions: t, pos = Vec3(0, 0, -1.2), # startPos = Vec3(0, 0, -1), + blendType=blendType ), LerpPosInterval(self.letterboxTop, t, pos = Vec3(0, 0, 1), # startPos = Vec3(0, 0, 0.8), + blendType=blendType ), ), Func(self.letterbox.stash), diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index 12aa08d4bd..f14d9610a4 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -34,6 +34,9 @@ TOGGLEKEYS g_StartupToggleKeys = {sizeof(TOGGLEKEYS), 0}; FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; #endif +using std::max; +using std::min; + #if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_SHOWBASE) #error Buildsystem error: BUILDING_DIRECT_SHOWBASE not defined #endif @@ -201,7 +204,7 @@ add_grid_zone(unsigned int x, // zoneBase is the first zone in the grid (e.g. the upper left) // zoneResolution is the number of cells on each axsis. returns the next // available zoneBase (i.e. zoneBase+xZoneResolution*yZoneResolution) - cerr<<"adding grid zone with a zoneBase of "< 1.0 || y < 0.0 || y > 1.0) { return 0; } - cerr<<"resolution="<output(out, indent_level, scope, complete); out << "["; @@ -180,16 +180,16 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPArrayType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { - ostringstream brackets; +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { + std::ostringstream brackets; brackets << "["; if (_bounds != nullptr) { brackets << *_bounds; } brackets << "]"; - string bracketsstr = brackets.str(); + std::string bracketsstr = brackets.str(); _element_type->output_instance(out, indent_level, scope, complete, prename, name + bracketsstr); diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index f1985d488e..be3f2b4e95 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.0.5. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.0.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -97,19 +97,22 @@ #include "cppNamespace.h" #include "cppUsing.h" +using std::stringstream; +using std::string; + //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -CPPScope *current_scope = NULL; -CPPScope *global_scope = NULL; -CPPPreprocessor *current_lexer = NULL; +CPPScope *current_scope = nullptr; +CPPScope *global_scope = nullptr; +CPPPreprocessor *current_lexer = nullptr; -static CPPStructType *current_struct = NULL; -static CPPEnumType *current_enum = NULL; +static CPPStructType *current_struct = nullptr; +static CPPEnumType *current_enum = nullptr; static int current_storage_class = 0; -static CPPType *current_type = NULL; -static CPPExpression *current_expr = NULL; +static CPPType *current_type = nullptr; +static CPPExpression *current_expr = nullptr; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; @@ -183,7 +186,7 @@ parse_const_expr(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_expr = (CPPExpression *)NULL; + current_expr = nullptr; current_lexer = pp; yyparse(); @@ -207,7 +210,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_type = (CPPType *)NULL; + current_type = nullptr; current_lexer = pp; yyparse(); @@ -224,7 +227,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, static void push_scope(CPPScope *new_scope) { last_scopes.push_back(current_scope); - if (new_scope != NULL) { + if (new_scope != nullptr) { current_scope = new_scope; } } @@ -263,7 +266,7 @@ pop_struct() { } -#line 268 "built/tmp/cppBison.yxx.c" /* yacc.c:339 */ +#line 270 "built/tmp/cppBison.yxx.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -614,7 +617,7 @@ int cppyyparse (void); /* Copy the second part of user declarations. */ -#line 619 "built/tmp/cppBison.yxx.c" /* yacc.c:358 */ +#line 621 "built/tmp/cppBison.yxx.c" /* yacc.c:358 */ #ifdef short # undef short @@ -928,83 +931,83 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 450, 450, 451, 455, 462, 463, 464, 468, 469, - 473, 477, 481, 494, 493, 505, 506, 507, 508, 509, - 510, 511, 524, 533, 537, 545, 549, 553, 574, 601, - 622, 651, 687, 730, 742, 763, 799, 833, 855, 891, - 913, 924, 938, 937, 952, 956, 961, 965, 976, 980, - 984, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, - 1025, 1029, 1036, 1037, 1041, 1042, 1043, 1048, 1047, 1063, - 1073, 1072, 1089, 1097, 1105, 1116, 1132, 1131, 1146, 1161, - 1170, 1185, 1184, 1209, 1208, 1236, 1235, 1266, 1265, 1284, - 1283, 1304, 1303, 1335, 1334, 1360, 1373, 1377, 1381, 1385, - 1398, 1402, 1406, 1410, 1414, 1419, 1424, 1428, 1432, 1436, - 1443, 1447, 1451, 1455, 1459, 1463, 1467, 1471, 1475, 1479, - 1483, 1487, 1491, 1495, 1499, 1503, 1507, 1511, 1515, 1519, - 1523, 1527, 1531, 1535, 1539, 1543, 1547, 1551, 1555, 1559, - 1563, 1567, 1571, 1575, 1579, 1583, 1587, 1591, 1595, 1602, - 1603, 1604, 1608, 1610, 1609, 1617, 1618, 1622, 1623, 1627, - 1633, 1642, 1643, 1647, 1651, 1655, 1659, 1665, 1671, 1677, - 1684, 1689, 1698, 1702, 1707, 1715, 1727, 1731, 1745, 1760, - 1765, 1770, 1775, 1780, 1785, 1790, 1795, 1801, 1800, 1831, - 1841, 1851, 1855, 1859, 1868, 1872, 1880, 1884, 1889, 1893, - 1898, 1906, 1911, 1919, 1923, 1928, 1932, 1937, 1945, 1950, - 1958, 1962, 1969, 1973, 1980, 1984, 1988, 1992, 1996, 2003, - 2007, 2011, 2015, 2019, 2023, 2030, 2031, 2032, 2036, 2039, - 2040, 2041, 2045, 2050, 2056, 2062, 2067, 2073, 2079, 2083, - 2094, 2098, 2108, 2112, 2116, 2121, 2126, 2131, 2136, 2141, - 2146, 2154, 2158, 2162, 2167, 2172, 2177, 2182, 2187, 2192, - 2197, 2203, 2211, 2216, 2221, 2226, 2231, 2236, 2241, 2246, - 2251, 2256, 2262, 2270, 2274, 2279, 2284, 2289, 2294, 2299, - 2304, 2309, 2314, 2322, 2326, 2331, 2336, 2341, 2346, 2351, - 2356, 2361, 2366, 2371, 2377, 2384, 2391, 2401, 2405, 2413, - 2417, 2421, 2425, 2429, 2445, 2461, 2470, 2474, 2484, 2491, - 2502, 2506, 2514, 2518, 2522, 2526, 2530, 2546, 2562, 2580, - 2589, 2593, 2603, 2610, 2614, 2622, 2626, 2642, 2658, 2667, - 2677, 2684, 2688, 2696, 2700, 2705, 2709, 2717, 2718, 2719, - 2720, 2725, 2724, 2749, 2748, 2778, 2779, 2786, 2787, 2791, - 2792, 2796, 2800, 2804, 2808, 2812, 2816, 2820, 2824, 2828, - 2832, 2839, 2847, 2851, 2855, 2860, 2868, 2872, 2879, 2880, - 2885, 2892, 2893, 2898, 2906, 2910, 2914, 2921, 2925, 2929, - 2937, 2936, 2959, 2958, 2981, 2982, 2986, 2992, 2999, 3008, - 3009, 3010, 3014, 3018, 3022, 3026, 3030, 3034, 3039, 3044, - 3049, 3054, 3058, 3063, 3072, 3077, 3085, 3089, 3093, 3101, - 3111, 3111, 3121, 3122, 3126, 3127, 3128, 3129, 3130, 3131, - 3132, 3133, 3134, 3135, 3136, 3137, 3137, 3137, 3138, 3138, - 3138, 3138, 3139, 3139, 3139, 3139, 3139, 3140, 3140, 3140, - 3141, 3141, 3141, 3141, 3141, 3142, 3142, 3142, 3142, 3142, - 3143, 3143, 3144, 3144, 3144, 3144, 3144, 3145, 3145, 3145, - 3145, 3145, 3146, 3146, 3146, 3146, 3147, 3147, 3147, 3147, - 3147, 3148, 3148, 3148, 3148, 3148, 3149, 3149, 3149, 3149, - 3149, 3149, 3150, 3150, 3150, 3150, 3150, 3151, 3151, 3151, - 3151, 3152, 3152, 3152, 3152, 3153, 3153, 3153, 3153, 3153, - 3154, 3154, 3154, 3154, 3155, 3155, 3155, 3155, 3155, 3156, - 3156, 3156, 3156, 3157, 3157, 3157, 3157, 3157, 3158, 3158, - 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, - 3161, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, - 3162, 3163, 3163, 3167, 3171, 3178, 3182, 3189, 3193, 3200, - 3204, 3208, 3212, 3216, 3220, 3224, 3228, 3240, 3244, 3248, - 3252, 3256, 3260, 3264, 3268, 3272, 3276, 3280, 3284, 3288, - 3292, 3296, 3300, 3304, 3308, 3312, 3316, 3320, 3324, 3328, - 3332, 3336, 3340, 3344, 3348, 3352, 3356, 3360, 3368, 3372, - 3376, 3380, 3384, 3388, 3392, 3402, 3412, 3418, 3424, 3430, - 3436, 3442, 3448, 3455, 3462, 3469, 3476, 3482, 3488, 3492, - 3504, 3508, 3512, 3516, 3520, 3531, 3542, 3546, 3550, 3554, - 3558, 3562, 3566, 3570, 3574, 3578, 3582, 3586, 3590, 3594, - 3598, 3602, 3606, 3610, 3614, 3618, 3622, 3626, 3630, 3634, - 3638, 3642, 3646, 3650, 3654, 3658, 3662, 3669, 3673, 3677, - 3681, 3685, 3689, 3693, 3697, 3701, 3707, 3713, 3717, 3723, - 3730, 3734, 3738, 3742, 3746, 3750, 3754, 3758, 3762, 3766, - 3770, 3774, 3778, 3782, 3786, 3790, 3794, 3808, 3812, 3816, - 3820, 3824, 3828, 3832, 3836, 3848, 3852, 3856, 3860, 3864, - 3875, 3886, 3890, 3894, 3898, 3902, 3906, 3910, 3914, 3918, - 3922, 3926, 3930, 3934, 3938, 3942, 3946, 3950, 3954, 3958, - 3962, 3966, 3970, 3974, 3978, 3982, 3986, 3990, 3994, 3998, - 4002, 4009, 4013, 4017, 4021, 4025, 4029, 4033, 4037, 4041, - 4047, 4053, 4061, 4065, 4069, 4073, 4080, 4090, 4096, 4102, - 4112, 4124, 4132, 4136, 4166, 4170, 4174, 4178, 4182, 4186, - 4192, 4196, 4200, 4204, 4208, 4219, 4223, 4227, 4231, 4239, - 4243, 4247, 4253, 4264 + 0, 452, 452, 453, 457, 464, 465, 466, 470, 471, + 475, 479, 483, 496, 495, 507, 508, 509, 510, 511, + 512, 513, 526, 535, 539, 547, 551, 555, 576, 603, + 624, 653, 689, 732, 744, 765, 801, 835, 857, 893, + 915, 926, 940, 939, 954, 958, 963, 967, 978, 982, + 986, 990, 994, 998, 1002, 1006, 1010, 1014, 1018, 1022, + 1027, 1031, 1038, 1039, 1043, 1044, 1045, 1050, 1049, 1065, + 1075, 1074, 1091, 1099, 1107, 1118, 1134, 1133, 1148, 1163, + 1172, 1187, 1186, 1224, 1223, 1260, 1259, 1290, 1289, 1308, + 1307, 1328, 1327, 1359, 1358, 1384, 1397, 1401, 1405, 1409, + 1422, 1426, 1430, 1434, 1438, 1443, 1448, 1452, 1456, 1460, + 1467, 1471, 1475, 1479, 1483, 1487, 1491, 1495, 1499, 1503, + 1507, 1511, 1515, 1519, 1523, 1527, 1531, 1535, 1539, 1543, + 1547, 1551, 1555, 1559, 1563, 1567, 1571, 1575, 1579, 1583, + 1587, 1591, 1595, 1599, 1603, 1607, 1611, 1615, 1619, 1626, + 1627, 1628, 1632, 1634, 1633, 1641, 1642, 1646, 1647, 1651, + 1657, 1666, 1667, 1671, 1675, 1679, 1683, 1689, 1695, 1701, + 1708, 1713, 1722, 1726, 1731, 1739, 1751, 1755, 1769, 1784, + 1789, 1794, 1799, 1804, 1809, 1814, 1819, 1825, 1824, 1855, + 1865, 1875, 1879, 1883, 1892, 1896, 1904, 1908, 1913, 1917, + 1922, 1930, 1935, 1943, 1947, 1952, 1956, 1961, 1969, 1974, + 1982, 1986, 1993, 1997, 2004, 2008, 2012, 2016, 2020, 2027, + 2031, 2035, 2039, 2043, 2047, 2054, 2055, 2056, 2060, 2063, + 2064, 2065, 2069, 2074, 2080, 2086, 2091, 2097, 2103, 2107, + 2118, 2122, 2132, 2136, 2140, 2145, 2150, 2155, 2160, 2165, + 2170, 2178, 2182, 2186, 2191, 2196, 2201, 2206, 2211, 2216, + 2221, 2227, 2235, 2240, 2245, 2250, 2255, 2260, 2265, 2270, + 2275, 2280, 2286, 2294, 2298, 2303, 2308, 2313, 2318, 2323, + 2328, 2333, 2338, 2346, 2350, 2355, 2360, 2365, 2370, 2375, + 2380, 2385, 2390, 2395, 2401, 2408, 2415, 2425, 2429, 2437, + 2441, 2445, 2449, 2453, 2469, 2485, 2494, 2498, 2508, 2515, + 2526, 2530, 2538, 2542, 2546, 2550, 2554, 2570, 2586, 2604, + 2613, 2617, 2627, 2634, 2638, 2646, 2650, 2666, 2682, 2691, + 2701, 2708, 2712, 2720, 2724, 2729, 2733, 2741, 2742, 2743, + 2744, 2749, 2748, 2773, 2772, 2802, 2803, 2810, 2811, 2815, + 2816, 2820, 2824, 2828, 2832, 2836, 2840, 2844, 2848, 2852, + 2856, 2863, 2871, 2875, 2879, 2884, 2892, 2896, 2903, 2904, + 2909, 2916, 2917, 2922, 2930, 2934, 2938, 2945, 2949, 2953, + 2961, 2960, 2983, 2982, 3005, 3006, 3010, 3016, 3023, 3032, + 3033, 3034, 3038, 3042, 3046, 3050, 3054, 3058, 3063, 3068, + 3073, 3078, 3082, 3087, 3096, 3101, 3109, 3113, 3117, 3125, + 3135, 3135, 3145, 3146, 3150, 3151, 3152, 3153, 3154, 3155, + 3156, 3157, 3158, 3159, 3160, 3161, 3161, 3161, 3162, 3162, + 3162, 3162, 3163, 3163, 3163, 3163, 3163, 3164, 3164, 3164, + 3165, 3165, 3165, 3165, 3165, 3166, 3166, 3166, 3166, 3166, + 3167, 3167, 3168, 3168, 3168, 3168, 3168, 3169, 3169, 3169, + 3169, 3169, 3170, 3170, 3170, 3170, 3171, 3171, 3171, 3171, + 3171, 3172, 3172, 3172, 3172, 3172, 3173, 3173, 3173, 3173, + 3173, 3173, 3174, 3174, 3174, 3174, 3174, 3175, 3175, 3175, + 3175, 3176, 3176, 3176, 3176, 3177, 3177, 3177, 3177, 3177, + 3178, 3178, 3178, 3178, 3179, 3179, 3179, 3179, 3179, 3180, + 3180, 3180, 3180, 3181, 3181, 3181, 3181, 3181, 3182, 3182, + 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, + 3185, 3186, 3186, 3186, 3186, 3186, 3186, 3186, 3186, 3186, + 3186, 3187, 3187, 3191, 3195, 3202, 3206, 3213, 3217, 3224, + 3228, 3232, 3236, 3240, 3244, 3248, 3252, 3264, 3268, 3272, + 3276, 3280, 3284, 3288, 3292, 3296, 3300, 3304, 3308, 3312, + 3316, 3320, 3324, 3328, 3332, 3336, 3340, 3344, 3348, 3352, + 3356, 3360, 3364, 3368, 3372, 3376, 3380, 3384, 3392, 3396, + 3400, 3404, 3408, 3412, 3416, 3426, 3436, 3442, 3448, 3454, + 3460, 3466, 3472, 3479, 3486, 3493, 3500, 3506, 3512, 3516, + 3528, 3532, 3536, 3540, 3544, 3555, 3566, 3570, 3574, 3578, + 3582, 3586, 3590, 3594, 3598, 3602, 3606, 3610, 3614, 3618, + 3622, 3626, 3630, 3634, 3638, 3642, 3646, 3650, 3654, 3658, + 3662, 3666, 3670, 3674, 3678, 3682, 3686, 3693, 3697, 3701, + 3705, 3709, 3713, 3717, 3721, 3725, 3731, 3737, 3741, 3747, + 3754, 3758, 3762, 3766, 3770, 3774, 3778, 3782, 3786, 3790, + 3794, 3798, 3802, 3806, 3810, 3814, 3818, 3832, 3836, 3840, + 3844, 3848, 3852, 3856, 3860, 3872, 3876, 3880, 3884, 3888, + 3899, 3910, 3914, 3918, 3922, 3926, 3930, 3934, 3938, 3942, + 3946, 3950, 3954, 3958, 3962, 3966, 3970, 3974, 3978, 3982, + 3986, 3990, 3994, 3998, 4002, 4006, 4010, 4014, 4018, 4022, + 4026, 4033, 4037, 4041, 4045, 4049, 4053, 4057, 4061, 4065, + 4071, 4077, 4085, 4089, 4093, 4097, 4104, 4114, 4120, 4126, + 4136, 4148, 4156, 4160, 4190, 4194, 4198, 4202, 4206, 4210, + 4216, 4220, 4224, 4228, 4232, 4243, 4247, 4251, 4255, 4263, + 4267, 4271, 4277, 4288 }; #endif @@ -3670,6 +3673,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -4011,70 +4015,71 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; - /* Default location. */ + /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc; YY_REDUCE_PRINT (yyn); switch (yyn) { case 3: -#line 452 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 454 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_expr = (yyvsp[0].u.expr); } -#line 4026 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4030 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 4: -#line 456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 458 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_type = (yyvsp[0].u.type); } -#line 4034 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4038 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 10: -#line 474 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-1].u.expr); } -#line 4042 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4046 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 11: -#line 478 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-2].u.expr); } -#line 4050 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4054 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 12: -#line 482 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-1].u.expr); } -#line 4058 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4062 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 13: -#line 494 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_storage_class((current_storage_class & ~CPPInstance::SC_c_binding) | ((yyvsp[-1].u.integer) & CPPInstance::SC_c_binding)); } -#line 4067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4071 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 14: -#line 499 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 501 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4075 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4079 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 21: -#line 512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 514 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level != 0) { yyerror("Unclosed __begin_publish", publish_loc); @@ -4087,11 +4092,11 @@ yyreduce: publish_nest_level++; current_scope->set_current_vis(V_published); } -#line 4092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4096 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 22: -#line 525 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level != 1) { yyerror("Unmatched __end_publish", (yylsp[0])); @@ -4100,19 +4105,19 @@ yyreduce: } publish_nest_level = 0; } -#line 4105 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4109 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 23: -#line 534 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_published); } -#line 4113 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4117 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 24: -#line 538 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level > 0) { current_scope->set_current_vis(V_published); @@ -4120,27 +4125,27 @@ yyreduce: current_scope->set_current_vis(V_public); } } -#line 4125 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4129 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 25: -#line 546 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_protected); } -#line 4133 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4137 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 26: -#line 550 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_private); } -#line 4141 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4145 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 27: -#line 554 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-3].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4161,11 +4166,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-7])); } } -#line 4166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4170 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 28: -#line 575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 577 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4192,11 +4197,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-10])); } } -#line 4197 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4201 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 29: -#line 602 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4217,11 +4222,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4222 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4226 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 30: -#line 623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 625 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4250,16 +4255,16 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-10])); } } -#line 4255 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4259 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 31: -#line 652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 654 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-8].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-8].u.identifier)->get_fully_scoped_name(), (yylsp[-8])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4290,16 +4295,16 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-12])); } } -#line 4295 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4299 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 32: -#line 688 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-10].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-10].u.identifier)->get_fully_scoped_name(), (yylsp[-10])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = (yyvsp[-8].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4337,11 +4342,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-14])); } } -#line 4342 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4346 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 33: -#line 731 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 733 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4353,11 +4358,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-6])); } } -#line 4358 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4362 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 34: -#line 743 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 745 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4378,11 +4383,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4383 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4387 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 35: -#line 764 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 766 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-5].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4418,11 +4423,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-11])); } } -#line 4423 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4427 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 36: -#line 800 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 802 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4456,11 +4461,11 @@ yyreduce: } } } -#line 4461 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4465 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 37: -#line 834 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 836 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4482,11 +4487,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4487 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4491 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 38: -#line 856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 858 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4522,25 +4527,25 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-12])); } } -#line 4527 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4531 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 39: -#line 892 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-4].u.identifier)->get_fully_scoped_name(), (yylsp[-4])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *element_getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (element_getter == (CPPDeclaration *)NULL || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (element_getter == nullptr || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid element method: " + (yyvsp[-2].u.identifier)->get_fully_scoped_name(), (yylsp[-4])); - element_getter = NULL; + element_getter = nullptr; } - if (length_getter != (CPPDeclaration *)NULL && element_getter != (CPPDeclaration *)NULL) { + if (length_getter != nullptr && element_getter != nullptr) { CPPMakeSeq *make_seq = new CPPMakeSeq((yyvsp[-6].u.identifier), length_getter->as_function_group(), element_getter->as_function_group(), @@ -4548,11 +4553,11 @@ yyreduce: current_scope->add_declaration(make_seq, global_scope, current_lexer, (yylsp[-8])); } } -#line 4553 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4557 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 40: -#line 914 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 916 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPExpression::Result result = (yyvsp[-4].u.expr)->evaluate(); if (result._type == CPPExpression::RT_error) { @@ -4563,11 +4568,11 @@ yyreduce: yywarning("static_assert failed: " + str.str(), (yylsp[-4])); } } -#line 4568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4572 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 41: -#line 925 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This alternative version of static_assert was introduced in C++17. CPPExpression::Result result = (yyvsp[-2].u.expr)->evaluate(); @@ -4577,55 +4582,55 @@ yyreduce: yywarning("static_assert failed", (yylsp[-2])); } } -#line 4582 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 42: -#line 938 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 940 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("temp"), V_public); push_scope(new_scope); } -#line 4592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 43: -#line 944 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete current_scope; pop_scope(); } -#line 4601 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4605 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 44: -#line 953 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = 0; } -#line 4609 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4613 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 45: -#line 957 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This isn't really a storage class, but it helps with parsing. (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_const; } -#line 4618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4622 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 46: -#line 962 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 964 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extern; } -#line 4626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4630 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 47: -#line 966 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 968 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extern; if ((yyvsp[-1].str) == "C") { @@ -4636,124 +4641,124 @@ yyreduce: yywarning("Ignoring unknown linkage type \"" + (yyvsp[-1].str) + "\"", (yylsp[-1])); } } -#line 4641 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4645 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 48: -#line 977 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_static; } -#line 4649 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4653 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 49: -#line 981 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_inline; } -#line 4657 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4661 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 50: -#line 985 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_virtual; } -#line 4665 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4669 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 51: -#line 989 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_explicit; } -#line 4673 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4677 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 52: -#line 993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_register; } -#line 4681 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4685 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 53: -#line 997 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_volatile; } -#line 4689 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4693 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 54: -#line 1001 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_mutable; } -#line 4697 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4701 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 55: -#line 1005 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1007 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_constexpr; } -#line 4705 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4709 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 56: -#line 1009 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_blocking; } -#line 4713 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4717 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 57: -#line 1013 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extension; } -#line 4721 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4725 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 58: -#line 1017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_thread_local; } -#line 4729 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4733 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 59: -#line 1021 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Ignore attribute specifiers for now. (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4738 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4742 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 60: -#line 1026 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1028 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 61: -#line 1030 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1032 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4754 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4758 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 67: -#line 1048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We don't need to push/pop type, because we can't nest // type_like_declaration. @@ -4764,19 +4769,19 @@ yyreduce: } push_storage_class((yyvsp[-1].u.integer)); } -#line 4769 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4773 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 68: -#line 1059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1061 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4777 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4781 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 69: -#line 1064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // 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 @@ -4785,48 +4790,48 @@ yyreduce: current_scope->add_declaration((yyvsp[-1].u.decl), global_scope, current_lexer, (yylsp[-1])); } -#line 4790 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4794 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 70: -#line 1073 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1075 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[0].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[0].u.instance) != nullptr) { // Push the scope so that the initializers can make use of things defined // in the class body. push_scope((yyvsp[0].u.instance)->get_scope(current_scope, global_scope)); (yyvsp[0].u.instance)->_storage_class |= (current_storage_class | (yyvsp[-1].u.integer)); } } -#line 4803 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4807 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 71: -#line 1082 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1084 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-2].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[-2].u.instance) != nullptr) { pop_scope(); current_scope->add_declaration((yyvsp[-2].u.instance), global_scope, current_lexer, (yylsp[-2])); (yyvsp[-2].u.instance)->set_initializer((yyvsp[0].u.expr)); } } -#line 4815 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4819 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 72: -#line 1090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1092 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-1].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[-1].u.instance) != nullptr) { (yyvsp[-1].u.instance)->_storage_class |= (current_storage_class | (yyvsp[-2].u.integer)); current_scope->add_declaration((yyvsp[-1].u.instance), global_scope, current_lexer, (yylsp[-1])); (yyvsp[-1].u.instance)->set_initializer((yyvsp[0].u.expr)); } } -#line 4827 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4831 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 74: -#line 1106 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1108 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); @@ -4837,11 +4842,11 @@ yyreduce: inst->set_initializer((yyvsp[0].u.expr)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-1])); } -#line 4842 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4846 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 75: -#line 1117 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1119 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-3].u.inst_ident)->add_modifier(IIT_const); @@ -4852,11 +4857,11 @@ yyreduce: inst->set_initializer((yyvsp[-2].u.expr)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-3])); } -#line 4857 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4861 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 76: -#line 1132 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1134 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -4867,23 +4872,23 @@ yyreduce: } push_storage_class((yyvsp[-1].u.integer)); } -#line 4872 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4876 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 77: -#line 1143 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1145 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4880 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4884 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 78: -#line 1147 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1149 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-1].u.instance) != (CPPDeclaration *)NULL) { + if ((yyvsp[-1].u.instance) != nullptr) { CPPInstance *inst = (yyvsp[-1].u.instance)->as_instance(); - if (inst != (CPPInstance *)NULL) { + if (inst != nullptr) { inst->_storage_class |= (current_storage_class | (yyvsp[-2].u.integer)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-1])); CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); @@ -4891,11 +4896,11 @@ yyreduce: } } } -#line 4896 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4900 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 79: -#line 1162 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1164 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); @@ -4904,11 +4909,11 @@ yyreduce: CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[-1].u.inst_ident), current_scope, (yylsp[-1]).file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-1])); } -#line 4909 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4913 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 80: -#line 1171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1173 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-3].u.inst_ident)->add_modifier(IIT_const); @@ -4917,24 +4922,37 @@ yyreduce: CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[-3].u.inst_ident), current_scope, (yylsp[-3]).file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-3])); } -#line 4922 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4926 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 81: -#line 1185 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope), + (yyvsp[-1].u.identifier)->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } -#line 4930 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4943 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 82: -#line 1189 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1200 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { + CPPScope *scope = (yyvsp[-5].u.identifier)->get_scope(current_scope, global_scope); CPPType *type; - if ((yyvsp[-5].u.identifier)->get_simple_name() == current_scope->get_simple_name() || - (yyvsp[-5].u.identifier)->get_simple_name() == string("~") + current_scope->get_simple_name()) { - // This is a constructor, and has no return. + std::string simple_name = (yyvsp[-5].u.identifier)->get_simple_name(); + if (!simple_name.empty() && simple_name[0] == '~') { + // A destructor has no return type. + type = new CPPSimpleType(CPPSimpleType::T_void); + } else if (scope != nullptr && simple_name == scope->get_simple_name()) { + // Neither does a constructor. type = new CPPSimpleType(CPPSimpleType::T_void); } else { // This isn't a constructor, so it has an implicit return type of @@ -4949,19 +4967,28 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } -#line 4954 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4971 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 83: -#line 1209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1224 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope), + (yyvsp[-1].u.identifier)->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } -#line 4962 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4988 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 84: -#line 1213 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type; @@ -4979,19 +5006,19 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } -#line 4984 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5010 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 85: -#line 1236 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1260 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); } -#line 4992 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5018 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 86: -#line 1240 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1264 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); if ((yyvsp[-5].u.identifier)->is_scoped()) { @@ -5010,75 +5037,75 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } } -#line 5015 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5041 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 87: -#line 1266 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1290 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-2].u.inst_ident)->get_scope(current_scope, global_scope)); } -#line 5023 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5049 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 88: -#line 1270 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1294 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type = (yyvsp[-10].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-10].u.identifier)->get_fully_scoped_name(), (yylsp[-10])); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = (yyvsp[-7].u.inst_ident); ii->add_modifier(IIT_pointer); ii->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer)); (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-10]).file); } -#line 5041 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5067 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 89: -#line 1284 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1308 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-2].u.inst_ident)->get_scope(current_scope, global_scope)); } -#line 5049 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5075 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 90: -#line 1288 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1312 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type = (yyvsp[-11].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-11].u.identifier)->get_fully_scoped_name(), (yylsp[-11])); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = (yyvsp[-7].u.inst_ident); ii->add_scoped_pointer_modifier((yyvsp[-9].u.identifier)); ii->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer)); (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-11]).file); } -#line 5067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 91: -#line 1304 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1328 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-3].u.identifier) != NULL) { + if ((yyvsp[-3].u.identifier) != nullptr) { push_scope((yyvsp[-3].u.identifier)->get_scope(current_scope, global_scope)); } } -#line 5077 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5103 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 92: -#line 1310 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1334 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-7].u.identifier) != NULL) { + if ((yyvsp[-7].u.identifier) != nullptr) { pop_scope(); } @@ -5093,7 +5120,7 @@ yyreduce: // the method's return type to determine the full type description. string name = "operator typecast " + (yyvsp[-6].u.type)->get_simple_name(); CPPIdentifier *ident = (yyvsp[-7].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier(name, (yylsp[-6])); } else { ident->add_name(name); @@ -5101,28 +5128,28 @@ yyreduce: (yyval.u.instance) = CPPInstance::make_typecast_function (new CPPInstance((yyvsp[-6].u.type), (yyvsp[-5].u.inst_ident), 0, (yylsp[-5]).file), ident, (yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 5106 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5132 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 93: -#line 1335 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1359 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-4].u.identifier) != NULL) { + if ((yyvsp[-4].u.identifier) != nullptr) { push_scope((yyvsp[-4].u.identifier)->get_scope(current_scope, global_scope)); } } -#line 5116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 94: -#line 1341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1365 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-8].u.identifier) != NULL) { + if ((yyvsp[-8].u.identifier) != nullptr) { pop_scope(); } CPPIdentifier *ident = (yyvsp[-8].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator typecast", (yylsp[-5])); } else { ident->add_name("operator typecast"); @@ -5131,626 +5158,626 @@ yyreduce: (yyval.u.instance) = CPPInstance::make_typecast_function (new CPPInstance((yyvsp[-6].u.type), (yyvsp[-5].u.inst_ident), 0, (yylsp[-5]).file), ident, (yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 5136 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5162 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 95: -#line 1361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *decl = (yyvsp[0].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (decl != (CPPDeclaration *)NULL) { + if (decl != nullptr) { (yyval.u.instance) = decl->as_instance(); } else { - (yyval.u.instance) = (CPPInstance *)NULL; + (yyval.u.instance) = nullptr; } } -#line 5150 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5176 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 96: -#line 1374 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1398 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = 0; } -#line 5158 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5184 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 97: -#line 1378 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_const_method; } -#line 5166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5192 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 98: -#line 1382 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1406 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_volatile_method; } -#line 5174 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5200 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 99: -#line 1386 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1410 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_noexcept; } -#line 5182 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5208 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 100: -#line 1399 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1423 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_final; } -#line 5190 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5216 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 101: -#line 1403 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1427 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_override; } -#line 5198 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5224 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 102: -#line 1407 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1431 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_lvalue_method; } -#line 5206 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5232 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 103: -#line 1411 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1435 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_rvalue_method; } -#line 5214 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5240 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 104: -#line 1415 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1439 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Used for lambdas, currently ignored. (yyval.u.integer) = (yyvsp[-1].u.integer); } -#line 5223 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5249 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 105: -#line 1420 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1444 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Used for lambdas in C++17, currently ignored. (yyval.u.integer) = (yyvsp[-1].u.integer); } -#line 5232 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5258 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 106: -#line 1425 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-3].u.integer); } -#line 5240 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5266 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 107: -#line 1429 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1453 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-4].u.integer); } -#line 5248 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5274 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 108: -#line 1433 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1457 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-5].u.integer); } -#line 5256 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5282 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 109: -#line 1437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1461 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-3].u.integer); } -#line 5264 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5290 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 110: -#line 1444 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1468 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "!"; } -#line 5272 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5298 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 111: -#line 1448 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1472 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "~"; } -#line 5280 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5306 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 112: -#line 1452 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "*"; } -#line 5288 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5314 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 113: -#line 1456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "/"; } -#line 5296 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5322 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 114: -#line 1460 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "%"; } -#line 5304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 115: -#line 1464 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1488 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "+"; } -#line 5312 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5338 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 116: -#line 1468 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "-"; } -#line 5320 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5346 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 117: -#line 1472 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "|"; } -#line 5328 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5354 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 118: -#line 1476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1500 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&"; } -#line 5336 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5362 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 119: -#line 1480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1504 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "^"; } -#line 5344 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5370 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 120: -#line 1484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1508 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "||"; } -#line 5352 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5378 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 121: -#line 1488 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&&"; } -#line 5360 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5386 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 122: -#line 1492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "=="; } -#line 5368 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5394 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 123: -#line 1496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1520 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "!="; } -#line 5376 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5402 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 124: -#line 1500 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1524 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<="; } -#line 5384 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5410 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 125: -#line 1504 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1528 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">="; } -#line 5392 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5418 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 126: -#line 1508 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<"; } -#line 5400 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5426 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 127: -#line 1512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">"; } -#line 5408 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5434 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 128: -#line 1516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<<"; } -#line 5416 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5442 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 129: -#line 1520 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1544 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">>"; } -#line 5424 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5450 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 130: -#line 1524 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "="; } -#line 5432 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5458 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 131: -#line 1528 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ","; } -#line 5440 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5466 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 132: -#line 1532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "++"; } -#line 5448 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5474 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 133: -#line 1536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1560 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "--"; } -#line 5456 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5482 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 134: -#line 1540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1564 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "*="; } -#line 5464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 135: -#line 1544 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1568 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "/="; } -#line 5472 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5498 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 136: -#line 1548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1572 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "%="; } -#line 5480 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5506 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 137: -#line 1552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1576 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "+="; } -#line 5488 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5514 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 138: -#line 1556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1580 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "-="; } -#line 5496 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5522 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 139: -#line 1560 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1584 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "|="; } -#line 5504 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5530 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 140: -#line 1564 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1588 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&="; } -#line 5512 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5538 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 141: -#line 1568 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1592 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "^="; } -#line 5520 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5546 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 142: -#line 1572 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1596 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<<="; } -#line 5528 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5554 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 143: -#line 1576 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1600 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">>="; } -#line 5536 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5562 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 144: -#line 1580 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "->"; } -#line 5544 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5570 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 145: -#line 1584 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1608 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "[]"; } -#line 5552 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5578 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 146: -#line 1588 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1612 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "()"; } -#line 5560 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 147: -#line 1592 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1616 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "new"; } -#line 5568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5594 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 148: -#line 1596 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1620 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "delete"; } -#line 5576 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5602 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 153: -#line 1610 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1634 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope(new CPPTemplateScope(current_scope)); } -#line 5584 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5610 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 154: -#line 1614 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1638 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 5592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5618 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 159: -#line 1628 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter((yyvsp[0].u.decl)); } -#line 5602 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5628 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 160: -#line 1634 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1658 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter((yyvsp[0].u.decl)); } -#line 5612 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5638 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 163: -#line 1648 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1672 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((CPPIdentifier *)NULL)); + (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter(nullptr)); } -#line 5620 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5646 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 164: -#line 1652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1676 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[0].u.identifier))); } -#line 5628 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5654 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 165: -#line 1656 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1680 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[-2].u.identifier), (yyvsp[0].u.type))); } -#line 5636 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5662 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 166: -#line 1660 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1684 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((CPPIdentifier *)NULL); + CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter(nullptr); ctp->_packed = true; (yyval.u.decl) = CPPType::new_type(ctp); } -#line 5646 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5672 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 167: -#line 1666 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((yyvsp[0].u.identifier)); ctp->_packed = true; (yyval.u.decl) = CPPType::new_type(ctp); } -#line 5656 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5682 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 168: -#line 1672 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1696 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPInstance *inst = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); inst->set_initializer((yyvsp[0].u.expr)); (yyval.u.decl) = inst; } -#line 5666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 169: -#line 1678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); inst->set_initializer((yyvsp[0].u.expr)); (yyval.u.decl) = inst; } -#line 5677 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5703 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 170: -#line 1685 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1709 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPInstance *inst = new CPPInstance((yyvsp[-1].u.type), (yyvsp[0].u.inst_ident), 0, (yylsp[0]).file); (yyval.u.decl) = inst; } -#line 5686 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5712 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 171: -#line 1690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[-1].u.type), (yyvsp[0].u.inst_ident), 0, (yylsp[0]).file); (yyval.u.decl) = inst; } -#line 5696 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5722 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 172: -#line 1699 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1723 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 5704 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5730 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 173: -#line 1703 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1727 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yywarning("Not a type: " + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); } -#line 5713 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5739 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 174: -#line 1708 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 5725 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5751 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 175: -#line 1716 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1740 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 5737 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5763 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 176: -#line 1728 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1752 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 5745 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5771 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 177: -#line 1732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1756 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // For an operator function. We implement this simply by building a // ficticious name for the function; in other respects it's just // like a regular function. CPPIdentifier *ident = (yyvsp[-1].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator "+(yyvsp[0].str), (yylsp[0])); } else { ident->_names.push_back("operator "+(yyvsp[0].str)); @@ -5758,18 +5785,18 @@ yyreduce: (yyval.u.inst_ident) = new CPPInstanceIdentifier(ident); } -#line 5763 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5789 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 178: -#line 1746 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1770 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A C++11 literal operator. if (!(yyvsp[-1].str).empty()) { yyerror("expected empty string", (yylsp[-1])); } CPPIdentifier *ident = (yyvsp[-2].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator \"\" "+(yyvsp[0].u.identifier)->get_simple_name(), (yylsp[0])); } else { ident->_names.push_back("operator \"\" "+(yyvsp[0].u.identifier)->get_simple_name()); @@ -5777,83 +5804,83 @@ yyreduce: (yyval.u.inst_ident) = new CPPInstanceIdentifier(ident); } -#line 5782 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5808 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 179: -#line 1761 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1785 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 5791 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5817 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 180: -#line 1766 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1790 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 5800 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5826 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 181: -#line 1771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 5809 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5835 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 182: -#line 1776 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1800 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 5818 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5844 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 183: -#line 1781 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1805 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 5827 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5853 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 184: -#line 1786 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1810 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 5836 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5862 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 185: -#line 1791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1815 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 5845 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5871 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 186: -#line 1796 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1820 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 5854 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5880 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 187: -#line 1801 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Create a scope for this function (in case it is a function) CPPScope *scope = new CPPScope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope), @@ -5866,11 +5893,11 @@ yyreduce: push_scope(scope); } -#line 5871 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5897 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 188: -#line 1814 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1838 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); @@ -5884,1410 +5911,1410 @@ yyreduce: (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } } -#line 5889 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5915 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 189: -#line 1832 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is handled a bit awkwardly right now. Ideally it'd be wrapped // up in the instance_identifier rule, but then more needs to happen in // order to avoid shift/reduce conflicts. - if ((yyvsp[0].u.type) != NULL) { + if ((yyvsp[0].u.type) != nullptr) { (yyvsp[-1].u.inst_ident)->add_trailing_return_type((yyvsp[0].u.type)); } (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); } -#line 5903 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5929 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 190: -#line 1842 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1866 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Bitfield definition. (yyvsp[-2].u.inst_ident)->_bit_width = (yyvsp[0].u.integer); (yyval.u.inst_ident) = (yyvsp[-2].u.inst_ident); } -#line 5913 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5939 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 191: -#line 1852 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.type) = NULL; + (yyval.u.type) = nullptr; } -#line 5921 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5947 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 192: -#line 1856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1880 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 5929 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5955 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 193: -#line 1860 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1884 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 5938 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5964 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 194: -#line 1869 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1893 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.identifier) = NULL; + (yyval.u.identifier) = nullptr; } -#line 5946 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5972 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 195: -#line 1873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1897 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 5954 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5980 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 196: -#line 1881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1905 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; } -#line 5962 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5988 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 197: -#line 1885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1909 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5971 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5997 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 198: -#line 1890 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1914 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[0].u.param_list); } -#line 5979 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6005 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 199: -#line 1894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1918 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5988 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6014 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 200: -#line 1899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-1].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5997 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6023 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 201: -#line 1907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6006 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6032 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 202: -#line 1912 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1936 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6015 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6041 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 203: -#line 1920 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1944 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; } -#line 6023 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6049 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 204: -#line 1924 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1948 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6032 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6058 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 205: -#line 1929 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1953 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[0].u.param_list); } -#line 6040 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6066 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 206: -#line 1933 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1957 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6049 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6075 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 207: -#line 1938 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1962 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-1].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6058 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6084 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 208: -#line 1946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1970 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 209: -#line 1951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 210: -#line 1959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6084 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6110 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 211: -#line 1963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 6092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6118 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 212: -#line 1970 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1994 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6100 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6126 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 213: -#line 1974 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1998 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 6108 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6134 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 214: -#line 1981 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2005 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 215: -#line 1985 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2009 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6124 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6150 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 216: -#line 1989 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2013 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6132 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6158 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 217: -#line 1993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); } -#line 6140 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6166 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 218: -#line 1997 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2021 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); } -#line 6148 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6174 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 219: -#line 2004 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2028 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6156 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6182 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 220: -#line 2008 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2032 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6164 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6190 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 221: -#line 2012 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2036 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 6172 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6198 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 222: -#line 2016 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2040 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); } -#line 6180 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6206 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 223: -#line 2020 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2044 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); } -#line 6188 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6214 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 224: -#line 2024 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6196 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6222 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 228: -#line 2037 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2061 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { } -#line 6203 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6229 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 232: -#line 2046 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2070 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6212 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6238 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 233: -#line 2051 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2075 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6222 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6248 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 234: -#line 2057 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2081 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-2]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6232 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6258 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 235: -#line 2063 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2087 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6241 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6267 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 236: -#line 2068 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2092 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6251 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6277 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 237: -#line 2074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2098 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-2]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6261 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6287 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 238: -#line 2080 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2104 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6269 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6295 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 239: -#line 2084 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2108 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6277 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6303 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 240: -#line 2095 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2119 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6285 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6311 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 241: -#line 2099 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2123 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_parameter)); (yyval.u.instance) = new CPPInstance(type, "expr"); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6296 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6322 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 242: -#line 2109 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2133 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 243: -#line 2113 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 6312 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6338 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 244: -#line 2117 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2141 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6321 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6347 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 245: -#line 2122 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2146 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6330 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6356 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 246: -#line 2127 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2151 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6339 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6365 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 247: -#line 2132 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2156 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6348 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6374 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 248: -#line 2137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2161 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 249: -#line 2142 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2166 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6366 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6392 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 250: -#line 2147 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6375 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6401 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 251: -#line 2155 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6383 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6409 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 252: -#line 2159 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 6391 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6417 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 253: -#line 2163 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6400 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6426 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 254: -#line 2168 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2192 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6409 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6435 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 255: -#line 2173 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2197 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6418 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6444 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 256: -#line 2178 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2202 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6427 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6453 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 257: -#line 2183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6436 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6462 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 258: -#line 2188 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2212 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6445 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6471 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 259: -#line 2193 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6454 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6480 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 260: -#line 2198 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2222 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 6464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 261: -#line 2204 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2228 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 6473 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6499 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 262: -#line 2212 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2236 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 263: -#line 2217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6491 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6517 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 264: -#line 2222 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2246 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6500 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6526 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 265: -#line 2227 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2251 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6509 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6535 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 266: -#line 2232 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2256 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6518 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6544 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 267: -#line 2237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2261 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6527 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6553 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 268: -#line 2242 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2266 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6536 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6562 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 269: -#line 2247 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2271 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6545 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6571 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 270: -#line 2252 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2276 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6554 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6580 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 271: -#line 2257 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 6564 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6590 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 272: -#line 2263 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2287 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 6573 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6599 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 273: -#line 2271 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2295 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6581 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6607 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 274: -#line 2275 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2299 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6590 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6616 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 275: -#line 2280 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2304 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6599 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6625 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 276: -#line 2285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6608 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6634 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 277: -#line 2290 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2314 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6617 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6643 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 278: -#line 2295 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2319 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 279: -#line 2300 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2324 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6635 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6661 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 280: -#line 2305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6644 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6670 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 281: -#line 2310 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2334 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6653 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6679 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 282: -#line 2315 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2339 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6662 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6688 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 283: -#line 2323 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2347 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6670 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6696 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 284: -#line 2327 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2351 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6679 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6705 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 285: -#line 2332 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2356 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6688 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6714 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 286: -#line 2337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6697 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6723 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 287: -#line 2342 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2366 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6706 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6732 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 288: -#line 2347 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2371 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6715 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6741 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 289: -#line 2352 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2376 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6724 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 290: -#line 2357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6733 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6759 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 291: -#line 2362 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2386 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6742 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6768 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 292: -#line 2367 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2391 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6751 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6777 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 293: -#line 2372 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2396 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6761 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6787 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 294: -#line 2378 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6772 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6798 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 295: -#line 2385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2409 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6783 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6809 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 296: -#line 2392 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2416 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6794 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6820 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 297: -#line 2402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2426 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 6802 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6828 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 298: -#line 2406 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2430 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 6814 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6840 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 299: -#line 2414 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2438 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 6822 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6848 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 300: -#line 2418 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2442 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6830 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6856 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 301: -#line 2422 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2446 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6838 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6864 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 302: -#line 2426 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2450 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.enum_type)); } -#line 6846 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6872 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 303: -#line 2430 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2454 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 6866 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6892 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 304: -#line 2446 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2470 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[-2].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), current_scope, (yylsp[-3]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[-2].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 6886 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6912 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 305: -#line 2462 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2486 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.type) == (CPPType *)NULL) { + if ((yyval.u.type) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 6899 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6925 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 306: -#line 2471 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2495 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 6907 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6933 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 307: -#line 2475 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2499 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.type) = (yyvsp[-1].u.type); } else { (yyval.u.type) = enum_type->get_underlying_type(); } } -#line 6921 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6947 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 308: -#line 2485 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2509 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 6929 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6955 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 309: -#line 2492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 6941 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6967 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 310: -#line 2503 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 6949 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6975 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 311: -#line 2507 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2531 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.decl) == NULL) { + if ((yyval.u.decl) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.decl) != NULL); + assert((yyval.u.decl) != nullptr); } -#line 6961 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6987 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 312: -#line 2515 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2539 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 6969 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6995 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 313: -#line 2519 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2543 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6977 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7003 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 314: -#line 2523 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[0].u.struct_type))); } -#line 6985 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7011 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 315: -#line 2527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2551 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[0].u.enum_type))); } -#line 6993 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7019 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 316: -#line 2531 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2555 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7013 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7039 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 317: -#line 2547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[-2].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), current_scope, (yylsp[-3]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[-2].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7033 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7059 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 318: -#line 2563 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yywarning(string("C++ does not permit forward declaration of untyped enum ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-1]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7055 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7081 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 319: -#line 2581 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2605 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.decl) == (CPPType *)NULL) { + if ((yyval.u.decl) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 7068 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7094 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 320: -#line 2590 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2614 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 321: -#line 2594 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2618 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.decl) = (yyvsp[-1].u.type); } else { (yyval.u.decl) = enum_type->get_underlying_type(); } } -#line 7090 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7116 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 322: -#line 2604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2628 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7098 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7124 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 323: -#line 2611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 7106 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7132 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 324: -#line 2615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 7118 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7144 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 325: -#line 2623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 7126 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7152 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 326: -#line 2627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 7146 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7172 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 327: -#line 2643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2667 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-1]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 7166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7192 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 328: -#line 2659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2683 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.type) == (CPPType *)NULL) { + if ((yyval.u.type) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 7179 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7205 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 329: -#line 2668 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2692 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.type) = (yyvsp[-1].u.type); } else { (yyval.u.type) = enum_type->get_underlying_type(); } } -#line 7193 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7219 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 330: -#line 2678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7201 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7227 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 331: -#line 2685 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2709 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[0].u.decl); } -#line 7209 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7235 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 332: -#line 2689 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2713 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yyerror(string("unknown type '") + (yyvsp[0].u.identifier)->get_fully_scoped_name() + "'", (yylsp[0])); (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); } -#line 7219 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7245 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 333: -#line 2697 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2721 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7227 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7253 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 334: -#line 2701 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2725 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7236 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7262 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 335: -#line 2706 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2730 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7244 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7270 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 336: -#line 2710 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2734 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7253 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7279 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 341: -#line 2725 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2749 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPVisibility starting_vis = ((yyvsp[-2].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("anon"), starting_vis); - CPPStructType *st = new CPPStructType((yyvsp[-2].u.extension_enum), NULL, current_scope, + CPPStructType *st = new CPPStructType((yyvsp[-2].u.extension_enum), nullptr, current_scope, new_scope, (yylsp[-2]).file); new_scope->set_struct_type(st); push_scope(new_scope); push_struct(st); } -#line 7271 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7297 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 342: -#line 2739 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; pop_struct(); pop_scope(); } -#line 7282 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7308 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 343: -#line 2749 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2773 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPVisibility starting_vis = ((yyvsp[-2].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPScope *new_scope = new CPPScope(scope, (yyvsp[0].u.identifier)->_names.back(), @@ -7301,260 +7328,260 @@ yyreduce: push_scope(new_scope); push_struct(st); } -#line 7306 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7332 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 344: -#line 2769 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2793 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; pop_struct(); pop_scope(); } -#line 7317 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7343 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 346: -#line 2780 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2804 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->_final = true; } -#line 7325 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7351 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 351: -#line 2797 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_unknown, false); } -#line 7333 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7359 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 352: -#line 2801 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, false); } -#line 7341 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7367 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 353: -#line 2805 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, false); } -#line 7349 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7375 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 354: -#line 2809 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, false); } -#line 7357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 355: -#line 2813 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, true); } -#line 7365 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7391 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 356: -#line 2817 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2841 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, true); } -#line 7373 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7399 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 357: -#line 2821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2845 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, true); } -#line 7381 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7407 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 358: -#line 2825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, true); } -#line 7389 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7415 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 359: -#line 2829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, true); } -#line 7397 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7423 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 360: -#line 2833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, true); } -#line 7405 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7431 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 361: -#line 2840 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2864 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.enum_type) = current_enum; - current_enum = NULL; + current_enum = nullptr; } -#line 7414 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7440 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 362: -#line 2848 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2872 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - current_enum = new CPPEnumType((yyvsp[-2].u.extension_enum), NULL, (yyvsp[0].u.type), current_scope, NULL, (yylsp[-2]).file); + current_enum = new CPPEnumType((yyvsp[-2].u.extension_enum), nullptr, (yyvsp[0].u.type), current_scope, nullptr, (yylsp[-2]).file); } -#line 7422 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7448 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 363: -#line 2852 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - current_enum = new CPPEnumType((yyvsp[0].u.extension_enum), NULL, current_scope, NULL, (yylsp[0]).file); + current_enum = new CPPEnumType((yyvsp[0].u.extension_enum), nullptr, current_scope, nullptr, (yylsp[0]).file); } -#line 7430 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7456 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 364: -#line 2856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2880 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, (yyvsp[-2].u.identifier)->_names.back(), V_public); current_enum = new CPPEnumType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), (yyvsp[0].u.type), current_scope, new_scope, (yylsp[-3]).file); } -#line 7439 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7465 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 365: -#line 2861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, (yyvsp[0].u.identifier)->_names.back(), V_public); current_enum = new CPPEnumType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, new_scope, (yylsp[-1]).file); } -#line 7448 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7474 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 366: -#line 2869 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2893 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 7456 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7482 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 367: -#line 2873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2897 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); } -#line 7464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 369: -#line 2881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2905 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); - current_enum->add_element((yyvsp[-1].u.identifier)->get_simple_name(), NULL, current_lexer, (yylsp[-1])); + assert(current_enum != nullptr); + current_enum->add_element((yyvsp[-1].u.identifier)->get_simple_name(), nullptr, current_lexer, (yylsp[-1])); } -#line 7473 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7499 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 370: -#line 2886 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2910 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element((yyvsp[-3].u.identifier)->get_simple_name(), (yyvsp[-1].u.expr), current_lexer, (yylsp[-3])); } -#line 7482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 372: -#line 2894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2918 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); - current_enum->add_element((yyvsp[0].u.identifier)->get_simple_name(), NULL, current_lexer, (yylsp[0])); + assert(current_enum != nullptr); + current_enum->add_element((yyvsp[0].u.identifier)->get_simple_name(), nullptr, current_lexer, (yylsp[0])); } -#line 7491 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7517 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 373: -#line 2899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element((yyvsp[-2].u.identifier)->get_simple_name(), (yyvsp[0].u.expr), current_lexer, (yylsp[-2])); } -#line 7500 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7526 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 374: -#line 2907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum; } -#line 7508 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7534 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 375: -#line 2911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum_class; } -#line 7516 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7542 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 376: -#line 2915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum_struct; } -#line 7524 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7550 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 377: -#line 2922 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_class; } -#line 7532 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7558 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 378: -#line 2926 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2950 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_struct; } -#line 7540 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7566 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 379: -#line 2930 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2954 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_union; } -#line 7548 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7574 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 380: -#line 2937 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2961 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *scope = (yyvsp[-1].u.identifier)->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = (yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, (yyvsp[-1].u.identifier)->_names.back(), V_public); @@ -7565,26 +7592,26 @@ yyreduce: current_scope->define_namespace(nspace); push_scope(scope); } -#line 7570 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 381: -#line 2955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 7578 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7604 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 382: -#line 2959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *scope = (yyvsp[-1].u.identifier)->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = (yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, (yyvsp[-1].u.identifier)->_names.back(), V_public); @@ -7596,143 +7623,143 @@ yyreduce: current_scope->define_namespace(nspace); push_scope(scope); } -#line 7601 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7627 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 383: -#line 2978 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3002 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 7609 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7635 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 386: -#line 2987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPUsing *using_decl = new CPPUsing((yyvsp[-1].u.identifier), false, (yylsp[-2]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[-2])); current_scope->add_using(using_decl, global_scope, current_lexer); } -#line 7619 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7645 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 387: -#line 2993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is really just an alternative way to declare a typedef. CPPTypedefType *typedef_type = new CPPTypedefType((yyvsp[-1].u.type), (yyvsp[-3].u.identifier), current_scope); typedef_type->_using = true; current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-4])); } -#line 7630 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7656 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 388: -#line 3000 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3024 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPUsing *using_decl = new CPPUsing((yyvsp[-1].u.identifier), true, (yylsp[-3]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[-3])); current_scope->add_using(using_decl, global_scope, current_lexer); } -#line 7640 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7666 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 392: -#line 3015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3039 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_bool); } -#line 7648 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7674 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 393: -#line 3019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3043 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char); } -#line 7656 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7682 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 394: -#line 3023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3047 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_wchar_t); } -#line 7664 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7690 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 395: -#line 3027 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3051 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char16_t); } -#line 7672 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7698 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 396: -#line 3031 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3055 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char32_t); } -#line 7680 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7706 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 397: -#line 3035 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short); } -#line 7689 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7715 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 398: -#line 3040 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long); } -#line 7698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 399: -#line 3045 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3069 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned); } -#line 7707 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7733 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 400: -#line 3050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed); } -#line 7716 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7742 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 401: -#line 3055 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3079 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int); } -#line 7724 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 402: -#line 3059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3083 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_short; } -#line 7733 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7759 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 403: -#line 3064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3088 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); if ((yyval.u.simple_type)->_flags & CPPSimpleType::F_long) { @@ -7741,192 +7768,192 @@ yyreduce: (yyval.u.simple_type)->_flags |= CPPSimpleType::F_long; } } -#line 7746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7772 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 404: -#line 3073 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3097 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_unsigned; } -#line 7755 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7781 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 405: -#line 3078 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3102 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_signed; } -#line 7764 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7790 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 406: -#line 3086 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3110 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float); } -#line 7772 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7798 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 407: -#line 3090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3114 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double); } -#line 7780 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7806 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 408: -#line 3094 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3118 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double, CPPSimpleType::F_long); } -#line 7789 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7815 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 409: -#line 3102 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3126 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_void); } -#line 7797 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7823 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 410: -#line 3111 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3135 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_lexer->_resolve_identifiers = false; } -#line 7805 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7831 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 411: -#line 3115 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3139 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_lexer->_resolve_identifiers = true; } -#line 7813 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7839 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 519: -#line 3159 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { } -#line 7820 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7846 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 543: -#line 3168 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3192 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 7828 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7854 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 544: -#line 3172 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3196 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7836 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7862 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 545: -#line 3179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3203 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 7844 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7870 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 546: -#line 3183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7852 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7878 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 547: -#line 3190 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3214 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7860 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7886 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 548: -#line 3194 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3218 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(',', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 7868 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7894 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 549: -#line 3201 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7876 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7902 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 550: -#line 3205 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 7884 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7910 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 551: -#line 3209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3233 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 7892 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7918 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 552: -#line 3213 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 7900 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7926 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 553: -#line 3217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 7908 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7934 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 554: -#line 3221 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3245 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 7916 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7942 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 555: -#line 3225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3249 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 7924 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7950 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 556: -#line 3229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3253 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -7935,470 +7962,470 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 7940 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7966 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 557: -#line 3241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3265 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 7948 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7974 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 558: -#line 3245 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3269 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 7956 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7982 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 559: -#line 3249 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3273 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 7964 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7990 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 560: -#line 3253 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3277 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 7972 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7998 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 561: -#line 3257 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 7980 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8006 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 562: -#line 3261 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 7988 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8014 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 563: -#line 3265 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3289 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[0].u.expr)); } -#line 7996 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8022 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 564: -#line 3269 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3293 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 8004 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8030 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 565: -#line 3273 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3297 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8012 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8038 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 566: -#line 3277 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3301 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8020 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8046 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 567: -#line 3281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8028 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8054 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 568: -#line 3285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8036 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8062 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 569: -#line 3289 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3313 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8044 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8070 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 570: -#line 3293 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3317 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8052 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8078 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 571: -#line 3297 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3321 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8060 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8086 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 572: -#line 3301 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3325 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8068 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8094 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 573: -#line 3305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 574: -#line 3309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3333 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8084 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8110 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 575: -#line 3313 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8118 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 576: -#line 3317 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8100 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8126 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 577: -#line 3321 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3345 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8108 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8134 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 578: -#line 3325 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3349 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 579: -#line 3329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3353 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8124 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8150 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 580: -#line 3333 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8132 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8158 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 581: -#line 3337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8140 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8166 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 582: -#line 3341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3365 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8148 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8174 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 583: -#line 3345 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3369 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8156 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8182 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 584: -#line 3349 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3373 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 8164 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8190 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 585: -#line 3353 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3377 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8172 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8198 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 586: -#line 3357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8180 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8206 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 587: -#line 3361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 8188 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8214 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 588: -#line 3369 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3393 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8196 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8222 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 589: -#line 3373 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3397 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 8204 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8230 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 590: -#line 3377 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3401 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 8212 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8238 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 591: -#line 3381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3405 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 8220 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8246 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 592: -#line 3385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3409 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 8228 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8254 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 593: -#line 3389 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3413 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 8236 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8262 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 594: -#line 3393 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3417 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A constructor call. CPPType *type = (yyvsp[-3].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-3].u.identifier)->get_fully_scoped_name(), (yylsp[-3])); } - assert(type != NULL); + assert(type != nullptr); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8250 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8276 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 595: -#line 3403 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3427 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Aggregate initialization. CPPType *type = (yyvsp[-3].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-3].u.identifier)->get_fully_scoped_name(), (yylsp[-3])); } - assert(type != NULL); + assert(type != nullptr); (yyval.u.expr) = new CPPExpression(CPPExpression::aggregate_init_op(type, (yyvsp[-1].u.expr))); } -#line 8264 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8290 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 596: -#line 3413 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8274 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8300 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 597: -#line 3419 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3443 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8284 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8310 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 598: -#line 3425 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8294 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8320 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 599: -#line 3431 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3455 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char16_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 600: -#line 3437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3461 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char32_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8314 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8340 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 601: -#line 3443 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3467 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_bool)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8324 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8350 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 602: -#line 3449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3473 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8335 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8361 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 603: -#line 3456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8346 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8372 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 604: -#line 3463 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3487 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 605: -#line 3470 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3494 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8368 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8394 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 606: -#line 3477 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3501 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_float)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8378 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8404 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 607: -#line 3483 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3507 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_double)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8388 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8414 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 608: -#line 3489 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3513 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 8396 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8422 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 609: -#line 3493 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3517 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -8407,43 +8434,43 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 8412 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8438 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 610: -#line 3505 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3529 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 8420 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8446 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 611: -#line 3509 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3533 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 8428 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8454 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 612: -#line 3513 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3537 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[0].u.type))); } -#line 8436 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8462 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 613: -#line 3517 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3541 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[-3].u.type), (yyvsp[-1].u.expr))); } -#line 8444 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8470 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 614: -#line 3521 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3545 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -8454,11 +8481,11 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.type), std_type_info)); } -#line 8459 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8485 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 615: -#line 3532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -8469,567 +8496,567 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.expr), std_type_info)); } -#line 8474 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8500 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 616: -#line 3543 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3567 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 8482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 617: -#line 3547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 8490 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8516 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 618: -#line 3551 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 8498 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8524 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 619: -#line 3555 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3579 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 8506 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8532 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 620: -#line 3559 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3583 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[0].u.expr)); } -#line 8514 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8540 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 621: -#line 3563 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 8522 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8548 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 622: -#line 3567 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3591 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8530 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8556 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 623: -#line 3571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3595 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8538 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8564 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 624: -#line 3575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3599 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8546 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8572 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 625: -#line 3579 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3603 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8554 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8580 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 626: -#line 3583 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3607 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8562 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8588 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 627: -#line 3587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8570 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 628: -#line 3591 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8578 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8604 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 629: -#line 3595 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8586 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8612 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 630: -#line 3599 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8594 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8620 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 631: -#line 3603 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8602 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8628 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 632: -#line 3607 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3631 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8610 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8636 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 633: -#line 3611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8644 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 634: -#line 3615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 635: -#line 3619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8634 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8660 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 636: -#line 3623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('<', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8642 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8668 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 637: -#line 3627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('>', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8650 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8676 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 638: -#line 3631 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3655 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8658 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8684 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 639: -#line 3635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 640: -#line 3639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3663 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8674 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8700 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 641: -#line 3643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3667 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8682 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8708 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 642: -#line 3647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3671 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8690 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8716 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 643: -#line 3651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3675 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 8698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 644: -#line 3655 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3679 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8706 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8732 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 645: -#line 3659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3683 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8714 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8740 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 646: -#line 3663 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3687 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 8722 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8748 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 647: -#line 3670 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3694 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 8730 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8756 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 648: -#line 3674 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3698 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(true); } -#line 8738 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8764 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 649: -#line 3678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(false); } -#line 8746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8772 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 650: -#line 3682 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3706 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 8754 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8780 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 651: -#line 3686 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3710 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.real)); } -#line 8762 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8788 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 652: -#line 3690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8770 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8796 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 653: -#line 3694 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3718 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8778 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8804 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 654: -#line 3698 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3722 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.identifier), current_scope, global_scope, current_lexer); } -#line 8786 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8812 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 655: -#line 3702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3726 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "final". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 8796 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8822 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 656: -#line 3708 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "override". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 8806 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8832 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 657: -#line 3714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3738 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); } -#line 8814 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8840 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 658: -#line 3718 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3742 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-6].u.closure_type)->_flags = (yyvsp[-4].u.integer); (yyvsp[-6].u.closure_type)->_return_type = (yyvsp[-3].u.type); (yyval.u.expr) = new CPPExpression(CPPExpression::lambda((yyvsp[-6].u.closure_type))); } -#line 8824 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8850 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 659: -#line 3724 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3748 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-9].u.closure_type)->_parameters = (yyvsp[-6].u.param_list); (yyvsp[-9].u.closure_type)->_flags = (yyvsp[-4].u.integer); (yyvsp[-9].u.closure_type)->_return_type = (yyvsp[-3].u.type); (yyval.u.expr) = new CPPExpression(CPPExpression::lambda((yyvsp[-9].u.closure_type))); } -#line 8835 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8861 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 660: -#line 3731 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3755 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_HAS_VIRTUAL_DESTRUCTOR, (yyvsp[-1].u.type))); } -#line 8843 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8869 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 661: -#line 3735 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3759 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_ABSTRACT, (yyvsp[-1].u.type))); } -#line 8851 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8877 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 662: -#line 3739 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CLASS, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8859 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8885 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 663: -#line 3743 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3767 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CLASS, (yyvsp[-1].u.type))); } -#line 8867 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8893 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 664: -#line 3747 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONSTRUCTIBLE, (yyvsp[-1].u.type))); } -#line 8875 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8901 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 665: -#line 3751 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3775 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONSTRUCTIBLE, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8883 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8909 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 666: -#line 3755 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3779 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONVERTIBLE_TO, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8891 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8917 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 667: -#line 3759 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3783 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_DESTRUCTIBLE, (yyvsp[-1].u.type))); } -#line 8899 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8925 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 668: -#line 3763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3787 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_EMPTY, (yyvsp[-1].u.type))); } -#line 8907 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8933 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 669: -#line 3767 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_ENUM, (yyvsp[-1].u.type))); } -#line 8915 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8941 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 670: -#line 3771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_FINAL, (yyvsp[-1].u.type))); } -#line 8923 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8949 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 671: -#line 3775 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3799 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_FUNDAMENTAL, (yyvsp[-1].u.type))); } -#line 8931 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8957 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 672: -#line 3779 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3803 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_POD, (yyvsp[-1].u.type))); } -#line 8939 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8965 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 673: -#line 3783 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3807 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_POLYMORPHIC, (yyvsp[-1].u.type))); } -#line 8947 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8973 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 674: -#line 3787 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3811 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_STANDARD_LAYOUT, (yyvsp[-1].u.type))); } -#line 8955 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8981 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 675: -#line 3791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3815 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_TRIVIAL, (yyvsp[-1].u.type))); } -#line 8963 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8989 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 676: -#line 3795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3819 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_UNION, (yyvsp[-1].u.type))); } -#line 8971 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8997 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 677: -#line 3809 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8979 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9005 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 678: -#line 3813 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 8987 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9013 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 679: -#line 3817 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3841 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 8995 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9021 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 680: -#line 3821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3845 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 9003 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9029 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 681: -#line 3825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 9011 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9037 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 682: -#line 3829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 9019 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9045 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 683: -#line 3833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 9027 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9053 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 684: -#line 3837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -9038,43 +9065,43 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 9043 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9069 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 685: -#line 3849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 9051 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9077 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 686: -#line 3853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3877 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 9059 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9085 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 687: -#line 3857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[0].u.type))); } -#line 9067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 688: -#line 3861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[-3].u.type), (yyvsp[-1].u.expr))); } -#line 9075 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9101 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 689: -#line 3865 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3889 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -9085,11 +9112,11 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.type), std_type_info)); } -#line 9090 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9116 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 690: -#line 3876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3900 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -9100,409 +9127,409 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.expr), std_type_info)); } -#line 9105 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9131 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 691: -#line 3887 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 9113 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9139 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 692: -#line 3891 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 9121 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9147 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 693: -#line 3895 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3919 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 9129 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9155 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 694: -#line 3899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 9137 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9163 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 695: -#line 3903 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 9145 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9171 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 696: -#line 3907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9153 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9179 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 697: -#line 3911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9161 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9187 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 698: -#line 3915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9169 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9195 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 699: -#line 3919 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3943 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9177 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9203 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 700: -#line 3923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3947 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9185 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9211 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 701: -#line 3927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9193 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9219 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 702: -#line 3931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9201 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9227 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 703: -#line 3935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9209 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9235 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 704: -#line 3939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9217 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9243 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 705: -#line 3943 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3967 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9225 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9251 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 706: -#line 3947 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3971 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9233 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9259 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 707: -#line 3951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9241 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9267 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 708: -#line 3955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9249 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9275 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 709: -#line 3959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9257 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9283 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 710: -#line 3963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('<', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9265 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9291 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 711: -#line 3967 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('>', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9273 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9299 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 712: -#line 3971 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9281 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9307 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 713: -#line 3975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9289 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9315 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 714: -#line 3979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9297 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9323 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 715: -#line 3983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4007 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 9305 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9331 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 716: -#line 3987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 9313 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9339 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 717: -#line 3991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 9321 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9347 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 718: -#line 3995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9329 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9355 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 719: -#line 3999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9337 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9363 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 720: -#line 4003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4027 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 9345 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9371 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 721: -#line 4010 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4034 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 9353 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9379 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 722: -#line 4014 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4038 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(true); } -#line 9361 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9387 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 723: -#line 4018 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4042 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(false); } -#line 9369 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9395 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 724: -#line 4022 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4046 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 9377 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9403 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 725: -#line 4026 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.real)); } -#line 9385 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9411 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 726: -#line 4030 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4054 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9393 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9419 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 727: -#line 4034 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4058 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9401 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9427 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 728: -#line 4038 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4062 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.identifier), current_scope, global_scope, current_lexer); } -#line 9409 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9435 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 729: -#line 4042 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "final". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 9419 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9445 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 730: -#line 4048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4072 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "override". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 9429 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9455 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 731: -#line 4054 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4078 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); } -#line 9437 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9463 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 732: -#line 4062 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4086 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(); } -#line 9445 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9471 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 733: -#line 4066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(CPPClosureType::CT_by_value); } -#line 9453 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9479 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 734: -#line 4070 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4094 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(CPPClosureType::CT_by_reference); } -#line 9461 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9487 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 735: -#line 4074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4098 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(); (yyvsp[-1].u.capture)->_initializer = (yyvsp[0].u.expr); (yyval.u.closure_type)->_captures.push_back(*(yyvsp[-1].u.capture)); delete (yyvsp[-1].u.capture); } -#line 9472 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9498 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 736: -#line 4081 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4105 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = (yyvsp[-3].u.closure_type); (yyvsp[-1].u.capture)->_initializer = (yyvsp[0].u.expr); (yyval.u.closure_type)->_captures.push_back(*(yyvsp[-1].u.capture)); delete (yyvsp[-1].u.capture); } -#line 9483 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9509 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 737: -#line 4091 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4115 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); (yyval.u.capture)->_type = CPPClosureType::CT_by_reference; } -#line 9493 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9519 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 738: -#line 4097 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4121 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[-1].u.identifier)->get_simple_name(); (yyval.u.capture)->_type = CPPClosureType::CT_by_reference; } -#line 9503 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9529 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 739: -#line 4103 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4127 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); @@ -9512,11 +9539,11 @@ yyreduce: (yyval.u.capture)->_type = CPPClosureType::CT_by_value; } } -#line 9517 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9543 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 740: -#line 4113 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); @@ -9525,189 +9552,189 @@ yyreduce: yywarning("only capture name 'this' may be preceded by an asterisk", (yylsp[0])); } } -#line 9530 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9556 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 741: -#line 4125 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4149 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, true); - if (type == NULL) { + if (type == nullptr) { type = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } (yyval.u.type) = type; } -#line 9542 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9568 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 742: -#line 4133 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4157 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 9550 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9576 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 743: -#line 4137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4161 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((yyvsp[-1].u.identifier)); ctp->_packed = true; (yyval.u.type) = CPPType::new_type(ctp); } -#line 9560 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 744: -#line 4167 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4191 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9594 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 745: -#line 4171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4195 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9576 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9602 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 746: -#line 4175 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4199 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9584 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9610 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 747: -#line 4179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4203 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("final", (yylsp[0])); } -#line 9592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9618 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 748: -#line 4183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[0])); } -#line 9600 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9626 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 749: -#line 4187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4211 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is not a keyword in Python, so it is useful to be able to use this // in MAKE_PROPERTY definitions, etc. (yyval.u.identifier) = new CPPIdentifier("signed", (yylsp[0])); } -#line 9610 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9636 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 750: -#line 4193 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("float", (yylsp[0])); } -#line 9618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9644 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 751: -#line 4197 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4221 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("public", (yylsp[0])); } -#line 9626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 752: -#line 4201 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("private", (yylsp[0])); } -#line 9634 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9660 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 753: -#line 4205 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("static", (yylsp[0])); } -#line 9642 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9668 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 754: -#line 4209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4233 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("default", (yylsp[0])); } -#line 9650 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9676 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 755: -#line 4220 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4244 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9658 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9684 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 756: -#line 4224 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4248 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 757: -#line 4228 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4252 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9674 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9700 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 758: -#line 4232 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4256 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[0])); } -#line 9682 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9708 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 759: -#line 4240 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4264 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].str)); } -#line 9690 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9716 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 760: -#line 4244 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4268 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 761: -#line 4248 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4272 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // The right string takes on the literal type of the left. (yyval.u.expr) = (yyvsp[-1].u.expr); (yyval.u.expr)->_str += (yyvsp[0].str); } -#line 9708 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9734 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 762: -#line 4254 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4278 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We have to check that the two literal types match up. (yyval.u.expr) = (yyvsp[-1].u.expr); @@ -9716,11 +9743,11 @@ yyreduce: } (yyval.u.expr)->_str += (yyvsp[0].u.expr)->_str; } -#line 9721 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9747 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; -#line 9725 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9751 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -9843,7 +9870,6 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); diff --git a/dtool/src/cppparser/cppBison.h.prebuilt b/dtool/src/cppparser/cppBison.h.prebuilt index a2ec1fca8c..c33ce691eb 100644 --- a/dtool/src/cppparser/cppBison.h.prebuilt +++ b/dtool/src/cppparser/cppBison.h.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.0.5. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index d132677763..5a82fa5d9f 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -32,6 +32,9 @@ #include "cppNamespace.h" #include "cppUsing.h" +using std::stringstream; +using std::string; + //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// @@ -1182,14 +1185,27 @@ constructor_prototype: /* Functions with implicit return types, and constructors */ IDENTIFIER '(' { - push_scope($1->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope), + $1->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } function_parameter_list ')' function_post { + CPPScope *scope = $1->get_scope(current_scope, global_scope); CPPType *type; - if ($1->get_simple_name() == current_scope->get_simple_name() || - $1->get_simple_name() == string("~") + current_scope->get_simple_name()) { - // This is a constructor, and has no return. + std::string simple_name = $1->get_simple_name(); + if (!simple_name.empty() && simple_name[0] == '~') { + // A destructor has no return type. + type = new CPPSimpleType(CPPSimpleType::T_void); + } else if (scope != nullptr && simple_name == scope->get_simple_name()) { + // Neither does a constructor. type = new CPPSimpleType(CPPSimpleType::T_void); } else { // This isn't a constructor, so it has an implicit return type of @@ -1206,7 +1222,16 @@ constructor_prototype: } | TYPENAME_IDENTIFIER '(' { - push_scope($1->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope), + $1->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } function_parameter_list ')' function_post { diff --git a/dtool/src/cppparser/cppBisonDefs.h b/dtool/src/cppparser/cppBisonDefs.h index 1c7be65b85..9e8f71f9b1 100644 --- a/dtool/src/cppparser/cppBisonDefs.h +++ b/dtool/src/cppparser/cppBisonDefs.h @@ -27,8 +27,6 @@ #include "cppExtensionType.h" #include "cppFile.h" -using namespace std; - class CPPParser; class CPPExpression; class CPPPreprocessor; diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 46fb525b8b..7c85eb6c24 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -40,7 +40,7 @@ is_fully_specified() const { * */ void CPPClassTemplateParameter:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (complete) { out << "class"; if (_packed) { diff --git a/dtool/src/cppparser/cppClosureType.cxx b/dtool/src/cppparser/cppClosureType.cxx index 974742e5df..1d12602c3b 100644 --- a/dtool/src/cppparser/cppClosureType.cxx +++ b/dtool/src/cppparser/cppClosureType.cxx @@ -49,7 +49,7 @@ operator = (const CPPClosureType ©) { * Adds a new capture to the beginning of the capture list. */ void CPPClosureType:: -add_capture(string name, CaptureType type, CPPExpression *initializer) { +add_capture(std::string name, CaptureType type, CPPExpression *initializer) { if (type == CT_none) { if (name == "this") { type = CT_by_reference; @@ -58,8 +58,8 @@ add_capture(string name, CaptureType type, CPPExpression *initializer) { } } - Capture capture = {move(name), type, initializer}; - _captures.insert(_captures.begin(), move(capture)); + Capture capture = {std::move(name), type, initializer}; + _captures.insert(_captures.begin(), std::move(capture)); } /** @@ -100,7 +100,7 @@ is_destructible() const { * */ void CPPClosureType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { out.put('['); bool have_capture = false; diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index f7eb198782..139a25dc5c 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -171,7 +171,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPConstType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { _wrapped_around->output(out, indent_level, scope, complete); out << " const"; } @@ -182,9 +182,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPConstType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { _wrapped_around->output_instance(out, indent_level, scope, complete, "const " + prename, name); } diff --git a/dtool/src/cppparser/cppDeclaration.cxx b/dtool/src/cppparser/cppDeclaration.cxx index 444801ceea..0125ed4289 100644 --- a/dtool/src/cppparser/cppDeclaration.cxx +++ b/dtool/src/cppparser/cppDeclaration.cxx @@ -338,8 +338,8 @@ is_less(const CPPDeclaration *other) const { } -ostream & -operator << (ostream &out, const CPPDeclaration::SubstDecl &subst) { +std::ostream & +operator << (std::ostream &out, const CPPDeclaration::SubstDecl &subst) { CPPDeclaration::SubstDecl::const_iterator it; for (it = subst.begin(); it != subst.end(); ++it) { out << " "; diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index d472c277fd..967dc6b6ec 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -25,8 +25,6 @@ #include #include -using namespace std; - class CPPInstance; class CPPTemplateParameterList; class CPPTypedefType; diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index ffbce64a7d..11fcd5da3e 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -89,7 +89,7 @@ get_underlying_type() { * */ CPPInstance *CPPEnumType:: -add_element(const string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos) { +add_element(const std::string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos) { CPPIdentifier *ident = new CPPIdentifier(name); ident->_native_scope = _parent_scope; @@ -262,7 +262,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPEnumType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index ed36275af9..2b2cc0bd50 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -31,6 +31,9 @@ #include +using std::cerr; +using std::string; + /** * */ @@ -161,7 +164,7 @@ as_boolean() const { * */ void CPPExpression::Result:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_type) { case RT_integer: out << _u._integer; @@ -1551,7 +1554,7 @@ is_tbd() const { * */ void CPPExpression:: -output(ostream &out, int indent_level, CPPScope *scope, bool) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool) const { switch (_type) { case T_nullptr: out << "nullptr"; @@ -1630,8 +1633,8 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { if (isprint(*si)) { out << *si; } else { - out << '\\' << oct << setw(3) << setfill('0') << (int)(*si) - << dec << setw(0); + out << '\\' << std::oct << std::setw(3) << std::setfill('0') << (int)(*si) + << std::dec << std::setw(0); } } } diff --git a/dtool/src/cppparser/cppExpressionParser.cxx b/dtool/src/cppparser/cppExpressionParser.cxx index c0821712fc..ef5785eb5a 100644 --- a/dtool/src/cppparser/cppExpressionParser.cxx +++ b/dtool/src/cppparser/cppExpressionParser.cxx @@ -36,9 +36,9 @@ CPPExpressionParser:: * */ bool CPPExpressionParser:: -parse_expr(const string &expr) { +parse_expr(const std::string &expr) { if (!init_const_expr(expr)) { - cerr << "Unable to parse expression\n"; + std::cerr << "Unable to parse expression\n"; return false; } @@ -51,9 +51,9 @@ parse_expr(const string &expr) { * */ bool CPPExpressionParser:: -parse_expr(const string &expr, const CPPPreprocessor &filepos) { +parse_expr(const std::string &expr, const CPPPreprocessor &filepos) { if (!init_const_expr(expr)) { - cerr << "Unable to parse expression\n"; + std::cerr << "Unable to parse expression\n"; return false; } @@ -68,7 +68,7 @@ parse_expr(const string &expr, const CPPPreprocessor &filepos) { * */ void CPPExpressionParser:: -output(ostream &out) const { +output(std::ostream &out) const { if (_expr == nullptr) { out << "(null expr)"; } else { diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index ef5168334b..b7d23cb667 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -36,7 +36,7 @@ CPPExtensionType(CPPExtensionType::Type type, /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_simple_name() const { if (_ident == nullptr) { return ""; @@ -47,7 +47,7 @@ get_simple_name() const { /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_local_name(CPPScope *scope) const { if (_ident == nullptr) { return ""; @@ -58,7 +58,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_fully_scoped_name() const { if (_ident == nullptr) { return ""; @@ -209,7 +209,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPExtensionType:: -output(ostream &out, int, CPPScope *scope, bool complete) const { +output(std::ostream &out, int, CPPScope *scope, bool complete) const { if (_ident != nullptr) { // If we have a name, use it. if (complete || cppparser_output_class_keyword) { @@ -242,8 +242,8 @@ as_extension_type() { return this; } -ostream & -operator << (ostream &out, CPPExtensionType::Type type) { +std::ostream & +operator << (std::ostream &out, CPPExtensionType::Type type) { switch (type) { case CPPExtensionType::T_enum: return out << "enum"; diff --git a/dtool/src/cppparser/cppFile.cxx b/dtool/src/cppparser/cppFile.cxx index a42602013f..ce9a61ffc5 100644 --- a/dtool/src/cppparser/cppFile.cxx +++ b/dtool/src/cppparser/cppFile.cxx @@ -15,6 +15,8 @@ #include +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppFunctionGroup.cxx b/dtool/src/cppparser/cppFunctionGroup.cxx index fdec00184d..7904663d08 100644 --- a/dtool/src/cppparser/cppFunctionGroup.cxx +++ b/dtool/src/cppparser/cppFunctionGroup.cxx @@ -20,7 +20,7 @@ * */ CPPFunctionGroup:: -CPPFunctionGroup(const string &name) : +CPPFunctionGroup(const std::string &name) : CPPDeclaration(CPPFile()), _name(name) { @@ -61,7 +61,7 @@ get_return_type() const { * */ void CPPFunctionGroup:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!_instances.empty()) { Instances::const_iterator ii = _instances.begin(); (*ii)->output(out, indent_level, scope, complete); diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 221297061d..27699d711b 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -16,6 +16,10 @@ #include "cppSimpleType.h" #include "cppInstance.h" +using std::ostream; +using std::ostringstream; +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppGlobals.cxx b/dtool/src/cppparser/cppGlobals.cxx index a435227203..f537ce8c42 100644 --- a/dtool/src/cppparser/cppGlobals.cxx +++ b/dtool/src/cppparser/cppGlobals.cxx @@ -13,4 +13,4 @@ #include "cppGlobals.h" -string cpp_longlong_keyword; +std::string cpp_longlong_keyword; diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 9fd7b500c8..43c937177b 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -19,6 +19,8 @@ #include "cppTBDType.h" #include "cppStructType.h" +using std::string; + /** * @@ -546,7 +548,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPIdentifier:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { if (scope == nullptr) { output_fully_scoped_name(out); } else { @@ -559,7 +561,7 @@ output(ostream &out, CPPScope *scope) const { * */ void CPPIdentifier:: -output_local_name(ostream &out, CPPScope *scope) const { +output_local_name(std::ostream &out, CPPScope *scope) const { assert(!_names.empty()); if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { @@ -583,7 +585,7 @@ output_local_name(ostream &out, CPPScope *scope) const { * */ void CPPIdentifier:: -output_fully_scoped_name(ostream &out) const { +output_fully_scoped_name(std::ostream &out) const { if (_native_scope != nullptr) { _native_scope->output(out, nullptr); out << "::"; diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index eb71e47315..cb59e9a048 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -26,6 +26,8 @@ #include +using std::string; + /** * */ @@ -506,7 +508,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPInstance:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { output(out, indent_level, scope, complete, -1); } @@ -515,7 +517,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * function prototype. See CPPFunctionType::output(). */ void CPPInstance:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete, +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { assert(_type != nullptr); diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index b75dfc6424..878d751285 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -119,8 +119,8 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ if (_ident != nullptr && _ident->get_simple_name().substr(0, 9) == "operator ") { - if (_ident->get_simple_name() != string("operator ()") && - _ident->get_simple_name() != string("operator []")) { + if (_ident->get_simple_name() != std::string("operator ()") && + _ident->get_simple_name() != std::string("operator []")) { if (params->_parameters.empty()) { flags |= CPPFunctionType::F_unary_op; } @@ -184,7 +184,7 @@ add_trailing_return_type(CPPType *type) { return; } } - cerr << "trailing return type can only be added to a function\n"; + std::cerr << "trailing return type can only be added to a function\n"; } /** @@ -296,7 +296,7 @@ r_unroll_type(CPPType *start_type, if (simple_type != nullptr && simple_type->_type == CPPSimpleType::T_auto) { return_type = mod._trailing_return_type; } else { - cerr << "function with trailing return type needs auto\n"; + std::cerr << "function with trailing return type needs auto\n"; } } result = new CPPFunctionType(return_type, mod._func_params, @@ -312,7 +312,7 @@ r_unroll_type(CPPType *start_type, break; default: - cerr << "Internal error--invalid CPPInstanceIdentifier\n"; + std::cerr << "Internal error--invalid CPPInstanceIdentifier\n"; abort(); } diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index 795677513e..6a2951d9cb 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -19,8 +19,6 @@ #include #include -using namespace std; - class CPPIdentifier; class CPPParameterList; class CPPType; diff --git a/dtool/src/cppparser/cppMakeProperty.cxx b/dtool/src/cppparser/cppMakeProperty.cxx index e75cfb5676..1846092eaa 100644 --- a/dtool/src/cppparser/cppMakeProperty.cxx +++ b/dtool/src/cppparser/cppMakeProperty.cxx @@ -38,7 +38,7 @@ CPPMakeProperty(CPPIdentifier *ident, Type type, /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_simple_name() const { return _ident->get_simple_name(); } @@ -46,7 +46,7 @@ get_simple_name() const { /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -54,7 +54,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -63,7 +63,7 @@ get_fully_scoped_name() const { * */ void CPPMakeProperty:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_length_function != nullptr) { out << "__make_seq_property"; } else { diff --git a/dtool/src/cppparser/cppMakeSeq.cxx b/dtool/src/cppparser/cppMakeSeq.cxx index d9b5ac7fcd..b032d367bb 100644 --- a/dtool/src/cppparser/cppMakeSeq.cxx +++ b/dtool/src/cppparser/cppMakeSeq.cxx @@ -32,7 +32,7 @@ CPPMakeSeq(CPPIdentifier *ident, /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_simple_name() const { return _ident->get_simple_name(); } @@ -40,7 +40,7 @@ get_simple_name() const { /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -48,7 +48,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -57,7 +57,7 @@ get_fully_scoped_name() const { * */ void CPPMakeSeq:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << "__make_seq(" << _ident->get_local_name(scope) << ", " << _length_getter->_name << ", " << _element_getter->_name diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index faaaced2d8..2fc85783a7 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -16,6 +16,8 @@ #include +using std::string; + /** * */ @@ -252,7 +254,7 @@ determine_type() const { * */ void CPPManifest:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name; if (_has_parameters) { diff --git a/dtool/src/cppparser/cppNameComponent.cxx b/dtool/src/cppparser/cppNameComponent.cxx index b5c7f825aa..1c8e4df88b 100644 --- a/dtool/src/cppparser/cppNameComponent.cxx +++ b/dtool/src/cppparser/cppNameComponent.cxx @@ -14,6 +14,8 @@ #include "cppNameComponent.h" #include "cppTemplateParameterList.h" +using std::string; + /** * */ @@ -83,7 +85,7 @@ get_name() const { */ string CPPNameComponent:: get_name_with_templ(CPPScope *scope) const { - ostringstream strm; + std::ostringstream strm; strm << _name; if (_templ != nullptr) { strm << "< "; @@ -157,7 +159,7 @@ set_templ(CPPTemplateParameterList *templ) { * */ void CPPNameComponent:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name; if (_templ != nullptr) { out << "< " << *_templ << " >"; diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index cdeb293fca..a33de22a39 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -19,8 +19,6 @@ #include -using namespace std; - class CPPTemplateParameterList; class CPPScope; diff --git a/dtool/src/cppparser/cppNamespace.cxx b/dtool/src/cppparser/cppNamespace.cxx index c8e84a3725..9a6f608f49 100644 --- a/dtool/src/cppparser/cppNamespace.cxx +++ b/dtool/src/cppparser/cppNamespace.cxx @@ -31,7 +31,7 @@ CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_simple_name() const { if (_ident == nullptr) { return ""; @@ -42,7 +42,7 @@ get_simple_name() const { /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_local_name(CPPScope *scope) const { if (_ident == nullptr) { return ""; @@ -53,7 +53,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_fully_scoped_name() const { if (_ident == nullptr) { return ""; @@ -73,7 +73,7 @@ get_scope() const { * */ void CPPNamespace:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_is_inline) { out << "inline "; } diff --git a/dtool/src/cppparser/cppParameterList.cxx b/dtool/src/cppparser/cppParameterList.cxx index 6ecdbc665d..4fc5198b6e 100644 --- a/dtool/src/cppparser/cppParameterList.cxx +++ b/dtool/src/cppparser/cppParameterList.cxx @@ -198,7 +198,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { * shown. */ void CPPParameterList:: -output(ostream &out, CPPScope *scope, bool parameter_names, +output(std::ostream &out, CPPScope *scope, bool parameter_names, int num_default_parameters) const { if (!_parameters.empty()) { for (int i = 0; i < (int)_parameters.size(); ++i) { diff --git a/dtool/src/cppparser/cppParser.cxx b/dtool/src/cppparser/cppParser.cxx index 6b13d95dec..f236a238c9 100644 --- a/dtool/src/cppparser/cppParser.cxx +++ b/dtool/src/cppparser/cppParser.cxx @@ -59,7 +59,7 @@ parse_file(const Filename &filename) { } if (!init_cpp(file)) { - cerr << "Unable to read " << filename << "\n"; + std::cerr << "Unable to read " << filename << "\n"; return false; } parse_cpp(this); @@ -72,7 +72,7 @@ parse_file(const Filename &filename) { * an expression. Returns NULL if the string is not a valid expression. */ CPPExpression *CPPParser:: -parse_expr(const string &expr) { +parse_expr(const std::string &expr) { YYLTYPE loc = {}; return CPPPreprocessor::parse_expr(expr, this, this, loc); } @@ -82,7 +82,7 @@ parse_expr(const string &expr) { * CPPType. Returns NULL if the string is not a valid type. */ CPPType *CPPParser:: -parse_type(const string &type) { +parse_type(const std::string &type) { CPPTypeParser ep(this, this); ep._verbose = 0; if (ep.parse_type(type, *this)) { diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 9185455350..bba2a82333 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -205,7 +205,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPPointerType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != (CPPFunctionType *)NULL) { @@ -235,10 +235,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPPointerType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { - string star = "*"; +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { + std::string star = "*"; CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != nullptr && diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 2a6c3270bc..24784a98c8 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -35,6 +35,9 @@ #include #include +using std::cerr; +using std::string; + // We manage our own visibility counter, in addition to that managed by // cppBison.y. We do this just so we can define manifests with the correct // visibility when they are declared. (Asking the parser for the current @@ -137,7 +140,7 @@ connect_input(const string &input) { assert(_in == nullptr); _input = input; - _in = new istringstream(_input); + _in = new std::istringstream(_input); return !_in->fail(); } @@ -1491,7 +1494,7 @@ handle_define_directive(const string &args, const YYLTYPE &loc) { } } - pair result = + std::pair result = _manifests.insert(Manifests::value_type(manifest->_name, manifest)); if (!result.second) { @@ -1555,7 +1558,7 @@ handle_if_directive(const string &args, const YYLTYPE &loc) { if (ep.parse_expr(expr, *this)) { CPPExpression::Result result = ep._expr->evaluate(); if (result._type == CPPExpression::RT_error) { - ostringstream strm; + std::ostringstream strm; strm << *ep._expr; warning("Ignoring invalid expression " + strm.str(), loc); } else { diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index 0b351c830e..42526789a3 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -210,7 +210,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPReferenceType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* _pointing_at->output(out, indent_level, scope, complete); out << " &"; @@ -224,9 +224,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPReferenceType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { if (_value_category == VC_rvalue) { _pointing_at->output_instance(out, indent_level, scope, complete, diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 878daa8812..af6404e4dd 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -33,6 +33,11 @@ #include "cppBisonDefs.h" #include "indent.h" +using std::ostream; +using std::ostringstream; +using std::pair; +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index 44fcc25fef..2631d6097a 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -25,8 +25,6 @@ #include #include -using namespace std; - class CPPType; class CPPDeclaration; class CPPExtensionType; diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index 321e76c3cd..1ed364a175 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -133,7 +133,7 @@ is_parameter_expr() const { /** * */ -string CPPSimpleType:: +std::string CPPSimpleType:: get_preferred_name() const { // Simple types always prefer to use their native types. return get_local_name(); @@ -143,7 +143,7 @@ get_preferred_name() const { * */ void CPPSimpleType:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { if (_flags & F_unsigned) { out << "unsigned "; } diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index 25337642a0..d0707c4404 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -28,7 +28,7 @@ * */ void CPPStructType::Base:: -output(ostream &out) const { +output(std::ostream &out) const { if (_is_virtual) { out << "virtual "; } @@ -545,6 +545,13 @@ is_copy_constructible(CPPVisibility min_vis) const { return true; } + if (get_move_constructor() != nullptr || + get_move_assignment_operator() != nullptr) { + // A user-declared move constructor or move assignment operator means that + // the implicitly-declared copy constructor is deleted. + return false; + } + CPPInstance *destructor = get_destructor(); if (destructor != nullptr) { if (destructor->_vis > min_vis) { @@ -1240,7 +1247,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPStructType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { @@ -1351,7 +1358,7 @@ get_virtual_funcs(VFunctions &funcs) const { } else { // Non-destructors we can try to match up by name. - string fname = inst->get_local_name(); + std::string fname = inst->get_local_name(); CPPScope::Functions::const_iterator fi; fi = _scope->_functions.find(fname); diff --git a/dtool/src/cppparser/cppTBDType.cxx b/dtool/src/cppparser/cppTBDType.cxx index 664787cbe6..5c583453ca 100644 --- a/dtool/src/cppparser/cppTBDType.cxx +++ b/dtool/src/cppparser/cppTBDType.cxx @@ -56,7 +56,7 @@ is_tbd() const { * include any scoping operators or template parameters, so it may not be a * compilable reference to the type. */ -string CPPTBDType:: +std::string CPPTBDType:: get_simple_name() const { return _ident->get_simple_name(); } @@ -65,7 +65,7 @@ get_simple_name() const { * Returns the compilable, correct name for this type within the indicated * scope. If the scope is NULL, within the scope the type is declared in. */ -string CPPTBDType:: +std::string CPPTBDType:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -74,7 +74,7 @@ get_local_name(CPPScope *scope) const { * Returns the compilable, correct name for the type, with completely explicit * scoping. */ -string CPPTBDType:: +std::string CPPTBDType:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -128,7 +128,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTBDType:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { out /* << "typename " */ << *_ident; } diff --git a/dtool/src/cppparser/cppTemplateParameterList.cxx b/dtool/src/cppparser/cppTemplateParameterList.cxx index 24ee70e9e4..fd12967711 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.cxx +++ b/dtool/src/cppparser/cppTemplateParameterList.cxx @@ -26,9 +26,9 @@ CPPTemplateParameterList() { /** * */ -string CPPTemplateParameterList:: +std::string CPPTemplateParameterList:: get_string() const { - ostringstream strname; + std::ostringstream strname; strname << "< " << *this << " >"; return strname.str(); } @@ -197,7 +197,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTemplateParameterList:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { if (!_parameters.empty()) { Parameters::const_iterator pi = _parameters.begin(); (*pi)->output(out, 0, scope, false); @@ -217,7 +217,7 @@ output(ostream &out, CPPScope *scope) const { * trailing newline. */ void CPPTemplateParameterList:: -write_formal(ostream &out, CPPScope *scope) const { +write_formal(std::ostream &out, CPPScope *scope) const { out << "template<"; if (!_parameters.empty()) { Parameters::const_iterator pi = _parameters.begin(); diff --git a/dtool/src/cppparser/cppTemplateScope.cxx b/dtool/src/cppparser/cppTemplateScope.cxx index 34482ad64b..a71c176005 100644 --- a/dtool/src/cppparser/cppTemplateScope.cxx +++ b/dtool/src/cppparser/cppTemplateScope.cxx @@ -17,6 +17,8 @@ #include "cppIdentifier.h" #include "cppTypedefType.h" +using std::string; + /** * */ @@ -154,7 +156,7 @@ get_fully_scoped_name() const { * */ void CPPTemplateScope:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { CPPScope::output(out, scope); out << "< "; _parameters.output(out, scope); diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index 8504150bbd..5649d4a612 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -23,7 +23,7 @@ */ CPPToken:: CPPToken(int token, int line_number, int col_number, - const CPPFile &file, const string &str, + const CPPFile &file, const std::string &str, const YYSTYPE &lval) : _token(token), _lval(lval) { @@ -39,7 +39,7 @@ CPPToken(int token, int line_number, int col_number, * */ CPPToken:: -CPPToken(int token, const YYLTYPE &loc, const string &str, const YYSTYPE &val) : +CPPToken(int token, const YYLTYPE &loc, const std::string &str, const YYSTYPE &val) : _token(token), _lval(val), _lloc(loc) { _lval.str = str; @@ -90,7 +90,7 @@ is_eof() const { * */ void CPPToken:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_token) { case REAL: out << "REAL " << _lval.u.real; diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index 26581c7205..eea6f47bf6 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -20,6 +20,8 @@ #include "cppExtensionType.h" #include +using std::string; + CPPType::Types CPPType::_types; CPPType::PreferredNames CPPType::_preferred_names; CPPType::AltNames CPPType::_alt_names; @@ -306,7 +308,7 @@ get_simple_name() const { */ string CPPType:: get_local_name(CPPScope *scope) const { - ostringstream ostrm; + std::ostringstream ostrm; output(ostrm, 0, scope, false); return ostrm.str(); } @@ -419,7 +421,7 @@ is_convertible_to(const CPPType *other) const { * have special exceptions. */ void CPPType:: -output_instance(ostream &out, const string &name, CPPScope *scope) const { +output_instance(std::ostream &out, const string &name, CPPScope *scope) const { output_instance(out, 0, scope, false, "", name); } @@ -429,7 +431,7 @@ output_instance(ostream &out, const string &name, CPPScope *scope) const { * have special exceptions. */ void CPPType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, +output_instance(std::ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { output(out, indent_level, scope, complete); @@ -454,7 +456,7 @@ as_type() { */ CPPType *CPPType:: new_type(CPPType *type) { - pair result = _types.insert(type); + std::pair result = _types.insert(type); if (result.second) { // The insertion has taken place; thus, this is the first time this type // has been declared. diff --git a/dtool/src/cppparser/cppTypeDeclaration.cxx b/dtool/src/cppparser/cppTypeDeclaration.cxx index 23c72cd2d0..84b6075172 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.cxx +++ b/dtool/src/cppparser/cppTypeDeclaration.cxx @@ -46,7 +46,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTypeDeclaration:: -output(ostream &out, int indent_level, CPPScope *scope, bool) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool) const { _type->output(out, indent_level, scope, true); } diff --git a/dtool/src/cppparser/cppTypeParser.cxx b/dtool/src/cppparser/cppTypeParser.cxx index b88a1a079d..cdaa1d0288 100644 --- a/dtool/src/cppparser/cppTypeParser.cxx +++ b/dtool/src/cppparser/cppTypeParser.cxx @@ -36,9 +36,9 @@ CPPTypeParser:: * */ bool CPPTypeParser:: -parse_type(const string &type) { +parse_type(const std::string &type) { if (!init_type(type)) { - cerr << "Unable to parse type\n"; + std::cerr << "Unable to parse type\n"; return false; } @@ -51,9 +51,9 @@ parse_type(const string &type) { * */ bool CPPTypeParser:: -parse_type(const string &type, const CPPPreprocessor &filepos) { +parse_type(const std::string &type, const CPPPreprocessor &filepos) { if (!init_type(type)) { - cerr << "Unable to parse type\n"; + std::cerr << "Unable to parse type\n"; return false; } @@ -68,7 +68,7 @@ parse_type(const string &type, const CPPPreprocessor &filepos) { * */ void CPPTypeParser:: -output(ostream &out) const { +output(std::ostream &out) const { if (_type == nullptr) { out << "(null type)"; } else { diff --git a/dtool/src/cppparser/cppTypeProxy.cxx b/dtool/src/cppparser/cppTypeProxy.cxx index fe6bfb7c05..4843ac5b34 100644 --- a/dtool/src/cppparser/cppTypeProxy.cxx +++ b/dtool/src/cppparser/cppTypeProxy.cxx @@ -14,6 +14,8 @@ #include "cppTypeProxy.h" #include "cppFile.h" +using std::string; + /** * */ @@ -144,7 +146,7 @@ is_incomplete() const { * have special exceptions. */ void CPPTypeProxy:: -output_instance(ostream &out, int indent_level, CPPScope *scope, +output_instance(std::ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { if (_actual_type == nullptr) { @@ -159,7 +161,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, * */ void CPPTypeProxy:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_actual_type == nullptr) { out << "unknown"; return; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index 32d4c55865..6924fca4a0 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -17,6 +17,8 @@ #include "cppTemplateScope.h" #include "indent.h" +using std::string; + /** * */ @@ -373,7 +375,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPTypedefType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { string name; if (_ident != nullptr) { name = _ident->get_local_name(scope); diff --git a/dtool/src/cppparser/cppUsing.cxx b/dtool/src/cppparser/cppUsing.cxx index 3611450de6..146f8f3f48 100644 --- a/dtool/src/cppparser/cppUsing.cxx +++ b/dtool/src/cppparser/cppUsing.cxx @@ -28,7 +28,7 @@ CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file) : * */ void CPPUsing:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { out << "using "; if (_full_namespace) { out << "namespace "; diff --git a/dtool/src/cppparser/cppVisibility.cxx b/dtool/src/cppparser/cppVisibility.cxx index 6cee2a70f3..92273c00a3 100644 --- a/dtool/src/cppparser/cppVisibility.cxx +++ b/dtool/src/cppparser/cppVisibility.cxx @@ -13,8 +13,8 @@ #include "cppVisibility.h" -ostream & -operator << (ostream &out, CPPVisibility vis) { +std::ostream & +operator << (std::ostream &out, CPPVisibility vis) { switch (vis) { case V_published: return out << "__published"; diff --git a/dtool/src/dconfig/test_config.cxx b/dtool/src/dconfig/test_config.cxx index 40f27e7197..2374bd775e 100644 --- a/dtool/src/dconfig/test_config.cxx +++ b/dtool/src/dconfig/test_config.cxx @@ -13,6 +13,9 @@ #include "dconfig.h" +using std::cout; +using std::endl; + #define SNARF Configure(test); diff --git a/dtool/src/dconfig/test_expand.cxx b/dtool/src/dconfig/test_expand.cxx index 281e8b02ba..334bf2593d 100644 --- a/dtool/src/dconfig/test_expand.cxx +++ b/dtool/src/dconfig/test_expand.cxx @@ -14,6 +14,9 @@ #include "expand.h" #include +using std::cout; +using std::endl; + void TestExpandFunction() { std::string line; diff --git a/dtool/src/dconfig/test_pfstream.cxx b/dtool/src/dconfig/test_pfstream.cxx index 29874a97ac..9b211c2381 100644 --- a/dtool/src/dconfig/test_pfstream.cxx +++ b/dtool/src/dconfig/test_pfstream.cxx @@ -14,13 +14,13 @@ #include "pfstream.h" #include -void ReadIt(istream& ifs) { +void ReadIt(std::istream& ifs) { std::string line; while (!ifs.eof()) { std::getline(ifs, line); if (line.length() != 0) - cout << line << endl; + std::cout << line << std::endl; } } diff --git a/dtool/src/dconfig/test_searchpath.cxx b/dtool/src/dconfig/test_searchpath.cxx index edcb8a13cd..4abf1f71bd 100644 --- a/dtool/src/dconfig/test_searchpath.cxx +++ b/dtool/src/dconfig/test_searchpath.cxx @@ -15,6 +15,9 @@ // #include "expand.h" #include +using std::cout; +using std::endl; + void TestSearch() { std::string line, path; diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 303c9f1223..d009510ad3 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -24,7 +24,7 @@ DeletedBufferChain(size_t buffer_size) { _buffer_size = buffer_size; // We must allocate at least this much space for bookkeeping reasons. - _buffer_size = max(_buffer_size, sizeof(ObjectNode)); + _buffer_size = std::max(_buffer_size, sizeof(ObjectNode)); } /** diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index db12cc8737..ff52c6291a 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -97,10 +97,12 @@ typedef std::ios::seekdir ios_seekdir; // in some important missing functions. #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 #include +#include namespace std { using std::tr1::tuple; using std::tr1::tie; + using std::tr1::copysign; typedef decltype(nullptr) nullptr_t; @@ -111,6 +113,8 @@ namespace std { template typename remove_reference::type &&move(T &&t) { return static_cast::type&&>(t); } + + template struct owner_less; }; #endif @@ -158,36 +162,6 @@ namespace std { #endif // CPPPARSER -// This was previously `using namespace std`, but we don't want to pull in the -// entire namespace, so we enumerate the things we are using without std:: -// prefix in the Panda headers. It is intended that this list will shrink. -using std::cerr; -using std::cin; -using std::cout; -using std::dec; -using std::endl; -using std::hex; -using std::ios; -using std::iostream; -using std::istream; -using std::istringstream; -using std::max; -using std::min; -using std::move; -using std::ostream; -using std::ostringstream; -using std::pair; -using std::setfill; -using std::setw; -using std::streambuf; -using std::streamoff; -using std::streampos; -using std::streamsize; -using std::string; -using std::stringstream; -using std::swap; -using std::wstring; - // The ReferenceCount class is defined later, within Panda, but we need to // pass around forward references to it here at the very low level. class ReferenceCount; diff --git a/dtool/src/dtoolbase/indent.cxx b/dtool/src/dtoolbase/indent.cxx index bf33828d03..df66a47197 100644 --- a/dtool/src/dtoolbase/indent.cxx +++ b/dtool/src/dtoolbase/indent.cxx @@ -16,8 +16,8 @@ /** * */ -ostream & -indent(ostream &out, int indent_level) { +std::ostream & +indent(std::ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { out << ' '; } diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 82ee8dc037..24d5f11a11 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -37,6 +37,8 @@ #endif // WIN32 +using std::cerr; + // Ensure we made the right decisions about the alignment size. static_assert(MEMORY_HOOK_ALIGNMENT >= sizeof(size_t), "MEMORY_HOOK_ALIGNMENT should at least be sizeof(size_t)"); @@ -423,7 +425,7 @@ heap_realloc_array(void *ptr, size_t size) { size_t orig_delta = (char *)ptr - (char *)alloc; size_t new_delta = (char *)ptr1 - (char *)alloc1; if (orig_delta != new_delta) { - memmove((char *)alloc1 + new_delta, (char *)alloc1 + orig_delta, min(size, orig_size)); + memmove((char *)alloc1 + new_delta, (char *)alloc1 + orig_delta, std::min(size, orig_size)); } root[-2] = size; diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index b933007dd5..bd7c1c1481 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -61,7 +61,7 @@ ns_alloc(size_t size) { // We have to allocate a new page. Allocate at least min_page_size bytes, // and then round that up to the next _page_size bytes. - size_t needed_size = max(size, min_page_size); + size_t needed_size = std::max(size, min_page_size); needed_size = memory_hook->round_up_to_page_size(needed_size); void *start = memory_hook->mmap_alloc(needed_size, false); _total_alloc += needed_size; diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index b5158810df..d61ca64ceb 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -20,8 +20,6 @@ #include "deletedChain.h" #include "typeHandle.h" -using std::allocator; - /** * This is our own Panda specialization on the default STL allocator. Its * main purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index b4c71c81eb..e7e9f96c28 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -27,8 +27,6 @@ #else -using std::deque; - /** * This is our own Panda specialization on the default STL deque. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 0ddef3c9f1..12d29880f3 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -26,8 +26,6 @@ #else -using std::list; - /** * This is our own Panda specialization on the default STL list. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 0f960ac9d5..6ddb38edee 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -40,9 +40,6 @@ #else // USE_STL_ALLOCATOR -using std::map; -using std::multimap; - /** * This is our own Panda specialization on the default STL map. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 7b51cf787d..ff54486dfe 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -40,9 +40,6 @@ #else // USE_STL_ALLOCATOR -using std::set; -using std::multiset; - /** * This is our own Panda specialization on the default STL set. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index f88b625bca..4199506d13 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -33,8 +33,6 @@ class pvector : public std::vector { #else -using std::vector; - /** * This is our own Panda specialization on the default STL vector. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/test_strtod.cxx b/dtool/src/dtoolbase/test_strtod.cxx index 169e90bfcf..1071a89273 100644 --- a/dtool/src/dtoolbase/test_strtod.cxx +++ b/dtool/src/dtoolbase/test_strtod.cxx @@ -26,9 +26,9 @@ main(int argc, char *argv[]) { for (int i = 1; i < argc; ++i) { char *endptr = nullptr; double result = pstrtod(argv[i], &endptr); - cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; + std::cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; result = strtod(argv[i], &endptr); - cerr << "strtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; + std::cerr << "strtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; } return 0; diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index c3cad42e8c..1b96352723 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -55,7 +55,7 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; if (rnode->_memory_usage[memory_class] < 0) { - cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; + std::cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; abort(); } } @@ -102,7 +102,7 @@ allocate_array(size_t size) { assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)alloc_size); if (rnode->_memory_usage[MC_array] < 0) { - cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; + std::cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; abort(); } } @@ -175,8 +175,8 @@ get_best_parent_from_Set(const std::set< int > &legal_vals) const { return -1; } -ostream & -operator << (ostream &out, TypeHandle::MemoryClass mem_class) { +std::ostream & +operator << (std::ostream &out, TypeHandle::MemoryClass mem_class) { switch (mem_class) { case TypeHandle::MC_singleton: return out << "singleton"; diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index d7077727e1..23cdb5ebfb 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -20,6 +20,11 @@ #include +using std::cerr; +using std::ostream; +using std::ostringstream; +using std::string; + MutexImpl *TypeRegistry::_lock = nullptr; TypeRegistry *TypeRegistry::_global_pointer = nullptr; diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index 6d8d85ffc5..f809ddcc0b 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -22,7 +22,7 @@ bool TypeRegistryNode::_paranoid_inheritance = false; * */ TypeRegistryNode:: -TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref) : +TypeRegistryNode(TypeHandle handle, const std::string &name, TypeHandle &ref) : _handle(handle), _name(name), _ref(ref) { clear_subtree(); @@ -54,19 +54,19 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { if (_paranoid_inheritance) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { - cerr + std::cerr << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " << paranoid_derives << "\n" << "Classes are in the same single inheritance subtree, children of " << child->_inherit._top->_name << "\n" - << hex + << std::hex << child->_name << " has mask " << child->_inherit._mask << " and bits " << child->_inherit._bits << "\n" << base->_name << " has mask " << base->_inherit._mask << " and bits " << base->_inherit._bits << "\n" - << dec; + << std::dec; return paranoid_derives; } } @@ -118,7 +118,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { if (_paranoid_inheritance) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { - cerr + std::cerr << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " @@ -280,7 +280,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, // We need at least one bit, even if there is only one child, so we can // differentiate parent from child. - more_bits = max(more_bits, 1); + more_bits = std::max(more_bits, 1); assert(more_bits < (int)(sizeof(SubtreeMaskType) * 8)); diff --git a/dtool/src/dtoolbase/typedObject.cxx b/dtool/src/dtoolbase/typedObject.cxx index a397ef843e..73a2cfc9c2 100644 --- a/dtool/src/dtoolbase/typedObject.cxx +++ b/dtool/src/dtoolbase/typedObject.cxx @@ -31,7 +31,7 @@ get_type() const { // Normally, this function should never be called, because it is a pure // virtual function. If it is called, you probably called get_type() on a // recently-destructed object. - cerr + std::cerr << "TypedObject::get_type() called!\n"; return _type_handle; } diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index f30f2156fc..4a094f1d98 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -17,6 +17,9 @@ #include #include +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index a2baf28343..4152a8c356 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -18,6 +18,9 @@ #include #include // for perror +using std::cerr; +using std::string; + #ifdef __APPLE__ #include // for realpath #endif // __APPLE__ @@ -554,7 +557,7 @@ read_args() { wchar_t buffer[buffer_size]; DWORD size = GetModuleFileNameW(dllhandle, buffer, buffer_size); if (size != 0) { - Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); + Filename tmp = Filename::from_os_specific_w(std::wstring(buffer, size)); tmp.make_true_case(); _dtool_name = tmp; } @@ -654,7 +657,7 @@ read_args() { wchar_t buffer[buffer_size]; DWORD size = GetModuleFileNameW(nullptr, buffer, buffer_size); if (size != 0) { - Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); + Filename tmp = Filename::from_os_specific_w(std::wstring(buffer, size)); tmp.make_true_case(); _binary_name = tmp; } @@ -727,7 +730,7 @@ read_args() { encoder.set_encoding(Filename::get_filesystem_encoding()); for (int i = 0; i < argc; ++i) { - wstring wtext(wargv[i]); + std::wstring wtext(wargv[i]); encoder.set_wtext(wtext); if (i == 0) { diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 61816e7a44..da5657dd9d 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -53,6 +53,11 @@ #include #endif +using std::cerr; +using std::ios; +using std::string; +using std::wstring; + TextEncoder::Encoding Filename::_filesystem_encoding = TextEncoder::E_utf8; TVOLATILE AtomicAdjust::Pointer Filename::_home_directory; @@ -832,9 +837,9 @@ get_filename_index(int index) const { Filename file(*this); if (_hash_end != _hash_start) { - ostringstream strm; + std::ostringstream strm; strm << _filename.substr(0, _hash_start) - << setw((int)(_hash_end - _hash_start)) << setfill('0') << index + << std::setw((int)(_hash_end - _hash_start)) << std::setfill('0') << index << _filename.substr(_hash_end); file.set_fullpath(strm.str()); } @@ -1542,7 +1547,7 @@ get_access_timestamp() const { /** * Returns the size of the file in bytes, or 0 if there is an error. */ -streamsize Filename:: +std::streamsize Filename:: get_file_size() const { #ifdef WIN32_VC wstring os_specific = get_filename_index(0).to_os_specific_w(); diff --git a/dtool/src/dtoolutil/filename_assist.mm b/dtool/src/dtoolutil/filename_assist.mm index e27c4d1ece..3192fc58e2 100644 --- a/dtool/src/dtoolutil/filename_assist.mm +++ b/dtool/src/dtoolutil/filename_assist.mm @@ -22,6 +22,8 @@ #include #endif +using std::string; + /** * Copy the Objective-C string to a C++ string. */ diff --git a/dtool/src/dtoolutil/filename_ext.cxx b/dtool/src/dtoolutil/filename_ext.cxx index 196492d23f..e60bf83a90 100644 --- a/dtool/src/dtoolutil/filename_ext.cxx +++ b/dtool/src/dtoolutil/filename_ext.cxx @@ -13,6 +13,9 @@ #include "filename_ext.h" +using std::string; +using std::wstring; + #ifdef HAVE_PYTHON #ifndef CPPPARSER diff --git a/dtool/src/dtoolutil/globPattern.cxx b/dtool/src/dtoolutil/globPattern.cxx index 57a6afdb57..982fe3bb1d 100644 --- a/dtool/src/dtoolutil/globPattern.cxx +++ b/dtool/src/dtoolutil/globPattern.cxx @@ -14,6 +14,8 @@ #include "globPattern.h" #include +using std::string; + /** * Returns true if the pattern includes any special globbing characters, or * false if it is just a literal string. diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index 4e9f990540..8ac3ed74f2 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -13,6 +13,8 @@ #include "lineStreamBuf.h" +using std::string; + /** * */ @@ -65,7 +67,7 @@ get_line() { */ int LineStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); // Reset pptr(). return 0; // EOF to indicate write full. @@ -77,7 +79,7 @@ sync() { */ int LineStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index a54763afb1..79d821b5fa 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -14,6 +14,8 @@ #include "load_dso.h" #include "executionEnvironment.h" +using std::string; + static Filename resolve_dso(const DSearchPath &path, const Filename &filename) { if (filename.is_local()) { if ((path.get_num_directories()==1)&&(path.get_directory(0)=="")) { @@ -47,7 +49,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { if (!abspath.is_regular_file()) { return nullptr; } - wstring os_specific_w = abspath.to_os_specific_w(); + std::wstring os_specific_w = abspath.to_os_specific_w(); // Try using LoadLibraryEx, if possible. typedef HMODULE (WINAPI *tLoadLibraryEx)(LPCWSTR, HANDLE, DWORD); @@ -104,7 +106,7 @@ load_dso_error() { } // Some unknown error code. - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "Unknown error " << last_error; return errmsg.str(); } diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 2e2c0ec035..676f17e0e6 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -25,6 +25,16 @@ #include #endif // _WIN32 +using std::cerr; +using std::dec; +using std::hex; +using std::ios; +using std::istream; +using std::ostream; +using std::streamoff; +using std::streampos; +using std::string; + PandaFileStreamBuf::NewlineMode PandaFileStreamBuf::_newline_mode = NM_native; static const size_t file_buffer_size = 4096; @@ -130,7 +140,7 @@ open(const char *filename, ios::openmode mode) { TextEncoder encoder; encoder.set_encoding(Filename::get_filesystem_encoding()); encoder.set_text(_filename); - wstring wfilename = encoder.get_wtext(); + std::wstring wfilename = encoder.get_wtext(); _handle = CreateFileW(wfilename.c_str(), access, share_mode, nullptr, creation_disposition, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index 5e7cc4b913..3d80d0f6b5 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -15,6 +15,8 @@ #include "pandaVersion.h" #include "dtool_platform.h" +using std::string; + PandaSystem *PandaSystem::_global_ptr = nullptr; TypeHandle PandaSystem::_type_handle; @@ -220,7 +222,7 @@ string PandaSystem:: get_compiler() { #if defined(_MSC_VER) // MSVC defines this macro. It's an integer; we need to format it. - ostringstream strm; + std::ostringstream strm; strm << "MSC v." << _MSC_VER; // We also get this suite of macros that tells us what the build platform @@ -368,7 +370,7 @@ add_system(const string &system) { void PandaSystem:: set_system_tag(const string &system, const string &tag, const string &value) { - pair result; + std::pair result; result = _systems.insert(Systems::value_type(system, SystemTags(get_class_type()))); if (result.second) { _system_names_dirty = true; @@ -399,7 +401,7 @@ heap_trim(size_t pad) { * */ void PandaSystem:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Panda version " << get_version_string(); } @@ -407,7 +409,7 @@ output(ostream &out) const { * */ void PandaSystem:: -write(ostream &out) const { +write(std::ostream &out) const { out << *this << "\n" << "compiled on " << get_build_date() << " by " << get_distributor() << "\n" @@ -433,6 +435,7 @@ write(ostream &out) const { PandaSystem *PandaSystem:: get_global_ptr() { if (_global_ptr == nullptr) { + init_type(); _global_ptr = new PandaSystem; } diff --git a/dtool/src/dtoolutil/panda_getopt_impl.cxx b/dtool/src/dtoolutil/panda_getopt_impl.cxx index 9a216bbda0..030641a357 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.cxx +++ b/dtool/src/dtoolutil/panda_getopt_impl.cxx @@ -22,6 +22,7 @@ // If the system does lack one or the other of these functions, then we'll go // ahead and provide it instead. +using std::string; char *optarg = nullptr; int optind = 0; @@ -226,7 +227,7 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { if (param._opt_index == 0 && opterr) { // This was an invalid character. optopt = param._short_option; - cerr << "Illegal option: -" << param._short_option << "\n"; + std::cerr << "Illegal option: -" << param._short_option << "\n"; return '?'; } diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index 591d2847e0..a5585ee3cd 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -14,6 +14,10 @@ #include "pfstreamBuf.h" #include +using std::cerr; +using std::endl; +using std::string; + PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir) { @@ -56,7 +60,7 @@ void PipeStreamBuf::command(const string cmd) { int PipeStreamBuf::overflow(int c) { assert(is_open()); assert(_dir == Output); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0) { write_chars(pbase(), n, false); pbump(-n); // reset pptr() @@ -72,11 +76,11 @@ int PipeStreamBuf::overflow(int c) { int PipeStreamBuf::sync(void) { assert(is_open()); if (_dir == Output) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n, false); pbump(-n); } else { - streamsize n = egptr() - gptr(); + std::streamsize n = egptr() - gptr(); if (n != 0) { gbump(n); // flush all our stored input away #ifndef NDEBUG diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index 847d8559bd..e77e0c5e13 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -14,7 +14,7 @@ #include "stringDecoder.h" #include "config_dtoolutil.h" -ostream *StringDecoder::_notify_ptr = &cerr; +std::ostream *StringDecoder::_notify_ptr = &std::cerr; /** * @@ -41,7 +41,7 @@ get_next_character() { * notify. */ void StringDecoder:: -set_notify_ptr(ostream *notify_ptr) { +set_notify_ptr(std::ostream *notify_ptr) { _notify_ptr = notify_ptr; } @@ -49,7 +49,7 @@ set_notify_ptr(ostream *notify_ptr) { * Returns the ostream that is used to write error messages to. See * set_notify_ptr(). */ -ostream *StringDecoder:: +std::ostream *StringDecoder:: get_notify_ptr() { return _notify_ptr; } @@ -131,7 +131,7 @@ get_next_character() { // utf-8 bytes--we have an error. if (_notify_ptr != nullptr) { (*_notify_ptr) - << "Non utf-8 byte in string: 0x" << hex << result << dec + << "Non utf-8 byte in string: 0x" << std::hex << result << std::dec << ", string is '" << _input << "'\n"; } return -1; diff --git a/dtool/src/dtoolutil/string_utils.cxx b/dtool/src/dtoolutil/string_utils.cxx index 600b07e7ed..50d5d53802 100644 --- a/dtool/src/dtoolutil/string_utils.cxx +++ b/dtool/src/dtoolutil/string_utils.cxx @@ -17,6 +17,9 @@ #include +using std::string; +using std::wstring; + // Case-insensitive string comparison, from Stroustrup's C++ third edition. // Works like strcmp(). int diff --git a/dtool/src/dtoolutil/test_pfstream.cxx b/dtool/src/dtoolutil/test_pfstream.cxx index b088079723..93bebd6236 100644 --- a/dtool/src/dtoolutil/test_pfstream.cxx +++ b/dtool/src/dtoolutil/test_pfstream.cxx @@ -17,26 +17,26 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cout << "test_pfstream command-line\n"; + std::cout << "test_pfstream command-line\n"; return (1); } // Build one command out of the arguments. - string cmd; + std::string cmd; cmd = argv[1]; for (int i = 2; i < argc; i++) { cmd += " "; cmd += argv[i]; } - cout << "Executing command:\n" << cmd << "\n"; + std::cout << "Executing command:\n" << cmd << "\n"; IPipeStream in(cmd); char c; c = in.get(); while (in && !in.fail() && !in.eof()) { - cout.put(toupper(c)); + std::cout.put(toupper(c)); c = in.get(); } diff --git a/dtool/src/dtoolutil/test_touch.cxx b/dtool/src/dtoolutil/test_touch.cxx index 722a94a85e..94a7d2782c 100644 --- a/dtool/src/dtoolutil/test_touch.cxx +++ b/dtool/src/dtoolutil/test_touch.cxx @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cout << "test_touch filename [filename ... ]\n"; + std::cout << "test_touch filename [filename ... ]\n"; return (1); } diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index 90ce30d395..1e1cd4bc61 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -16,6 +16,11 @@ #include "unicodeLatinMap.h" #include "config_dtoolutil.h" +using std::istream; +using std::ostream; +using std::string; +using std::wstring; + TextEncoder::Encoding TextEncoder::_default_encoding = TextEncoder::E_iso8859; /** diff --git a/dtool/src/dtoolutil/win32ArgParser.cxx b/dtool/src/dtoolutil/win32ArgParser.cxx index 231b4af12b..4faf6bff95 100644 --- a/dtool/src/dtoolutil/win32ArgParser.cxx +++ b/dtool/src/dtoolutil/win32ArgParser.cxx @@ -24,6 +24,8 @@ #include #include +using std::string; + /** * */ @@ -97,7 +99,7 @@ set_command_line(const string &command_line) { * starts parsing this into argc, argv. */ void Win32ArgParser:: -set_command_line(const wstring &command_line) { +set_command_line(const std::wstring &command_line) { TextEncoder encoder; encoder.set_encoding(Filename::get_filesystem_encoding()); encoder.set_wtext(command_line); @@ -146,7 +148,7 @@ do_glob() { // means to do it. string envvar = ExecutionEnvironment::get_environment_variable("PANDA_GLOB"); if (!envvar.empty()) { - istringstream strm(envvar); + std::istringstream strm(envvar); int value; strm >> value; if (!strm.fail()) { diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 745d084b72..e7a2f828d9 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -32,6 +32,10 @@ #include "interrogateType.h" #include "pnotify.h" +using std::ostream; +using std::ostringstream; +using std::string; + /** * */ @@ -439,7 +443,10 @@ get_call_str(const string &container, const vector_string &pexprs) const { call << ")." << _cppfunc->get_local_name(); } else { - call << _cppfunc->get_local_name(&parser); + if (_cpptype != nullptr) { + call << _cpptype->get_local_name(&parser); + } + call << "::" << _cppfunc->get_local_name(); } } call << "("; diff --git a/dtool/src/interrogate/functionWriter.cxx b/dtool/src/interrogate/functionWriter.cxx index 6a5c3e4e34..58937d3f3d 100644 --- a/dtool/src/interrogate/functionWriter.cxx +++ b/dtool/src/interrogate/functionWriter.cxx @@ -30,7 +30,7 @@ FunctionWriter:: /** * */ -const string &FunctionWriter:: +const std::string &FunctionWriter:: get_name() const { return _name; } @@ -42,7 +42,7 @@ int FunctionWriter:: compare_to(const FunctionWriter &other) const { // Lexicographical string comparison. - string::const_iterator n1, n2; + std::string::const_iterator n1, n2; n1 = _name.begin(); n2 = other._name.begin(); while (n1 != _name.end() && n2 != other._name.end()) { @@ -65,12 +65,12 @@ compare_to(const FunctionWriter &other) const { * Outputs the prototype for the function. */ void FunctionWriter:: -write_prototype(ostream &) { +write_prototype(std::ostream &) { } /** * Outputs the code for the function. */ void FunctionWriter:: -write_code(ostream &) { +write_code(std::ostream &) { } diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.cxx b/dtool/src/interrogate/functionWriterPtrFromPython.cxx index c27ef1efe5..016d79cff7 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrFromPython.cxx @@ -43,7 +43,7 @@ FunctionWriterPtrFromPython:: * Outputs the prototype for the function. */ void FunctionWriterPtrFromPython:: -write_prototype(ostream &out) { +write_prototype(std::ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); out << "static int " << _name << "(PyObject *obj, "; @@ -57,7 +57,7 @@ write_prototype(ostream &out) { * Outputs the code for the function. */ void FunctionWriterPtrFromPython:: -write_code(ostream &out) { +write_code(std::ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); out << "static int\n" diff --git a/dtool/src/interrogate/functionWriterPtrToPython.cxx b/dtool/src/interrogate/functionWriterPtrToPython.cxx index aac2984dbc..e2486dae7c 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrToPython.cxx @@ -44,7 +44,7 @@ FunctionWriterPtrToPython:: * Outputs the prototype for the function. */ void FunctionWriterPtrToPython:: -write_prototype(ostream &out) { +write_prototype(std::ostream &out) { out << "static PyObject *" << _name << "("; _pointer_type->output_instance(out, "addr", &parser); out << ", int caller_manages);\n"; @@ -54,8 +54,8 @@ write_prototype(ostream &out) { * Outputs the code for the function. */ void FunctionWriterPtrToPython:: -write_code(ostream &out) { - string classobj_func = InterfaceMakerPythonObj::get_builder_name(_type); +write_code(std::ostream &out) { + std::string classobj_func = InterfaceMakerPythonObj::get_builder_name(_type); out << "static PyObject *\n" << _name << "("; _pointer_type->output_instance(out, "addr", &parser); diff --git a/dtool/src/interrogate/functionWriters.cxx b/dtool/src/interrogate/functionWriters.cxx index 93ee5945fc..2d1d167b2d 100644 --- a/dtool/src/interrogate/functionWriters.cxx +++ b/dtool/src/interrogate/functionWriters.cxx @@ -41,7 +41,7 @@ FunctionWriters:: */ FunctionWriter *FunctionWriters:: add_writer(FunctionWriter *writer) { - pair result = _writers.insert(writer); + std::pair result = _writers.insert(writer); if (!result.second) { // Already there; delete the pointer. delete writer; @@ -55,7 +55,7 @@ add_writer(FunctionWriter *writer) { * Generates prototypes for all of the functions. */ void FunctionWriters:: -write_prototypes(ostream &out) { +write_prototypes(std::ostream &out) { Writers::iterator wi; for (wi = _writers.begin(); wi != _writers.end(); ++wi) { FunctionWriter *writer = (*wi); @@ -67,7 +67,7 @@ write_prototypes(ostream &out) { * Generates all of the functions. */ void FunctionWriters:: -write_code(ostream &out) { +write_code(std::ostream &out) { Writers::iterator wi; for (wi = _writers.begin(); wi != _writers.end(); ++wi) { FunctionWriter *writer = (*wi); diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 69ab181286..0d4d56dfc1 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -39,6 +39,10 @@ #include "cppStructType.h" #include "pnotify.h" +using std::ostream; +using std::ostringstream; +using std::string; + InterrogateType dummy_type; /** diff --git a/dtool/src/interrogate/interfaceMakerC.cxx b/dtool/src/interrogate/interfaceMakerC.cxx index 966e9c058d..64b36fc366 100644 --- a/dtool/src/interrogate/interfaceMakerC.cxx +++ b/dtool/src/interrogate/interfaceMakerC.cxx @@ -24,6 +24,8 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; + /** * */ @@ -115,7 +117,7 @@ synthesize_this_parameter() { /** * Returns the prefix string used to generate wrapper function names. */ -string InterfaceMakerC:: +std::string InterfaceMakerC:: get_wrapper_prefix() { return "_inC"; } @@ -124,7 +126,7 @@ get_wrapper_prefix() { * Returns the prefix string used to generate unique symbolic names, which are * not necessarily C-callable function names. */ -string InterfaceMakerC:: +std::string InterfaceMakerC:: get_unique_prefix() { return "c"; } @@ -206,7 +208,7 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, write_spam_message(out, remap); } - string return_expr = + std::string return_expr = remap->call_function(out, 2, true, "param0"); return_expr = manage_return_value(out, 2, remap, return_expr); if (!return_expr.empty()) { diff --git a/dtool/src/interrogate/interfaceMakerPython.cxx b/dtool/src/interrogate/interfaceMakerPython.cxx index 31f59c0785..cfd82edf19 100644 --- a/dtool/src/interrogate/interfaceMakerPython.cxx +++ b/dtool/src/interrogate/interfaceMakerPython.cxx @@ -28,7 +28,7 @@ InterfaceMakerPython(InterrogateModuleDef *def) : * particular interface to the indicated output stream. */ void InterfaceMakerPython:: -write_includes(ostream &out) { +write_includes(std::ostream &out) { InterfaceMaker::write_includes(out); out << "#undef _POSIX_C_SOURCE\n" << "#undef _XOPEN_SOURCE\n" @@ -45,7 +45,7 @@ write_includes(ostream &out) { * was executing, and report this failure back to Python. */ void InterfaceMakerPython:: -test_assert(ostream &out, int indent_level) const { +test_assert(std::ostream &out, int indent_level) const { if (watch_asserts) { out << "#ifndef NDEBUG\n"; indent(out, indent_level) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index c040f0dc6c..3134fcb2eb 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -39,7 +39,17 @@ #include #include -extern InterrogateType dummy_type; +using std::dec; +using std::hex; +using std::max; +using std::min; +using std::oct; +using std::ostream; +using std::ostringstream; +using std::set; +using std::string; + +extern InterrogateType dummy_type; extern std::string EXPORT_IMPORT_PREFIX; #define CLASS_PREFIX "Dtool_" @@ -663,12 +673,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp return; } - CPPStructType::Derivation::const_iterator bi; - for (bi = inclass->_derivation.begin(); - bi != inclass->_derivation.end(); - ++bi) { - - const CPPStructType::Base &base = (*bi); + for (const CPPStructType::Base &base : inclass->_derivation) { // if (base._vis <= V_public) can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != nullptr) { @@ -702,7 +707,7 @@ 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 InterrogateType &itype, bool is_const) { - out << boolalpha; + out << std::boolalpha; if (!isExportThisRun(itype._cpptype)) { _external_imports.insert(TypeManager::resolve_type(itype._cpptype)); @@ -791,11 +796,10 @@ write_prototypes(ostream &out_code, ostream *out_h) { } /* - for (fi = _functions.begin(); fi != _functions.end(); ++fi) - { - Function *func = (*fi); - if (!func->_itype.is_global() && is_function_legal(func)) - write_prototype_for (out_code, func); + for (Function *func : _functions) { + if (!func->_itype.is_global() && is_function_legal(func)) { + write_prototype_for(out_code, func); + } } */ @@ -811,6 +815,11 @@ write_prototypes(ostream &out_code, ostream *out_h) { // _external_imports.insert(object->_itype._cpptype); } } + } else if (object->_itype.is_scoped_enum() && isExportThisRun(object->_itype._cpptype)) { + // Forward declare where we will put the scoped enum type. + string class_name = object->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + out_code << "static PyTypeObject *Dtool_Ptr_" << safe_name << " = nullptr;\n"; } } @@ -818,8 +827,7 @@ write_prototypes(ostream &out_code, ostream *out_h) { out_code << " * Extern declarations for imported classes\n"; out_code << " */\n"; - for (std::set::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ii++) { - CPPType *type = (*ii); + for (CPPType *type : _external_imports) { string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); @@ -916,15 +924,13 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { out_code << " */\n"; /* - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { write_prototype_for(out_code, func); } */ /* - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_constructors) { std::string fname = "int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; write_prototype_for_name(out_code, obj, func, fname); } @@ -983,9 +989,6 @@ write_functions(ostream &out) { */ void InterfaceMakerPythonNative:: write_class_details(ostream &out, Object *obj) { - Functions::iterator fi; - Function::Remaps::const_iterator ri; - // std::string cClassName = obj->_itype.get_scoped_name(); std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); std::string cClassName = obj->_itype.get_true_name(); @@ -995,8 +998,7 @@ write_class_details(ostream &out, Object *obj) { out << " */\n"; // First write out all the wrapper functions for the methods. - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { if (func) { // Write the definition of the generic wrapper function for this // function. @@ -1005,18 +1007,13 @@ write_class_details(ostream &out, Object *obj) { } // Now write out generated getters and setters for the properties. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); - + for (Property *property : obj->_properties) { write_getset(out, obj, property); } // Write the constructors. std::string fname = "static int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); - + for (Function *func : obj->_constructors) { string expected_params; write_function_for_name(out, obj, func->_remaps, fname, expected_params, true, AT_keyword_args, RF_int); } @@ -1042,17 +1039,16 @@ write_class_details(ostream &out, Object *obj) { } // Write make seqs: generated methods that return a sequence of items. - MakeSeqs::iterator msi; - for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { - if (is_function_legal((*msi)->_length_getter) && - is_function_legal((*msi)->_element_getter)) { - write_make_seq(out, obj, ClassName, cClassName, *msi); + for (MakeSeq *make_seq : obj->_make_seqs) { + if (is_function_legal(make_seq->_length_getter) && + is_function_legal(make_seq->_element_getter)) { + write_make_seq(out, obj, ClassName, cClassName, make_seq); } else { - if (!is_function_legal((*msi)->_length_getter)) { - cerr << "illegal length function for MAKE_SEQ: " << (*msi)->_length_getter->_name << "\n"; + if (!is_function_legal(make_seq->_length_getter)) { + std::cerr << "illegal length function for MAKE_SEQ: " << make_seq->_length_getter->_name << "\n"; } - if (!is_function_legal((*msi)->_element_getter)) { - cerr << "illegal element function for MAKE_SEQ: " << (*msi)->_element_getter->_name << "\n"; + if (!is_function_legal(make_seq->_element_getter)) { + std::cerr << "illegal element function for MAKE_SEQ: " << make_seq->_element_getter->_name << "\n"; } } } @@ -1287,11 +1283,11 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { 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); + for (CPPType *type : _external_imports) { + string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); - if (has_get_class_type_function(*ii)) { + if (has_get_class_type_function(type)) { out << " Dtool_Ptr_" << safe_name << " = LookupRuntimeTypedClass(" << class_name << "::get_class_type());\n"; } else { out << " Dtool_Ptr_" << safe_name << " = LookupNamedClass(\"" << class_name << "\");\n"; @@ -1310,28 +1306,36 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { int enum_count = object->_itype.number_of_enum_values(); if (object->_itype.is_scoped_enum()) { - // Convert as Python 3.4 enum. + // Convert as Python 3.4-style enum. + string class_name = object->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + CPPType *underlying_type = TypeManager::unwrap_const(object->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); - out << "#if PY_VERSION_HEX >= 0x03040000\n\n"; out << " // enum class " << object->_itype.get_scoped_name() << "\n"; out << " {\n"; out << " PyObject *members = PyTuple_New(" << enum_count << ");\n"; out << " PyObject *member;\n"; for (int xx = 0; xx < enum_count; xx++) { out << " member = PyTuple_New(2);\n" - " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" + "#if PY_MAJOR_VERSION >= 3\n" + " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" << object->_itype.get_enum_value_name(xx) << "\"));\n" + "#else\n" + " PyTuple_SET_ITEM(member, 0, PyString_FromString(\"" + << object->_itype.get_enum_value_name(xx) << "\"));\n" + "#endif\n" " PyTuple_SET_ITEM(member, 1, Dtool_WrapValue((" << cast_to << ")" << object->_itype.get_scoped_name() << "::" << object->_itype.get_enum_value_name(xx) << "));\n" " PyTuple_SET_ITEM(members, " << xx << ", member);\n"; } + out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" + << object->_itype.get_name() << "\", members, \"" + << _def->module_name << "\");\n"; out << " PyModule_AddObject(module, \"" << object->_itype.get_name() - << "\", Dtool_EnumType_Create(\"" << object->_itype.get_name() - << "\", members, \"" << _def->module_name << "\"));\n"; + << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; - out << "#endif\n"; } else { out << " // enum " << object->_itype.get_scoped_name() << "\n"; for (int xx = 0; xx < enum_count; xx++) { @@ -1545,7 +1549,6 @@ write_module_class(ostream &out, Object *obj) { is_runtime_typed = true; } - Functions::iterator fi; out << "/**\n"; out << " * Python method tables for " << ClassName << " (" << export_class_name << ")\n" ; out << " */\n"; @@ -1556,8 +1559,7 @@ write_module_class(ostream &out, Object *obj) { bool got_copy = false; bool got_deepcopy = false; - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { if (func->_name == "__copy__") { got_copy = true; } else if (func->_name == "__deepcopy__") { @@ -1594,9 +1596,7 @@ write_module_class(ostream &out, Object *obj) { bool has_nonslotted = false; - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (!is_remap_legal(remap)) { continue; } @@ -1688,9 +1688,7 @@ write_module_class(ostream &out, Object *obj) { out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, nullptr},\n"; } - MakeSeqs::iterator msi; - for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { - MakeSeq *make_seq = (*msi); + for (MakeSeq *make_seq : obj->_make_seqs) { if (!is_function_legal(make_seq->_length_getter) || !is_function_legal(make_seq->_element_getter)) { continue; @@ -1866,10 +1864,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delattr and setattr. Fish out the // remaps for both types. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_cppfunc->get_simple_name() == "__delattr__" && remap->_parameters.size() == 2) { delattr_remaps.insert(remap); @@ -2019,10 +2014,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delitem and setitem. Fish out the // remaps for either one. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_flags & FunctionRemap::F_setitem_int) { setitem_remaps.insert(remap); @@ -2088,10 +2080,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delitem and setitem. Fish out the // remaps for either one. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_flags & FunctionRemap::F_setitem) { setitem_remaps.insert(remap); @@ -2175,9 +2164,7 @@ write_module_class(ostream &out, Object *obj) { // Iterate through the remaps to find the one that matches our // parameters. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : def._remaps) { if (remap->_const_method) { if ((remap->_flags & FunctionRemap::F_explicit_self) == 0) { params_const.push_back("self"); @@ -2244,9 +2231,7 @@ write_module_class(ostream &out, Object *obj) { // Iterate through the remaps to find the one that matches our // parameters. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : def._remaps) { if (remap->_const_method) { if ((remap->_flags & FunctionRemap::F_explicit_self) == 0) { params_const.push_back("self"); @@ -2330,10 +2315,7 @@ write_module_class(ostream &out, Object *obj) { set one_param_remaps; set two_param_remaps; - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_parameters.size() == 2) { one_param_remaps.insert(remap); @@ -2447,7 +2429,7 @@ write_module_class(ostream &out, Object *obj) { // Nothing special about the wrapper function: just write it normally. string fname = "static PyObject *" + def._wrapper_name + "(PyObject *self, PyObject *args, PyObject *kwds)\n"; - vector remaps; + std::vector remaps; remaps.insert(remaps.end(), def._remaps.begin(), def._remaps.end()); string expected_params; write_function_for_name(out, obj, remaps, fname, expected_params, true, AT_keyword_args, RF_pyobject | RF_err_null); @@ -2473,7 +2455,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return nullptr;\n"; out << " }\n\n"; - out << " ostringstream os;\n"; + out << " std::ostringstream os;\n"; if (need_repr == 3) { out << " invoke_extension(local_this).python_repr(os, \"" << classNameFromCppName(ClassName, false) << "\");\n"; @@ -2503,7 +2485,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return nullptr;\n"; out << " }\n\n"; - out << " ostringstream os;\n"; + out << " std::ostringstream os;\n"; if (need_str == 2) { out << " local_this->write(os, 0);\n"; } else { @@ -2527,17 +2509,14 @@ write_module_class(ostream &out, Object *obj) { out << " return nullptr;\n"; out << " }\n\n"; - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { + for (Function *func : obj->_methods) { std::set remaps; - Function *func = (*fi); if (!func) { continue; } // We only accept comparison operators that take one parameter (besides // 'this'). - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_has_this && (remap->_args_type == AT_single_arg)) { remaps.insert(remap); } @@ -2624,9 +2603,7 @@ write_module_class(ostream &out, Object *obj) { if (obj->_properties.size() > 0) { // Write out the array of properties, telling Python which getter and // setter to call when they are assigned or queried in Python code. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); + for (Property *property : obj->_properties) { const InterrogateElement &ielem = property->_ielement; if (!property->_has_this || property->_getter_remaps.empty()) { continue; @@ -3050,10 +3027,10 @@ write_module_class(ostream &out, Object *obj) { out << " // Dependent objects\n"; if (bases.size() > 0) { string baseargs; - for (vector::iterator bi = bases.begin(); bi != bases.end(); ++bi) { - string safe_name = make_safe_name((*bi)->get_local_name(&parser)); + for (CPPType *base : bases) { + string safe_name = make_safe_name(base->get_local_name(&parser)); - if (isExportThisRun(*bi)) { + if (isExportThisRun(base)) { baseargs += ", (PyTypeObject *)&Dtool_" + safe_name; out << " Dtool_PyModuleClassInit_" << safe_name << "(nullptr);\n"; @@ -3148,29 +3125,37 @@ write_module_class(ostream &out, Object *obj) { // support recently. } else if (nested_obj->_itype.is_scoped_enum()) { - // Convert enum class as Python 3.4 enum. + // Convert enum class as Python 3.4-style enum. + string class_name = nested_obj->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + int enum_count = nested_obj->_itype.number_of_enum_values(); CPPType *underlying_type = TypeManager::unwrap_const(nested_obj->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); - out << "#if PY_VERSION_HEX >= 0x03040000\n\n"; out << " // enum class " << nested_obj->_itype.get_scoped_name() << ";\n"; out << " {\n"; out << " PyObject *members = PyTuple_New(" << enum_count << ");\n"; out << " PyObject *member;\n"; for (int xx = 0; xx < enum_count; xx++) { out << " member = PyTuple_New(2);\n" + "#if PY_MAJOR_VERSION >= 3\n" " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" << nested_obj->_itype.get_enum_value_name(xx) << "\"));\n" + "#else\n" + " PyTuple_SET_ITEM(member, 0, PyString_FromString(\"" + << nested_obj->_itype.get_enum_value_name(xx) << "\"));\n" + "#endif\n" " PyTuple_SET_ITEM(member, 1, Dtool_WrapValue((" << cast_to << ")" << nested_obj->_itype.get_scoped_name() << "::" << nested_obj->_itype.get_enum_value_name(xx) << "));\n" " PyTuple_SET_ITEM(members, " << xx << ", member);\n"; } + out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" + << nested_obj->_itype.get_name() << "\", members, \"" + << _def->module_name << "\");\n"; out << " PyDict_SetItemString(dict, \"" << nested_obj->_itype.get_name() - << "\", Dtool_EnumType_Create(\"" << nested_obj->_itype.get_name() - << "\", members, \"" << _def->module_name << "\"));\n"; + << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; - out << "#endif\n"; } else if (nested_obj->_itype.is_enum()) { out << " // enum " << nested_obj->_itype.get_scoped_name() << ";\n"; @@ -3197,9 +3182,7 @@ write_module_class(ostream &out, Object *obj) { } // Also add the static properties, which can't be added via getset. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); + for (Property *property : obj->_properties) { const InterrogateElement &ielem = property->_ielement; if (property->_has_this || property->_getter_remaps.empty()) { continue; @@ -3344,9 +3327,7 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker // should even write it. bool has_remaps = false; - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (!is_remap_legal(remap)) { continue; } @@ -3795,18 +3776,12 @@ void InterfaceMakerPythonNative:: write_coerce_constructor(ostream &out, Object *obj, bool is_const) { std::map > map_sets; std::map >::iterator mii; - std::set::iterator sii; int max_required_args = 0; - Functions::iterator fi; - Function::Remaps::const_iterator ri; - // Go through the methods and find appropriate static make() functions. - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (Function *func : obj->_methods) { + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_flags & FunctionRemap::F_coerce_constructor) { nassertd(!remap->_has_this) continue; @@ -3840,10 +3815,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { // Now go through the constructors that are suitable for coercion. This // excludes copy constructors and ones marked "explicit". - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (Function *func : obj->_constructors) { + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_flags & FunctionRemap::F_coerce_constructor) { nassertd(!remap->_has_this) continue; @@ -4869,6 +4842,46 @@ write_function_instance(ostream &out, FunctionRemap *remap, clear_error = true; only_pyobjects = false; + } else if (TypeManager::is_scoped_enum(type)) { + if (args_type == AT_single_arg) { + param_name = "arg"; + } else { + indent(out, indent_level) << "PyObject *" << param_name; + if (default_value != nullptr) { + out << " = nullptr"; + } + out << ";\n"; + format_specifiers += "O"; + parameter_list += ", &" + param_name; + } + + CPPEnumType *enum_type = (CPPEnumType *)TypeManager::unwrap(type); + CPPType *underlying_type = enum_type->get_underlying_type(); + underlying_type = TypeManager::unwrap_const(underlying_type); + + //indent(out, indent_level); + //underlying_type->output_instance(out, param_name + "_val", &parser); + //out << default_expr << ";\n"; + extra_convert << "long " << param_name << "_val"; + + if (default_value != nullptr) { + extra_convert << " = (long)"; + default_value->output(extra_convert, 0, &parser, false); + extra_convert << + ";\nif (" << param_name << " != nullptr) {\n" + " " << param_name << "_val = Dtool_EnumValue_AsLong(" + param_name + ");\n" + "}"; + } else { + extra_convert + << ";\n" + << param_name << "_val = Dtool_EnumValue_AsLong(" + param_name + ");\n"; + } + + pexpr_string = "(" + enum_type->get_local_name(&parser) + ")" + param_name + "_val"; + expected_params += classNameFromCppName(enum_type->get_simple_name(), false); + extra_param_check << " && " << param_name << "_val != -1"; + clear_error = true; + } else if (TypeManager::is_bool(type)) { if (args_type == AT_single_arg) { param_name = "arg"; @@ -5571,7 +5584,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << ", *Dtool_Ptr_" << make_safe_name(class_name) << ");\n"; } else { - extra_convert << boolalpha + extra_convert << std::boolalpha << " = (" << class_name << " *)" << "DTOOL_Call_GetPointerThisClass(" << param_name << ", Dtool_Ptr_" << make_safe_name(class_name) @@ -6268,7 +6281,24 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, CPPType *orig_type = return_type->get_orig_type(); CPPType *type = return_type->get_new_type(); - if (return_type->new_type_is_atomic_string() || + if (TypeManager::is_scoped_enum(type)) { + InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); + TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); + const InterrogateType &itype = idb->get_type(type_index); + string safe_name = make_safe_name(itype.get_scoped_name()); + + indent(out, indent_level) + << "return PyObject_CallFunction((PyObject *)Dtool_Ptr_" << safe_name; + + CPPType *underlying_type = ((CPPEnumType *)itype._cpptype)->get_underlying_type(); + if (TypeManager::is_unsigned_integer(underlying_type)) { + out << ", \"k\", (unsigned long)"; + } else { + out << ", \"l\", (long)"; + } + out << "(" << return_expr << "));\n"; + + } else if (return_type->new_type_is_atomic_string() || TypeManager::is_simple(type) || TypeManager::is_char_pointer(type) || TypeManager::is_wchar_pointer(type) || @@ -6494,11 +6524,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one integral argument. - Function::Remaps::iterator it; - for (it = property->_getter_remaps.begin(); - it != property->_getter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6563,11 +6589,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the setters that take two arguments. - Function::Remaps::iterator it; - for (it = property->_setter_remaps.begin(); - it != property->_setter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_setter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 2 && max_num_args >= 2 && @@ -6665,11 +6687,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one argument. Fish out the ones // already taken by the sequence getter. - Function::Remaps::iterator it; - for (it = property->_getter_remaps.begin(); - it != property->_getter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6798,11 +6816,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one integral argument. - Function::Remaps::iterator it; - for (it = property->_getkey_function->_remaps.begin(); - it != property->_getkey_function->_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getkey_function->_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6959,11 +6973,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the setters that take one argument. - Function::Remaps::iterator it; - for (it = property->_setter_remaps.begin(); - it != property->_setter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_setter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1) { @@ -7294,6 +7304,10 @@ is_cpp_type_legal(CPPType *in_ctype) { // bool answer = false; CPPType *type = TypeManager::resolve_type(in_ctype); + if (TypeManager::is_rvalue_reference(type)) { + return false; + } + type = TypeManager::unwrap(type); if (TypeManager::is_void(type)) { @@ -7352,9 +7366,7 @@ isExportThisRun(Function *func) { return false; } - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end();) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { return isExportThisRun(remap->_cpptype); } @@ -7429,10 +7441,7 @@ has_coerce_constructor(CPPStructType *type) { CPPScope::Functions::iterator fgi; for (fgi = scope->_functions.begin(); fgi != scope->_functions.end(); ++fgi) { CPPFunctionGroup *fgroup = fgi->second; - - CPPFunctionGroup::Instances::iterator ii; - for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { - CPPInstance *inst = (*ii); + for (CPPInstance *inst : fgroup->_instances) { CPPFunctionType *ftype = inst->_type->as_function_type(); if (ftype == nullptr) { continue; @@ -7517,9 +7526,7 @@ is_remap_coercion_possible(FunctionRemap *remap) { */ bool InterfaceMakerPythonNative:: is_function_legal(Function *func) { - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap)) { // printf(" Function Is Marked Legal %s\n",func->_name.c_str()); @@ -7565,13 +7572,7 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { return true; } - CPPStructType::Derivation::const_iterator bi; - for (bi = inclass->_derivation.begin(); - bi != inclass->_derivation.end(); - ++bi) { - - const CPPStructType::Base &base = (*bi); - + for (const CPPStructType::Base &base : inclass->_derivation) { CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != nullptr) { if (DoesInheritFromIsClass(base_type, name)) { @@ -7622,9 +7623,7 @@ has_init_type_function(CPPType *type) { } const CPPFunctionGroup *group = it->second; - CPPFunctionGroup::Instances::const_iterator ii; - for (ii = group->_instances.begin(); ii != group->_instances.end(); ++ii) { - const CPPInstance *cppinst = *ii; + for (const CPPInstance *cppinst : group->_instances) { const CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); if (cppfunc != nullptr && @@ -7873,7 +7872,7 @@ output_quoted(ostream &out, int indent_level, const std::string &str, default: if (!isprint(*si)) { - out << "\\" << oct << setw(3) << setfill('0') << (unsigned int)(*si) + out << "\\" << oct << std::setw(3) << std::setfill('0') << (unsigned int)(*si) << dec; } else { out << *si; diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index 3f11acb855..fa0e35eaea 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -25,6 +25,9 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index 8ee9552250..c0f1be390a 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -23,6 +23,9 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 39b69e2c1d..d11bd22ff6 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -22,6 +22,9 @@ #include "pystub.h" #include +using std::cerr; +using std::string; + CPPParser parser; Filename output_code_filename; diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index f320a66943..f579f1586d 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -50,6 +50,13 @@ #include #include +using std::cerr; +using std::istream; +using std::map; +using std::ostream; +using std::ostringstream; +using std::string; + InterrogateBuilder builder; std::string EXPORT_IMPORT_PREFIX; @@ -1699,7 +1706,7 @@ get_function(CPPInstance *function, string description, ifunction._flags |= flags; // Also, make sure this particular signature is defined. - pair result = + std::pair result = ifunction._instances->insert(InterrogateFunction::Instances::value_type(function_signature, function)); InterrogateFunction::Instances::iterator ii = result.first; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 0fe4534890..5c5cc9d9ab 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -27,6 +27,9 @@ #include +using std::cerr; +using std::string; + Filename output_code_filename; string module_name; string library_name; @@ -149,7 +152,7 @@ static bool print_dependent_types(const string &lib1, const string &lib2) { return false; } -int write_python_table_native(ostream &out) { +int write_python_table_native(std::ostream &out) { out << "\n#include \"dtoolbase.h\"\n" << "#include \"interrogate_request.h\"\n\n" << "#include \"py_panda.h\"\n\n"; @@ -192,7 +195,7 @@ int write_python_table_native(ostream &out) { interrogate_type_has_library_name(basetype)) { string baselib = interrogate_type_library_name(basetype); if (baselib != library_name) { - deps.insert(move(baselib)); + deps.insert(std::move(baselib)); } } } @@ -203,7 +206,7 @@ int write_python_table_native(ostream &out) { interrogate_type_has_library_name(wrapped)) { string wrappedlib = interrogate_type_library_name(wrapped); if (wrappedlib != library_name) { - deps.insert(move(wrappedlib)); + deps.insert(std::move(wrappedlib)); } } } @@ -420,7 +423,7 @@ int write_python_table_native(ostream &out) { return count; } -int write_python_table(ostream &out) { +int write_python_table(std::ostream &out) { out << "\n#include \"dtoolbase.h\"\n" << "#include \"interrogate_request.h\"\n\n" << "#undef _POSIX_C_SOURCE\n" diff --git a/dtool/src/interrogate/parameterRemap.cxx b/dtool/src/interrogate/parameterRemap.cxx index 19c6bb4251..4794c7c16d 100644 --- a/dtool/src/interrogate/parameterRemap.cxx +++ b/dtool/src/interrogate/parameterRemap.cxx @@ -13,6 +13,8 @@ #include "parameterRemap.h" +using std::string; + /** * @@ -26,7 +28,7 @@ ParameterRemap:: * original type to the new type, for passing into the actual C++ function. */ void ParameterRemap:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } @@ -37,7 +39,7 @@ pass_parameter(ostream &out, const string &variable_name) { * return the modified expression. */ string ParameterRemap:: -prepare_return_expr(ostream &, int, const string &expression) { +prepare_return_expr(std::ostream &, int, const string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index d2ea916fff..07dad4694a 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -14,6 +14,8 @@ #include "parameterRemapBasicStringPtrToString.h" #include "interrogate.h" +using std::string; + /** * */ @@ -34,7 +36,7 @@ ParameterRemapBasicStringPtrToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicStringPtrToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "&std::string(" << variable_name << ")"; } @@ -67,7 +69,7 @@ ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicWStringPtrToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "&std::wstring(" << variable_name << ")"; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index 0e5bac31ff..90cd3d7e45 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -14,6 +14,8 @@ #include "parameterRemapBasicStringRefToString.h" #include "interrogate.h" +using std::string; + /** * */ @@ -34,7 +36,7 @@ ParameterRemapBasicStringRefToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicStringRefToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "std::string(" << variable_name << ")"; } @@ -67,7 +69,7 @@ ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicWStringRefToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "std::wstring(" << variable_name << ")"; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index d2ed1f0406..21faabfaac 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -15,6 +15,9 @@ #include "interfaceMaker.h" #include "interrogate.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index 05f0eda533..f5e7c35b39 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -36,7 +36,7 @@ ParameterRemapConcreteToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapConcreteToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? @@ -50,8 +50,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapConcreteToPointer:: -get_return_expr(const string &expression) { +std::string ParameterRemapConcreteToPointer:: +get_return_expr(const std::string &expression) { return "new " + _orig_type->get_local_name(&parser) + "(" + expression + ")"; diff --git a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx index c031350e70..2fb23e90bc 100644 --- a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx +++ b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx @@ -31,7 +31,7 @@ ParameterRemapConstToNonConst(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapConstToNonConst:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << variable_name; } @@ -39,7 +39,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapConstToNonConst:: -get_return_expr(const string &expression) { +std::string ParameterRemapConstToNonConst:: +get_return_expr(const std::string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapEnumToInt.cxx b/dtool/src/interrogate/parameterRemapEnumToInt.cxx index 40283dd364..59fb6019fc 100644 --- a/dtool/src/interrogate/parameterRemapEnumToInt.cxx +++ b/dtool/src/interrogate/parameterRemapEnumToInt.cxx @@ -35,7 +35,7 @@ ParameterRemapEnumToInt(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapEnumToInt:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << "(" << _enum_type->get_local_name(&parser) << ")" << variable_name; } @@ -43,8 +43,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapEnumToInt:: -get_return_expr(const string &expression) { +std::string ParameterRemapEnumToInt:: +get_return_expr(const std::string &expression) { return "(int)(" + expression + ")"; } diff --git a/dtool/src/interrogate/parameterRemapHandleToInt.cxx b/dtool/src/interrogate/parameterRemapHandleToInt.cxx index b22052c7c3..4594ca45c8 100644 --- a/dtool/src/interrogate/parameterRemapHandleToInt.cxx +++ b/dtool/src/interrogate/parameterRemapHandleToInt.cxx @@ -36,7 +36,7 @@ ParameterRemapHandleToInt(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapHandleToInt:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { CPPType *unwrapped = TypeManager::unwrap_const(_orig_type); if (unwrapped->get_local_name(&parser) == "TypeHandle") { @@ -50,7 +50,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapHandleToInt:: -get_return_expr(const string &expression) { +std::string ParameterRemapHandleToInt:: +get_return_expr(const std::string &expression) { return "(" + expression + ").get_index()"; } diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.cxx b/dtool/src/interrogate/parameterRemapPTToPointer.cxx index d4aefb71d2..243b907260 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapPTToPointer.cxx @@ -21,6 +21,8 @@ #include "cppDeclaration.h" #include "pnotify.h" +using std::string; + /** * */ @@ -64,7 +66,7 @@ ParameterRemapPTToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapPTToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx index c4a4e77451..bdb613cef6 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx @@ -35,7 +35,7 @@ ParameterRemapReferenceToConcrete(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapReferenceToConcrete:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << variable_name; } @@ -43,7 +43,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapReferenceToConcrete:: -get_return_expr(const string &expression) { +std::string ParameterRemapReferenceToConcrete:: +get_return_expr(const std::string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index 3199017eea..6c8e8b05a9 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -35,7 +35,7 @@ ParameterRemapReferenceToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapReferenceToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? This is only relevant if @@ -52,7 +52,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapReferenceToPointer:: -get_return_expr(const string &expression) { +std::string ParameterRemapReferenceToPointer:: +get_return_expr(const std::string &expression) { return "&(" + expression + ")"; } diff --git a/dtool/src/interrogate/parameterRemapThis.cxx b/dtool/src/interrogate/parameterRemapThis.cxx index e0ef867931..7fd8be4243 100644 --- a/dtool/src/interrogate/parameterRemapThis.cxx +++ b/dtool/src/interrogate/parameterRemapThis.cxx @@ -39,7 +39,7 @@ ParameterRemapThis(CPPType *type, bool is_const) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapThis:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << "(*" << variable_name << ")"; } @@ -47,8 +47,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapThis:: -get_return_expr(const string &) { +std::string ParameterRemapThis:: +get_return_expr(const std::string &) { return "**invalid**"; } diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index 0a3abe4559..9771a2db1b 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -15,6 +15,8 @@ #include "interrogate.h" #include "typeManager.h" +using std::string; + /** * */ @@ -44,7 +46,7 @@ ParameterRemapToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } @@ -88,7 +90,7 @@ ParameterRemapToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 9eb45fcc5b..aa903407d1 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -25,6 +25,11 @@ #include "pystub.h" #include +using std::cerr; +using std::cin; +using std::cout; +using std::string; + CPPParser parser; void diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index 85161eb69e..ab1fbffce3 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -30,6 +30,8 @@ #include "cppTypedefType.h" #include "pnotify.h" +using std::string; + /** * A horrible hack around a CPPParser bug. We don't trust the CPPType pointer * we were given; instead, we ask CPPParser to parse a new type of the same @@ -122,6 +124,26 @@ is_reference(CPPType *type) { } } +/** + * Returns true if the indicated type is some kind of an rvalue reference. + */ +bool TypeManager:: +is_rvalue_reference(CPPType *type) { + switch (type->get_subtype()) { + case CPPDeclaration::ST_const: + return is_rvalue_reference(type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_reference: + return type->as_reference_type()->_value_category == CPPReferenceType::VC_rvalue; + + case CPPDeclaration::ST_typedef: + return is_rvalue_reference(type->as_typedef_type()->_type); + + default: + return false; + } +} + /** * Returns true if the indicated type is some kind of a reference or const * reference type at all, false otherwise. @@ -308,6 +330,26 @@ is_struct(CPPType *type) { } } +/** + * Returns true if the indicated type is an enum class, const or otherwise. + */ +bool TypeManager:: +is_scoped_enum(CPPType *type) { + switch (type->get_subtype()) { + case CPPDeclaration::ST_enum: + return ((CPPEnumType *)type)->is_scoped(); + + case CPPDeclaration::ST_const: + return is_scoped_enum(type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_typedef: + return is_scoped_enum(type->as_typedef_type()->_type); + + default: + return false; + } +} + /** * Returns true if the indicated type is some kind of enumerated type, const * or otherwise. @@ -2251,7 +2293,7 @@ get_function_signature(CPPInstance *function, CPPFunctionType *ftype = function->_type->as_function_type(); assert(ftype != nullptr); - ostringstream out; + std::ostringstream out; // It's tempting to mark static methods with a different function signature // than non-static, because a static method doesn't have an implicit 'this' diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index d507e947ef..f1aa2908b1 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -44,6 +44,7 @@ public: static bool is_assignable(CPPType *type); static bool is_reference(CPPType *type); + static bool is_rvalue_reference(CPPType *type); static bool is_ref_to_anything(CPPType *type); static bool is_const_ref_to_anything(CPPType *type); static bool is_const_pointer_to_anything(CPPType *type); @@ -52,6 +53,7 @@ public: static bool is_pointer(CPPType *type); static bool is_const(CPPType *type); static bool is_struct(CPPType *type); + static bool is_scoped_enum(CPPType *type); static bool is_enum(CPPType *type); static bool is_const_enum(CPPType *type); static bool is_const_ref_to_enum(CPPType *type); diff --git a/dtool/src/interrogatedb/interrogateComponent.cxx b/dtool/src/interrogatedb/interrogateComponent.cxx index c5a8e15df0..61398f686f 100644 --- a/dtool/src/interrogatedb/interrogateComponent.cxx +++ b/dtool/src/interrogatedb/interrogateComponent.cxx @@ -16,13 +16,13 @@ // This static string is just kept around as a handy bogus return value for // functions that must return a const string reference. -string InterrogateComponent::_empty_string; +std::string InterrogateComponent::_empty_string; /** * Formats the component for output to a data file. */ void InterrogateComponent:: -output(ostream &out) const { +output(std::ostream &out) const { idf_output_string(out, _name); out << _alt_names.size() << " "; @@ -36,14 +36,14 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateComponent:: -input(istream &in) { +input(std::istream &in) { idf_input_string(in, _name); int num_alt_names; in >> num_alt_names; _alt_names.reserve(num_alt_names); for (int i = 0; i < num_alt_names; ++i) { - string alt_name; + std::string alt_name; idf_input_string(in, alt_name); _alt_names.push_back(alt_name); } diff --git a/dtool/src/interrogatedb/interrogateDatabase.cxx b/dtool/src/interrogatedb/interrogateDatabase.cxx index 8781e5c2bd..a8e7b37a6c 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.cxx +++ b/dtool/src/interrogatedb/interrogateDatabase.cxx @@ -16,6 +16,9 @@ #include "indexRemapper.h" #include "interrogate_datafile.h" +using std::map; +using std::string; + InterrogateDatabase *InterrogateDatabase::_global_ptr = nullptr; int InterrogateDatabase::_file_major_version = 0; int InterrogateDatabase::_file_minor_version = 0; @@ -734,7 +737,7 @@ remap_indices(int first_index, IndexRemapper &remap) { * Writes the database to the indicated stream for later reading. */ void InterrogateDatabase:: -write(ostream &out, InterrogateModuleDef *def) const { +write(std::ostream &out, InterrogateModuleDef *def) const { // Write out the file header. out << def->file_identifier << "\n" << _current_major_version << " " << _current_minor_version << "\n"; @@ -793,7 +796,7 @@ write(ostream &out, InterrogateModuleDef *def) const { * Returns true if the file is read successfully, false if there is an error. */ bool InterrogateDatabase:: -read(istream &in, InterrogateModuleDef *def) { +read(std::istream &in, InterrogateModuleDef *def) { InterrogateDatabase temp; if (!temp.read_new(in, def)) { return false; @@ -899,7 +902,7 @@ load_latest() { * already has some data in it. */ bool InterrogateDatabase:: -read_new(istream &in, InterrogateModuleDef *def) { +read_new(std::istream &in, InterrogateModuleDef *def) { // We've already read the header. Read the module definition. idf_input_string(in, def->library_name); idf_input_string(in, def->library_hash_name); diff --git a/dtool/src/interrogatedb/interrogateElement.cxx b/dtool/src/interrogatedb/interrogateElement.cxx index 38c7c8f4ec..4b6b3d948f 100644 --- a/dtool/src/interrogatedb/interrogateElement.cxx +++ b/dtool/src/interrogatedb/interrogateElement.cxx @@ -20,7 +20,7 @@ * Formats the InterrogateElement data for output to a data file. */ void InterrogateElement:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _type << " " @@ -40,7 +40,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateElement:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _type >> _getter >> _setter; if (InterrogateDatabase::get_file_minor_version() >= 1) { diff --git a/dtool/src/interrogatedb/interrogateFunction.cxx b/dtool/src/interrogatedb/interrogateFunction.cxx index a9a60264da..db70cc0b9c 100644 --- a/dtool/src/interrogatedb/interrogateFunction.cxx +++ b/dtool/src/interrogatedb/interrogateFunction.cxx @@ -58,7 +58,7 @@ operator = (const InterrogateFunction ©) { * Formats the InterrogateFunction data for output to a data file. */ void InterrogateFunction:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _class << " "; @@ -73,7 +73,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateFunction:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _class; idf_input_string(in, _scoped_name); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx index 3cb143a2f3..9cad10ef4e 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx @@ -17,6 +17,9 @@ #include +using std::istream; +using std::ostream; + /** * */ diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.cxx b/dtool/src/interrogatedb/interrogateMakeSeq.cxx index 68f3f5999e..d875a91809 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.cxx +++ b/dtool/src/interrogatedb/interrogateMakeSeq.cxx @@ -19,7 +19,7 @@ * Formats the InterrogateMakeSeq data for output to a data file. */ void InterrogateMakeSeq:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _length_getter << " " << _element_getter << " "; @@ -31,7 +31,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateMakeSeq:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _length_getter >> _element_getter; diff --git a/dtool/src/interrogatedb/interrogateManifest.cxx b/dtool/src/interrogatedb/interrogateManifest.cxx index 5257b85aaf..a078e868f4 100644 --- a/dtool/src/interrogatedb/interrogateManifest.cxx +++ b/dtool/src/interrogatedb/interrogateManifest.cxx @@ -19,7 +19,7 @@ * Formats the InterrogateManifest data for output to a data file. */ void InterrogateManifest:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _int_value << " " @@ -32,7 +32,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateManifest:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _int_value >> _type >> _getter; idf_input_string(in, _definition); diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index 41839ffbf7..a9b9404cd4 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -18,6 +18,9 @@ #include +using std::istream; +using std::ostream; + /** * */ diff --git a/dtool/src/interrogatedb/interrogate_datafile.cxx b/dtool/src/interrogatedb/interrogate_datafile.cxx index 65cc3f3fef..a61defb368 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.cxx +++ b/dtool/src/interrogatedb/interrogate_datafile.cxx @@ -13,6 +13,10 @@ #include "interrogate_datafile.h" +using std::istream; +using std::ostream; +using std::string; + /** * Writes the indicated string to the output file. Uses the given whitespace diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 5f72f967e0..2cd08d4adf 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -17,6 +17,8 @@ #include "interrogateFunction.h" #include "config_interrogatedb.h" +using std::string; + // This function adds one more directory to the list of directories search for // interrogate (*.in) files. In the past, this list has been defined the // environment variable ETC_PATH, but now it is passed in by the code diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 8f889768ea..69f8961463 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -31,6 +31,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into) { if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, *target_class); @@ -52,6 +54,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == &target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, target_class); @@ -93,6 +97,20 @@ INLINE PyObject *DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, i Py_RETURN_RICHCOMPARE(cmpval, 0, op); } +/** + * Converts the enum value to a C long. + */ +INLINE long Dtool_EnumValue_AsLong(PyObject *value) { + PyObject *val = PyObject_GetAttrString(value, "value"); + if (val != nullptr) { + long as_long = PyLongOrInt_AS_LONG(val); + Py_DECREF(val); + return as_long; + } else { + return -1; + } +} + /** * These functions wrap a pointer for a class that defines get_type_handle(). */ diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index ee2966789f..e900ab0e7f 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_PYTHON +using std::string; + PyMemberDef standard_type_members[] = { {(char *)"this", (sizeof(void*) == sizeof(int)) ? T_UINT : T_ULONGLONG, offsetof(Dtool_PyInstDef, _ptr_to_object), READONLY, (char *)"C++ 'this' pointer, if any"}, {(char *)"this_ownership", T_BOOL, offsetof(Dtool_PyInstDef, _memory_rules), READONLY, (char *)"C++ 'this' ownership rules"}, @@ -304,11 +306,39 @@ PyObject *_Dtool_Return(PyObject *value) { return value; } +#if PY_VERSION_HEX < 0x03040000 +static PyObject *Dtool_EnumType_Str(PyObject *self) { + PyObject *name = PyObject_GetAttrString(self, "name"); +#if PY_MAJOR_VERSION >= 3 + PyObject *repr = PyUnicode_FromFormat("%s.%s", Py_TYPE(self)->tp_name, PyString_AS_STRING(name)); +#else + PyObject *repr = PyString_FromFormat("%s.%s", Py_TYPE(self)->tp_name, PyString_AS_STRING(name)); +#endif + Py_DECREF(name); + return repr; +} + +static PyObject *Dtool_EnumType_Repr(PyObject *self) { + PyObject *name = PyObject_GetAttrString(self, "name"); + PyObject *value = PyObject_GetAttrString(self, "value"); +#if PY_MAJOR_VERSION >= 3 + PyObject *repr = PyUnicode_FromFormat("<%s.%s: %ld>", Py_TYPE(self)->tp_name, PyString_AS_STRING(name), PyLongOrInt_AS_LONG(value)); +#else + PyObject *repr = PyString_FromFormat("<%s.%s: %ld>", Py_TYPE(self)->tp_name, PyString_AS_STRING(name), PyLongOrInt_AS_LONG(value)); +#endif + Py_DECREF(name); + Py_DECREF(value); + return repr; +} +#endif + /** - * Creates a Python 3.4-style enum type. Steals reference to 'names'. + * Creates a Python 3.4-style enum type. Steals reference to 'names', which + * should be a tuple of (name, value) pairs. */ -PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { +PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { static PyObject *enum_class = nullptr; +#if PY_VERSION_HEX >= 0x03040000 static PyObject *enum_meta = nullptr; static PyObject *enum_create = nullptr; if (enum_meta == nullptr) { @@ -323,12 +353,69 @@ PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *m PyObject *result = PyObject_CallFunction(enum_create, (char *)"OsN", enum_class, name, names); nassertr(result != nullptr, nullptr); +#else + static PyObject *name_str; + static PyObject *name_sunder_str; + static PyObject *value_str; + static PyObject *value_sunder_str; + // Emulate something vaguely like the enum module. + if (enum_class == nullptr) { +#if PY_MAJOR_VERSION >= 3 + name_str = PyUnicode_InternFromString("name"); + value_str = PyUnicode_InternFromString("value"); + name_sunder_str = PyUnicode_InternFromString("_name_"); + value_sunder_str = PyUnicode_InternFromString("_value_"); +#else + name_str = PyString_InternFromString("name"); + value_str = PyString_InternFromString("value"); + name_sunder_str = PyString_InternFromString("_name_"); + value_sunder_str = PyString_InternFromString("_value_"); +#endif + PyObject *name_value_tuple = PyTuple_New(4); + PyTuple_SET_ITEM(name_value_tuple, 0, name_str); + PyTuple_SET_ITEM(name_value_tuple, 1, value_str); + PyTuple_SET_ITEM(name_value_tuple, 2, name_sunder_str); + PyTuple_SET_ITEM(name_value_tuple, 3, value_sunder_str); + Py_INCREF(name_str); + Py_INCREF(value_str); + + PyObject *slots_dict = PyDict_New(); + PyDict_SetItemString(slots_dict, "__slots__", name_value_tuple); + Py_DECREF(name_value_tuple); + + enum_class = PyObject_CallFunction((PyObject *)&PyType_Type, (char *)"s()N", "Enum", slots_dict); + nassertr(enum_class != nullptr, nullptr); + } + PyObject *result = PyObject_CallFunction((PyObject *)&PyType_Type, (char *)"s(O)N", name, enum_class, PyDict_New()); + nassertr(result != nullptr, nullptr); + + ((PyTypeObject *)result)->tp_str = Dtool_EnumType_Str; + ((PyTypeObject *)result)->tp_repr = Dtool_EnumType_Repr; + + // Copy the names as instances of the above to the class dict. + Py_ssize_t size = PyTuple_GET_SIZE(names); + for (Py_ssize_t i = 0; i < size; ++i) { + PyObject *item = PyTuple_GET_ITEM(names, i); + PyObject *name = PyTuple_GET_ITEM(item, 0); + PyObject *value = PyTuple_GET_ITEM(item, 1); + PyObject *member = _PyObject_CallNoArg(result); + PyObject_SetAttr(member, name_str, name); + PyObject_SetAttr(member, name_sunder_str, name); + PyObject_SetAttr(member, value_str, value); + PyObject_SetAttr(member, value_sunder_str, value); + PyObject_SetAttr(result, name, member); + Py_DECREF(member); + } + Py_DECREF(names); +#endif + if (module != nullptr) { PyObject *modstr = PyUnicode_FromString(module); PyObject_SetAttrString(result, "__module__", modstr); Py_DECREF(modstr); } - return result; + nassertr(PyType_Check(result), nullptr); + return (PyTypeObject *)result; } /** @@ -425,7 +512,7 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { // are uniquly defined by an integer. void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype) { - pair result = + std::pair result = named_type_map.insert(NamedTypeMap::value_type(name, &otype)); if (!result.second) { @@ -450,7 +537,7 @@ RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype) { << " has an illegal TypeHandle value; check that init_type() is called.\n"; } else { - pair result = + std::pair result = runtime_type_map.insert(RuntimeTypeMap::value_type(type_index, &otype)); if (!result.second) { // There was already an entry in the dictionary for type_index. @@ -531,7 +618,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { version[2] != '0' + PY_MINOR_VERSION) { // Raise a helpful error message. We can safely do this because the // signature and behavior for PyErr_SetString has remained consistent. - ostringstream errs; + std::ostringstream errs; errs << "this module was compiled for Python " << PY_MAJOR_VERSION << "." << PY_MINOR_VERSION << ", which is " << "incompatible with Python " << version.substr(0, 3); diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 4025b965d5..7916147e4d 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -158,6 +158,16 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ Py_TYPE(self)->tp_free(self);\ } +#define Define_Dtool_FreeInstanceRef_Private(CLASS_NAME,CNAME)\ +static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ + if (DtoolInstance_VOID_PTR(self) != nullptr) {\ + if (((Dtool_PyInstDef *)self)->_memory_rules) {\ + unref_delete((ReferenceCount *)(CNAME *)DtoolInstance_VOID_PTR(self));\ + }\ + }\ + Py_TYPE(self)->tp_free(self);\ +} + #define Define_Dtool_Simple_FreeInstance(CLASS_NAME, CNAME)\ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ ((Dtool_InstDef_##CLASS_NAME *)self)->_value.~##CLASS_NAME();\ @@ -248,8 +258,10 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); /** * Wrapper around Python 3.4's enum library, which does not have a C API. */ -EXPCL_INTERROGATEDB PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, - const char *module = nullptr); +EXPCL_INTERROGATEDB PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, + const char *module = nullptr); +EXPCL_INTERROGATEDB INLINE long Dtool_EnumValue_AsLong(PyObject *value); + /** @@ -292,7 +304,7 @@ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) #define Define_Module_ClassRef_Private(MODULE_NAME,CLASS_NAME,CNAME,PUBLIC_NAME)\ Define_Module_Class_Internal(MODULE_NAME,CLASS_NAME,CNAME)\ Define_Dtool_new(CLASS_NAME,CNAME)\ -Define_Dtool_FreeInstance_Private(CLASS_NAME,CNAME)\ +Define_Dtool_FreeInstanceRef_Private(CLASS_NAME,CNAME)\ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) #define Define_Module_ClassRef(MODULE_NAME,CLASS_NAME,CNAME,PUBLIC_NAME)\ diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index f03d727bd3..71a5a38ffd 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -377,7 +377,7 @@ static PyObject *Dtool_MutableSequenceWrapper_insert(PyObject *self, PyObject *a return PyErr_Format(PyExc_TypeError, "%s.insert() does not support negative indices", wrap->_base._name); } } - return wrap->_insert_func(wrap->_base._self, (ssize_t)max(index, (Py_ssize_t)0), PyTuple_GET_ITEM(args, 1)); + return wrap->_insert_func(wrap->_base._self, (ssize_t)std::max(index, (Py_ssize_t)0), PyTuple_GET_ITEM(args, 1)); } /** @@ -1209,19 +1209,6 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { return result; } -static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_MappingWrapper_Items_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - PyTypeObject Dtool_MappingWrapper_Keys_Type = { PyVarObject_HEAD_INIT(nullptr, 0) "sequence wrapper", diff --git a/dtool/src/parser-inc/time.h b/dtool/src/parser-inc/time.h index 74093ee881..23e49129d2 100644 --- a/dtool/src/parser-inc/time.h +++ b/dtool/src/parser-inc/time.h @@ -1 +1,8 @@ +#pragma once + #include + +struct timespec { + time_t tv_sec; + long tv_nsec; +}; diff --git a/dtool/src/parser-inc/unordered_map b/dtool/src/parser-inc/unordered_map index e3c6220d35..035932bd49 100644 --- a/dtool/src/parser-inc/unordered_map +++ b/dtool/src/parser-inc/unordered_map @@ -24,9 +24,10 @@ #include #include #include +#include namespace std { - + template , diff --git a/dtool/src/parser-inc/unordered_set b/dtool/src/parser-inc/unordered_set index 766161d12b..53b6d794c8 100644 --- a/dtool/src/parser-inc/unordered_set +++ b/dtool/src/parser-inc/unordered_set @@ -24,6 +24,7 @@ #include #include #include +#include namespace std { @@ -46,7 +47,7 @@ namespace std { typedef typename allocator_type::const_reference const_reference; typedef size_t size_type; typedef std::ptrdiff_t difference_type; - + class iterator; class const_iterator; class local_iterator; diff --git a/dtool/src/parser-inc/ws2tcpip.h b/dtool/src/parser-inc/ws2tcpip.h index 49262434c5..002bb035b5 100644 --- a/dtool/src/parser-inc/ws2tcpip.h +++ b/dtool/src/parser-inc/ws2tcpip.h @@ -1 +1 @@ -typedef DWORD socklen_t; +typedef int socklen_t; diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index 2dd32f7c5b..ef05db96ee 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -56,7 +56,7 @@ AndroidLogStream::AndroidLogStreamBuf:: */ int AndroidLogStream::AndroidLogStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); // Write the characters that remain in the buffer. for (char *p = pbase(); p < pptr(); ++p) { @@ -73,7 +73,7 @@ sync() { */ int AndroidLogStream::AndroidLogStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; @@ -107,7 +107,7 @@ write_char(char c) { */ AndroidLogStream:: AndroidLogStream(int priority) : - ostream(new AndroidLogStreamBuf(priority)) { + std::ostream(new AndroidLogStreamBuf(priority)) { } /** @@ -122,7 +122,7 @@ AndroidLogStream:: * Returns an AndroidLogStream suitable for writing log messages with the * indicated severity. */ -ostream &AndroidLogStream:: +std::ostream &AndroidLogStream:: out(NotifySeverity severity) { static AndroidLogStream* streams[NS_fatal + 1] = {nullptr}; diff --git a/dtool/src/prc/configDeclaration.cxx b/dtool/src/prc/configDeclaration.cxx index d692bec013..7cbfa5ba6e 100644 --- a/dtool/src/prc/configDeclaration.cxx +++ b/dtool/src/prc/configDeclaration.cxx @@ -17,6 +17,8 @@ #include "pstrtod.h" #include "string_utils.h" +using std::string; + /** * Use the ConfigPage::make_declaration() interface to create a new * declaration. @@ -133,7 +135,7 @@ set_double_word(size_t n, double value) { * */ void ConfigDeclaration:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); } @@ -141,7 +143,7 @@ output(ostream &out) const { * */ void ConfigDeclaration:: -write(ostream &out) const { +write(std::ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); // if (!get_variable()->is_used()) { out << " (not used)"; } out << "\n"; diff --git a/dtool/src/prc/configFlags.cxx b/dtool/src/prc/configFlags.cxx index 7d9fb90eec..4613dc4615 100644 --- a/dtool/src/prc/configFlags.cxx +++ b/dtool/src/prc/configFlags.cxx @@ -18,8 +18,8 @@ TVOLATILE AtomicAdjust::Integer ConfigFlags::_global_modified; /** * */ -ostream & -operator << (ostream &out, ConfigFlags::ValueType type) { +std::ostream & +operator << (std::ostream &out, ConfigFlags::ValueType type) { switch (type) { case ConfigFlags::VT_undefined: return out << "undefined"; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index ce515529c2..b7f1d06bd9 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -25,6 +25,10 @@ #include "openssl/evp.h" #endif +using std::istream; +using std::ostream; +using std::string; + ConfigPage *ConfigPage::_default_page = nullptr; ConfigPage *ConfigPage::_local_page = nullptr; @@ -340,7 +344,7 @@ output(ostream &out) const { */ void ConfigPage:: output_brief_signature(ostream &out) const { - size_t num_bytes = min(_signature.size(), (size_t)8); + size_t num_bytes = std::min(_signature.size(), (size_t)8); for (size_t p = 0; p < num_bytes; ++p) { unsigned int byte = _signature[p]; diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index fafaa6fa07..18f8b12784 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -38,6 +38,8 @@ #include #include +using std::string; + ConfigPageManager *ConfigPageManager::_global_ptr = nullptr; /** @@ -241,7 +243,7 @@ reload_implicit_pages() { // Use a set to ensure that we only visit each directory once, even if it // appears multiple times (under different aliases!) in the path. - set unique_dirnames; + std::set unique_dirnames; // We walk through the list of directories in forward order, so that the // most important directories are visited first. @@ -447,7 +449,7 @@ delete_explicit_page(ConfigPage *page) { * */ void ConfigPageManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConfigPageManager, " << _explicit_pages.size() + _implicit_pages.size() << " pages."; @@ -457,7 +459,7 @@ output(ostream &out) const { * */ void ConfigPageManager:: -write(ostream &out) const { +write(std::ostream &out) const { check_sort_pages(); out << _explicit_pages.size() << " explicit pages:\n"; @@ -558,7 +560,7 @@ scan_auto_prc_dir(Filename &prc_dir) const { } // Didn't find it; too bad. - cerr << "Warning: unable to auto-locate config files in directory named by \"" + std::cerr << "Warning: unable to auto-locate config files in directory named by \"" << prc_dir << "\".\n"; return false; } diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 55643704b7..0b4e728b94 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -21,9 +21,9 @@ ConfigVariableBase::Unconstructed *ConfigVariableBase::_unconstructed; * ConfigVariableFoo derived class. */ ConfigVariableBase:: -ConfigVariableBase(const string &name, +ConfigVariableBase(const std::string &name, ConfigVariableBase::ValueType value_type, - const string &description, int flags) : + const std::string &description, int flags) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { #ifndef NDEBUG diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index b2ab7d277a..8ae104efd8 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -23,6 +23,8 @@ #include +using std::string; + /** * Use the ConfigVariableManager::make_variable() interface to create a new @@ -126,9 +128,9 @@ set_flags(int flags) { if ((bits_changed & ~(F_trust_level_mask | F_dconfig)) != 0) { prc_cat->warning() << "changing flags for ConfigVariable " - << get_name() << " from " << hex + << get_name() << " from " << std::hex << (_flags & ~F_trust_level_mask) << " to " - << (flags & ~F_trust_level_mask) << dec << ".\n"; + << (flags & ~F_trust_level_mask) << std::dec << ".\n"; } } @@ -325,7 +327,7 @@ get_declaration(size_t n) const { * */ void ConfigVariableCore:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_declaration(0)->get_string_value(); } @@ -333,7 +335,7 @@ output(ostream &out) const { * */ void ConfigVariableCore:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ConfigVariable " << get_name() << ":\n"; check_sort_declarations(); diff --git a/dtool/src/prc/configVariableList.cxx b/dtool/src/prc/configVariableList.cxx index 7ecd861837..f663ac5adc 100644 --- a/dtool/src/prc/configVariableList.cxx +++ b/dtool/src/prc/configVariableList.cxx @@ -17,7 +17,7 @@ * */ void ConfigVariableList:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_num_values() << " values."; } @@ -25,7 +25,7 @@ output(ostream &out) const { * */ void ConfigVariableList:: -write(ostream &out) const { +write(std::ostream &out) const { size_t num_values = get_num_values(); for (size_t i = 0; i < num_values; ++i) { out << get_string_value(i) << "\n"; diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index 52f7269f6b..774dc19f6b 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -17,6 +17,8 @@ #include "configPage.h" #include "config_prc.h" +using std::string; + ConfigVariableManager *ConfigVariableManager::_global_ptr = nullptr; /** @@ -180,7 +182,7 @@ is_variable_used(size_t n) const { * */ void ConfigVariableManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConfigVariableManager, " << _variables.size() << " variables."; } @@ -188,7 +190,7 @@ output(ostream &out) const { * */ void ConfigVariableManager:: -write(ostream &out) const { +write(std::ostream &out) const { VariablesByName::const_iterator ni; for (ni = _variables_by_name.begin(); ni != _variables_by_name.end(); @@ -211,7 +213,7 @@ write(ostream &out) const { * state. */ void ConfigVariableManager:: -write_prc_variables(ostream &out) const { +write_prc_variables(std::ostream &out) const { VariablesByName::const_iterator ni; for (ni = _variables_by_name.begin(); ni != _variables_by_name.end(); diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 984ba435c7..2231626a7a 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -32,7 +32,7 @@ reload_search_path() { Filename page_filename(page->get_name()); Filename page_dirname = page_filename.get_dirname(); ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); - string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); + std::string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); if (!expanded.empty()) { Filename dir = Filename::from_os_specific(expanded); diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index 1fd5cc72b5..192c1181c6 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -101,7 +101,7 @@ EncryptStreamBuf:: * */ void EncryptStreamBuf:: -open_read(istream *source, bool owns_source, const string &password) { +open_read(std::istream *source, bool owns_source, const std::string &password) { OpenSSL_add_all_algorithms(); _source = source; @@ -208,7 +208,7 @@ close_read() { * */ void EncryptStreamBuf:: -open_write(ostream *dest, bool owns_dest, const string &password) { +open_write(std::ostream *dest, bool owns_dest, const std::string &password) { OpenSSL_add_all_algorithms(); close_write(); @@ -408,7 +408,7 @@ read_chars(char *start, size_t length) { if (_in_read_overflow_buffer != 0) { // Take from the overflow buffer. - length = min(length, _in_read_overflow_buffer); + length = std::min(length, _in_read_overflow_buffer); memcpy(start, _read_overflow_buffer, length); _in_read_overflow_buffer -= length; memcpy(_read_overflow_buffer + length, _read_overflow_buffer, _in_read_overflow_buffer); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index 0d91f5b444..f9c39135e8 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -29,6 +29,12 @@ #include #endif +using std::cerr; +using std::cout; +using std::ostream; +using std::ostringstream; +using std::string; + Notify *Notify::_global_ptr = nullptr; /** @@ -101,7 +107,7 @@ get_literal_flag() { if (!got_flag) { #ifndef PHAVE_IOSTREAM - flag = ios::bitalloc(); + flag = std::ios::bitalloc(); #else // We lost bitalloc in the new iostream? Ok, this feature will just be // disabled for now. No big deal. @@ -187,7 +193,7 @@ get_category(const string &basename, NotifyCategory *parent_category) { } } - pair result = + std::pair result = _categories.insert(Categories::value_type(fullname, nullptr)); bool inserted = result.second; @@ -430,7 +436,7 @@ config_initialized() { if (!notify_output.empty()) { if (notify_output == "stdout") { - cout.setf(ios::unitbuf); + cout.setf(std::ios::unitbuf); set_ostream_ptr(&cout, false); } else if (notify_output == "stderr") { @@ -459,7 +465,7 @@ config_initialized() { nout << "Unable to open file " << filename << " for output.\n"; delete out; } else { - out->setf(ios::unitbuf); + out->setf(std::ios::unitbuf); set_ostream_ptr(out, true); } #endif // BUILD_IPHONE diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 8faa89bdd0..11a3c52587 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -31,7 +31,7 @@ long NotifyCategory::_server_delta = 0; * */ NotifyCategory:: -NotifyCategory(const string &fullname, const string &basename, +NotifyCategory(const std::string &fullname, const std::string &basename, NotifyCategory *parent) : _fullname(fullname), _basename(basename), @@ -55,7 +55,7 @@ NotifyCategory(const string &fullname, const string &basename, * the Notify::out() stream and returns that. If the severity level is * disabled, this returns Notify::null(). */ -ostream &NotifyCategory:: +std::ostream &NotifyCategory:: out(NotifySeverity severity, bool prefix) const { if (is_on(severity)) { @@ -151,9 +151,9 @@ set_server_delta(long delta) { * Returns the name of the config variable that controls this category. This * is called at construction time. */ -string NotifyCategory:: +std::string NotifyCategory:: get_config_name() const { - string config_name; + std::string config_name; if (_fullname.empty()) { config_name = "notify-level"; diff --git a/dtool/src/prc/notifySeverity.cxx b/dtool/src/prc/notifySeverity.cxx index 0ee750e879..d6547e8de1 100644 --- a/dtool/src/prc/notifySeverity.cxx +++ b/dtool/src/prc/notifySeverity.cxx @@ -14,6 +14,10 @@ #include "notifySeverity.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, NotifySeverity severity) { switch (severity) { diff --git a/dtool/src/prc/streamReader.cxx b/dtool/src/prc/streamReader.cxx index e9fa173ad1..74f278e220 100644 --- a/dtool/src/prc/streamReader.cxx +++ b/dtool/src/prc/streamReader.cxx @@ -14,6 +14,8 @@ #include "streamReader.h" #include "memoryHook.h" +using std::string; + /** * Extracts a variable-length string. diff --git a/dtool/src/prc/streamReader_ext.cxx b/dtool/src/prc/streamReader_ext.cxx index 53a4570872..94c346e370 100644 --- a/dtool/src/prc/streamReader_ext.cxx +++ b/dtool/src/prc/streamReader_ext.cxx @@ -41,9 +41,9 @@ extract_bytes(size_t size) { */ PyObject *Extension:: readline() { - istream *in = _this->get_istream(); + std::istream *in = _this->get_istream(); - string line; + std::string line; int ch = in->get(); while (!in->eof() && !in->fail()) { line += ch; diff --git a/dtool/src/prc/streamWrapper.cxx b/dtool/src/prc/streamWrapper.cxx index 68f8e47abb..3c59fb3a90 100644 --- a/dtool/src/prc/streamWrapper.cxx +++ b/dtool/src/prc/streamWrapper.cxx @@ -13,6 +13,8 @@ #include "streamWrapper.h" +using std::streamsize; + /** * */ @@ -121,7 +123,7 @@ streamsize IStreamWrapper:: seek_gpos_eof() { streamsize pos; acquire(); - _istream->seekg(0, ios::end); + _istream->seekg(0, std::ios::end); pos = _istream->tellg(); release(); @@ -204,7 +206,7 @@ void OStreamWrapper:: seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail) { acquire(); _ostream->clear(); - _ostream->seekp(0, ios::end); + _ostream->seekp(0, std::ios::end); #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { @@ -228,7 +230,7 @@ streamsize OStreamWrapper:: seek_ppos_eof() { streamsize pos; acquire(); - _ostream->seekp(0, ios::end); + _ostream->seekp(0, std::ios::end); #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index 48b8f62d9c..a6ee834b04 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -30,6 +30,9 @@ #include "openssl/rand.h" #include "openssl/bio.h" +using std::cerr; +using std::string; + class KeyNumber { public: int _number; @@ -69,7 +72,7 @@ output_ssl_errors() { * string. */ void -output_c_string(ostream &out, const string &string_name, +output_c_string(std::ostream &out, const string &string_name, size_t index, BIO *mbio) { char *data_ptr; size_t data_size = BIO_get_mem_data(mbio, &data_ptr); @@ -94,8 +97,8 @@ output_c_string(ostream &out, const string &string_name, out << data_ptr[i]; } else { - out << "\\x" << hex << setw(2) << setfill('0') - << (unsigned int)(unsigned char)data_ptr[i] << dec; + out << "\\x" << std::hex << std::setw(2) << std::setfill('0') + << (unsigned int)(unsigned char)data_ptr[i] << std::dec; } } } @@ -456,7 +459,7 @@ main(int argc, char **argv) { EVP_PKEY *pkey = generate_key(); PrcKeyRegistry::get_global_ptr()->set_key(n, pkey, now); - ostringstream strm; + std::ostringstream strm; if (got_hash || n != 1) { // If we got an explicit hash mark, we always output the number. If we // did not get an explicit hash mark, we output the number only if it is diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index f122283c55..5e9d04a1b4 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -30,6 +30,9 @@ #include "openssl/bio.h" #include "openssl/evp.h" +using std::cerr; +using std::string; + string progname = PROGNAME; /** @@ -77,7 +80,7 @@ read_prc_line(const string &line, string &data) { * indicated string. */ void -read_file(istream &in, string &data) { +read_file(std::istream &in, string &data) { // We avoid getline() here because of its notorious problem with last lines // that lack a trailing newline character. static const size_t buffer_size = 1024; @@ -129,7 +132,7 @@ read_file(istream &in, string &data) { * Outputs the indicated data stream as a series of hex digits. */ void -output_hex(ostream &out, const unsigned char *data, size_t size) { +output_hex(std::ostream &out, const unsigned char *data, size_t size) { } /** @@ -155,7 +158,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { } // Append the comments before the signature (these get signed too). - ostringstream strm; + std::ostringstream strm; strm << "##!\n"; if (!no_comments) { time_t now = time(nullptr); @@ -203,7 +206,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { } cerr << "Rewriting " << filename << "\n"; - out << data << hex << setfill('0'); + out << data << std::hex << std::setfill('0'); static const size_t row_width = 32; for (size_t p = 0; p < sig_size; p += row_width) { out << "##!sig "; @@ -214,11 +217,11 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { end = p+row_width; for (size_t q = p; q < end; q++) { - out << setw(2) << (unsigned int)sig_data[q]; + out << std::setw(2) << (unsigned int)sig_data[q]; } out << "\n"; } - out << dec; + out << std::dec; delete[] sig_data; } diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index cf617cd6f7..b2e9d4d62f 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -36,7 +36,6 @@ extern "C" { EXPCL_PYSTUB int PyDict_SetItem(...); EXPCL_PYSTUB int PyDict_SetItemString(...); EXPCL_PYSTUB int PyDict_Size(...); - EXPCL_PYSTUB int PyDict_Type(...); EXPCL_PYSTUB int PyErr_Clear(...); EXPCL_PYSTUB int PyErr_ExceptionMatches(...); EXPCL_PYSTUB int PyErr_Fetch(...); @@ -54,9 +53,7 @@ extern "C" { EXPCL_PYSTUB int PyEval_SaveThread(...); EXPCL_PYSTUB int PyFloat_AsDouble(...); EXPCL_PYSTUB int PyFloat_FromDouble(...); - EXPCL_PYSTUB int PyFloat_Type(...); EXPCL_PYSTUB int PyGen_Check(...); - EXPCL_PYSTUB int PyGen_Type(...); EXPCL_PYSTUB int PyGILState_Ensure(...); EXPCL_PYSTUB int PyGILState_Release(...); EXPCL_PYSTUB int PyImport_GetModuleDict(...); @@ -65,14 +62,12 @@ extern "C" { EXPCL_PYSTUB int PyInt_AsSsize_t(...); EXPCL_PYSTUB int PyInt_FromLong(...); EXPCL_PYSTUB int PyInt_FromSize_t(...); - EXPCL_PYSTUB int PyInt_Type(...); EXPCL_PYSTUB int PyIter_Next(...); EXPCL_PYSTUB int PyList_Append(...); EXPCL_PYSTUB int PyList_AsTuple(...); EXPCL_PYSTUB int PyList_GetItem(...); EXPCL_PYSTUB int PyList_New(...); EXPCL_PYSTUB int PyList_SetItem(...); - EXPCL_PYSTUB int PyList_Type(...); EXPCL_PYSTUB int PyLong_AsLong(...); EXPCL_PYSTUB int PyLong_AsLongLong(...); EXPCL_PYSTUB int PyLong_AsSsize_t(...); @@ -83,7 +78,6 @@ extern "C" { EXPCL_PYSTUB int PyLong_FromSize_t(...); EXPCL_PYSTUB int PyLong_FromUnsignedLong(...); EXPCL_PYSTUB int PyLong_FromUnsignedLongLong(...); - EXPCL_PYSTUB int PyLong_Type(...); EXPCL_PYSTUB int PyMapping_GetItemString(...); EXPCL_PYSTUB int PyMem_Free(...); EXPCL_PYSTUB int PyMemoryView_FromObject(...); @@ -121,9 +115,9 @@ extern "C" { EXPCL_PYSTUB int PyObject_Repr(...); EXPCL_PYSTUB int PyObject_RichCompareBool(...); EXPCL_PYSTUB int PyObject_SelfIter(...); + EXPCL_PYSTUB int PyObject_SetAttr(...); EXPCL_PYSTUB int PyObject_SetAttrString(...); EXPCL_PYSTUB int PyObject_Str(...); - EXPCL_PYSTUB int PyObject_Type(...); EXPCL_PYSTUB int PySeqIter_New(...); EXPCL_PYSTUB int PySequence_Check(...); EXPCL_PYSTUB int PySequence_Fast(...); @@ -138,7 +132,6 @@ extern "C" { EXPCL_PYSTUB int PyString_InternFromString(...); EXPCL_PYSTUB int PyString_InternInPlace(...); EXPCL_PYSTUB int PyString_Size(...); - EXPCL_PYSTUB int PyString_Type(...); EXPCL_PYSTUB int PySys_GetObject(...); EXPCL_PYSTUB int PyThreadState_Clear(...); EXPCL_PYSTUB int PyThreadState_Delete(...); @@ -180,7 +173,6 @@ extern "C" { EXPCL_PYSTUB int PyUnicode_GetSize(...); EXPCL_PYSTUB int PyUnicode_InternFromString(...); EXPCL_PYSTUB int PyUnicode_InternInPlace(...); - EXPCL_PYSTUB int PyUnicode_Type(...); EXPCL_PYSTUB int Py_BuildValue(...); EXPCL_PYSTUB int Py_GetVersion(...); EXPCL_PYSTUB int Py_InitModule4(...); @@ -232,8 +224,17 @@ extern "C" { EXPCL_PYSTUB extern void *PyExc_SystemExit; EXPCL_PYSTUB extern void *PyExc_TypeError; EXPCL_PYSTUB extern void *PyExc_ValueError; + EXPCL_PYSTUB extern void *PyDict_Type; + EXPCL_PYSTUB extern void *PyFloat_Type; + EXPCL_PYSTUB extern void *PyGen_Type; + EXPCL_PYSTUB extern void *PyInt_Type; + EXPCL_PYSTUB extern void *PyList_Type; + EXPCL_PYSTUB extern void *PyLong_Type; + EXPCL_PYSTUB extern void *PyObject_Type; + EXPCL_PYSTUB extern void *PyString_Type; EXPCL_PYSTUB extern void *PyTuple_Type; EXPCL_PYSTUB extern void *PyType_Type; + EXPCL_PYSTUB extern void *PyUnicode_Type; EXPCL_PYSTUB extern void *_PyThreadState_Current; EXPCL_PYSTUB extern void *_Py_FalseStruct; EXPCL_PYSTUB extern void *_Py_NoneStruct; @@ -265,7 +266,6 @@ int PyDict_Next(...) { return 0; }; int PyDict_SetItem(...) { return 0; }; int PyDict_SetItemString(...) { return 0; }; int PyDict_Size(...){ return 0; } -int PyDict_Type(...) { return 0; }; int PyErr_Clear(...) { return 0; }; int PyErr_ExceptionMatches(...) { return 0; }; int PyErr_Fetch(...) { return 0; } @@ -284,9 +284,7 @@ int PyEval_RestoreThread(...) { return 0; } int PyEval_SaveThread(...) { return 0; } int PyFloat_AsDouble(...) { return 0; } int PyFloat_FromDouble(...) { return 0; } -int PyFloat_Type(...) { return 0; } int PyGen_Check(...) { return 0; } -int PyGen_Type(...) { return 0; } int PyGILState_Ensure(...) { return 0; } int PyGILState_Release(...) { return 0; } int PyImport_GetModuleDict(...) { return 0; } @@ -295,14 +293,12 @@ int PyInt_AsLong(...) { return 0; } int PyInt_AsSsize_t(...) { return 0; } int PyInt_FromLong(...) { return 0; } int PyInt_FromSize_t(...) { return 0; } -int PyInt_Type(...) { return 0; } int PyIter_Next(...) { return 0; } int PyList_Append(...) { return 0; } int PyList_AsTuple(...) { return 0; } int PyList_GetItem(...) { return 0; } int PyList_New(...) { return 0; } int PyList_SetItem(...) { return 0; } -int PyList_Type(...) { return 0; } int PyLong_AsLong(...) { return 0; } int PyLong_AsLongLong(...) { return 0; } int PyLong_AsSsize_t(...) { return 0; } @@ -313,7 +309,6 @@ int PyLong_FromLongLong(...) { return 0; } int PyLong_FromSize_t(...) { return 0; } int PyLong_FromUnsignedLong(...) { return 0; } int PyLong_FromUnsignedLongLong(...) { return 0; } -int PyLong_Type(...) { return 0; } int PyMapping_GetItemString(...) { return 0; } int PyMem_Free(...) { return 0; } int PyMemoryView_FromObject(...) { return 0; } @@ -351,9 +346,9 @@ int PyObject_Malloc(...) { return 0; } int PyObject_Repr(...) { return 0; } int PyObject_RichCompareBool(...) { return 0; } int PyObject_SelfIter(...) { return 0; } +int PyObject_SetAttr(...) { return 0; } int PyObject_SetAttrString(...) { return 0; } int PyObject_Str(...) { return 0; } -int PyObject_Type(...) { return 0; } int PySeqIter_New(...) { return 0; } int PySequence_Check(...) { return 0; } int PySequence_Fast(...) { return 0; } @@ -367,8 +362,6 @@ int PyString_FromString(...) { return 0; } int PyString_FromStringAndSize(...) { return 0; } int PyString_InternFromString(...) { return 0; } int PyString_InternInPlace(...) { return 0; } -int PyString_Size(...) { return 0; } -int PyString_Type(...) { return 0; } int PySys_GetObject(...) { return 0; } int PyThreadState_Clear(...) { return 0; } int PyThreadState_Delete(...) { return 0; } @@ -410,7 +403,6 @@ int PyUnicode_FromWideChar(...) { return 0; } int PyUnicode_GetSize(...) { return 0; } int PyUnicode_InternFromString(...) { return 0; } int PyUnicode_InternInPlace(...) { return 0; } -int PyUnicode_Type(...) { return 0; } int Py_GetVersion(...) { return 0; } int Py_BuildValue(...) { return 0; } int Py_InitModule4(...) { return 0; } @@ -468,8 +460,17 @@ void *PyExc_StopIteration = nullptr; void *PyExc_SystemExit = nullptr; void *PyExc_TypeError = nullptr; void *PyExc_ValueError = nullptr; +void *PyDict_Type = nullptr; +void *PyFloat_Type = nullptr; +void *PyGen_Type = nullptr; +void *PyInt_Type = nullptr; +void *PyList_Type = nullptr; +void *PyLong_Type = nullptr; +void *PyObject_Type = nullptr; +void *PyString_Type = nullptr; void *PyTuple_Type = nullptr; void *PyType_Type = nullptr; +void *PyUnicode_Type = nullptr; void *_PyThreadState_Current = nullptr; void *_Py_FalseStruct = nullptr; void *_Py_NoneStruct = nullptr; diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index 9a5c6dfc16..590b8ac873 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -23,6 +23,11 @@ #include +using std::cerr; +using std::cout; +using std::ostream; +using std::string; + static ostream & indent(ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { diff --git a/dtool/src/test_interrogate/test_lib.cxx b/dtool/src/test_interrogate/test_lib.cxx index cab224118c..89ccafccfc 100644 --- a/dtool/src/test_interrogate/test_lib.cxx +++ b/dtool/src/test_interrogate/test_lib.cxx @@ -34,7 +34,7 @@ int stupid_global; Configure(test_lib); ConfigureFn(test_lib) { - cerr << "In test_lib configure function!" << endl; + std::cerr << "In test_lib configure function!" << std::endl; } ConfigureLibSym; diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 39b7dd3518..976bfd84f5 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -1239,8 +1239,13 @@ done: FunctionEnd +!ifndef LVM_GETITEMCOUNT !define LVM_GETITEMCOUNT 0x1004 +!endif + +!ifndef LVM_GETITEMTEXT !define LVM_GETITEMTEXT 0x102D +!endif Function DumpLog Exch $5 diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index df25c49f39..6181ccf87e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1351,6 +1351,9 @@ def CompileCxx(obj,src,opts): # Fast math is nice, but we'd like to see NaN in dev builds. cmd += " -fno-finite-math-only" + # Make sure this is off to avoid GCC/Eigen bug (see GitHub #228) + cmd += " -fno-unsafe-math-optimizations" + if (optlevel==1): cmd += " -ggdb -D_DEBUG" if (optlevel==2): cmd += " -O1 -D_DEBUG" if (optlevel==3): cmd += " -O2" diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index b8bdcbf07b..6be22d7d1a 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -760,7 +760,6 @@ - @@ -1114,7 +1113,6 @@ - @@ -1379,7 +1377,6 @@ - @@ -3706,7 +3703,6 @@ - diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 81163c8179..76dec39406 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -102,7 +102,8 @@ MAYAVERSIONINFO = [("MAYA6", "6.0"), ("MAYA2015","2015"), ("MAYA2016","2016"), ("MAYA20165","2016.5"), - ("MAYA2017","2017") + ("MAYA2017","2017"), + ("MAYA2018","2018"), ] MAXVERSIONINFO = [("MAX6", "SOFTWARE\\Autodesk\\3DSMAX\\6.0", "installdir", "maxsdk\\cssdk\\include"), @@ -321,8 +322,12 @@ def GetHostArch(): target = GetTarget() if target == 'windows': return 'x64' if host_64 else 'x86' - else: #TODO - return platform.machine() + + machine = platform.machine() + if machine.startswith('armv7'): + return 'armv7a' + else: + return machine def SetTarget(target, arch=None): """Sets the target platform; the one we're compiling for. Also diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index f727f10e73..e490f1c05e 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -488,7 +488,10 @@ def makewheel(version, output_dir, platform=default_platform): # Write the panda3d tree. We use a custom empty __init__ since the # default one adds the bin directory to the PATH, which we don't have. - whl.write_file_data('panda3d/__init__.py', '') + whl.write_file_data('panda3d/__init__.py', """"Python bindings for the Panda3D libraries" + +__version__ = '{0}' +""".format(version)) ext_suffix = GetExtensionSuffix() diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 865936e2ed..626111ed83 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -26,6 +26,8 @@ #include #include +using std::string; + // struct android_app* panda_android_app = NULL; extern int main(int argc, const char **argv); @@ -197,7 +199,7 @@ void android_main(struct android_app* app) { get_model_path().append_directory(asset_dir); // Now load the configuration files. - vector pages; + std::vector pages; ConfigPageManager *cp_mgr; AAssetDir *etc = AAssetManager_openDir(app->activity->assetManager, "etc"); if (etc != nullptr) { @@ -209,7 +211,7 @@ void android_main(struct android_app* app) { GlobPattern pattern = cp_mgr->get_prc_pattern(i); if (pattern.matches(filename)) { Filename prc_fn("etc", filename); - istream *in = asset_mount->open_read_file(prc_fn); + std::istream *in = asset_mount->open_read_file(prc_fn); if (in != nullptr) { ConfigPage *page = cp_mgr->make_explicit_page(Filename("/android_asset", prc_fn)); page->read_prc(*in); diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index aa527cefc3..083cd7c192 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -139,7 +139,7 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) { * Shows a toast notification at the bottom of the activity. The duration * should be 0 for short and 1 for long. */ -void android_show_toast(ANativeActivity *activity, const string &message, int duration) { +void android_show_toast(ANativeActivity *activity, const std::string &message, int duration) { Thread *thread = Thread::get_current_thread(); JNIEnv *env = thread->get_jni_env(); nassertv(env != nullptr); diff --git a/panda/src/android/pnmFileTypeAndroid.cxx b/panda/src/android/pnmFileTypeAndroid.cxx index aa25b2c777..535cc30563 100644 --- a/panda/src/android/pnmFileTypeAndroid.cxx +++ b/panda/src/android/pnmFileTypeAndroid.cxx @@ -27,7 +27,7 @@ PNMFileTypeAndroid(CompressFormat format) : _format(format) { /** * Returns a few words describing the file type. */ -string PNMFileTypeAndroid:: +std::string PNMFileTypeAndroid:: get_name() const { return "Android Bitmap"; } @@ -54,7 +54,7 @@ get_num_extensions() const { * Returns the nth possible filename extension associated with this particular * file type, without a leading dot. */ -string PNMFileTypeAndroid:: +std::string PNMFileTypeAndroid:: get_extension(int n) const { static const char *const jpeg_extensions[] = {"jpg", "jpeg", "jpe"}; switch (_format) { @@ -84,7 +84,7 @@ has_magic_number() const { * returns NULL. */ PNMReader *PNMFileTypeAndroid:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const std::string &magic_number) { return new Reader(this, file, owns_file, magic_number); } @@ -94,7 +94,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeAndroid:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { return new Writer(this, file, owns_file, _format); } diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index 797571a311..7feceffa1c 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -60,11 +60,11 @@ static void conv_rgba4444(uint16_t in, xel &rgb, xelval &alpha) { * */ PNMFileTypeAndroid::Reader:: -Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : +Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number) : PNMReader(type, file, owns_file), _bitmap(nullptr) { // Hope we can putback() more than one character. - for (string::reverse_iterator mi = magic_number.rbegin(); + for (std::string::reverse_iterator mi = magic_number.rbegin(); mi != magic_number.rend(); ++mi) { _file->putback(*mi); }; @@ -75,7 +75,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : return; } - streampos pos = _file->tellg(); + std::streampos pos = _file->tellg(); Thread *current_thread = Thread::get_current_thread(); _env = current_thread->get_jni_env(); @@ -143,7 +143,7 @@ prepare_read() { int x_reduction = _orig_x_size / _read_x_size; int y_reduction = _orig_y_size / _read_y_size; - _sample_size = max(min(x_reduction, y_reduction), 1); + _sample_size = std::max(std::min(x_reduction, y_reduction), 1); } _bitmap = _env->CallStaticObjectMethod(jni_PandaActivity, diff --git a/panda/src/android/pnmFileTypeAndroidWriter.cxx b/panda/src/android/pnmFileTypeAndroidWriter.cxx index 4677a25cbd..3157733115 100644 --- a/panda/src/android/pnmFileTypeAndroidWriter.cxx +++ b/panda/src/android/pnmFileTypeAndroidWriter.cxx @@ -34,7 +34,7 @@ enum class BitmapConfig : jint { * */ PNMFileTypeAndroid::Writer:: -Writer(PNMFileType *type, ostream *file, bool owns_file, +Writer(PNMFileType *type, std::ostream *file, bool owns_file, CompressFormat format) : PNMWriter(type, file, owns_file), _format(format) diff --git a/panda/src/android/python_main.cxx b/panda/src/android/python_main.cxx index c1fc0a39fe..0e4059c61c 100644 --- a/panda/src/android/python_main.cxx +++ b/panda/src/android/python_main.cxx @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { Py_SetProgramName(Py_DecodeLocale("ppython", nullptr)); // Set PYTHONHOME to the location of the .apk file. - string apk_path = ExecutionEnvironment::get_binary_name(); + std::string apk_path = ExecutionEnvironment::get_binary_name(); Py_SetPythonHome(Py_DecodeLocale(apk_path.c_str(), nullptr)); // We need to make zlib available to zipimport, but I don't know how @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { // This is used by the import hook to locate the module libraries. Filename dtool_name = ExecutionEnvironment::get_dtool_name(); - string native_dir = dtool_name.get_dirname(); + std::string native_dir = dtool_name.get_dirname(); PyObject *py_native_dir = PyUnicode_FromStringAndSize(native_dir.c_str(), native_dir.size()); PySys_SetObject("_native_library_dir", py_native_dir); Py_DECREF(py_native_dir); diff --git a/panda/src/androiddisplay/androidGraphicsPipe.cxx b/panda/src/androiddisplay/androidGraphicsPipe.cxx index 673a03e5a2..53f0f72310 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.cxx +++ b/panda/src/androiddisplay/androidGraphicsPipe.cxx @@ -68,7 +68,7 @@ AndroidGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string AndroidGraphicsPipe:: +std::string AndroidGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } @@ -99,7 +99,7 @@ AndroidGraphicsPipe::get_preferred_window_thread() const { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) AndroidGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index 3d5b949633..e5c8177d9e 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -275,7 +275,7 @@ reset() { #endif // If "PixelFlinger" is present, assume software. - if (_gl_renderer.find("PixelFlinger") != string::npos) { + if (_gl_renderer.find("PixelFlinger") != std::string::npos) { _fbprops.set_force_software(1); _fbprops.set_force_hardware(0); } else { diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 62755cdd2c..431f9419b7 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -38,7 +38,7 @@ TypeHandle AndroidGraphicsWindow::_type_handle; */ AndroidGraphicsWindow:: AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/config_androiddisplay.cxx b/panda/src/androiddisplay/config_androiddisplay.cxx index 6b344b6c9d..42b0fb8120 100644 --- a/panda/src/androiddisplay/config_androiddisplay.cxx +++ b/panda/src/androiddisplay/config_androiddisplay.cxx @@ -64,7 +64,7 @@ init_libandroiddisplay() { /** * Returns the given EGL error as string. */ -const string get_egl_error_string(int error) { +const std::string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; case 0x3001: return "EGL_NOT_INITIALIZED"; break; diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index 77d4c1a076..39d16156ef 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -25,6 +25,8 @@ #include // For GetSystemDirectory() #endif +using std::string; + TypeHandle AudioManager::_type_handle; @@ -312,7 +314,7 @@ get_dls_pathname() { * */ void AudioManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -320,7 +322,7 @@ output(ostream &out) const { * */ void AudioManager:: -write(ostream &out) const { +write(std::ostream &out) const { out << (*this) << "\n"; } diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index 9d121e06b0..19cc27f030 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -14,6 +14,8 @@ #include "audioSound.h" +using std::ostream; + TypeHandle AudioSound::_type_handle; /** diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index 0f58e56a32..1ea8053eb6 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -25,6 +25,10 @@ #error Buildsystem error: BUILDING_PANDA_AUDIO not defined #endif +using std::istream; +using std::ostream; +using std::string; + Configure(config_audio); NotifyCategoryDef(audio, ""); diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index f7126e9b7b..dabeb8c825 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -49,7 +49,7 @@ is_valid() { * */ PT(AudioSound) NullAudioManager:: -get_sound(const string&, bool positional, int mode) { +get_sound(const std::string&, bool positional, int mode) { return get_null_sound(); } @@ -65,7 +65,7 @@ get_sound(MovieAudio *sound, bool positional, int mode) { * */ void NullAudioManager:: -uncache_sound(const string&) { +uncache_sound(const std::string&) { // intentionally blank. } diff --git a/panda/src/audio/nullAudioSound.cxx b/panda/src/audio/nullAudioSound.cxx index 980083b468..0fbdf14672 100644 --- a/panda/src/audio/nullAudioSound.cxx +++ b/panda/src/audio/nullAudioSound.cxx @@ -14,6 +14,8 @@ #include "nullAudioSound.h" +using std::string; + TypeHandle NullAudioSound::_type_handle; namespace { diff --git a/panda/src/audio/test_audio.cxx b/panda/src/audio/test_audio.cxx index a2a7ac06fb..612ad1bcb5 100644 --- a/panda/src/audio/test_audio.cxx +++ b/panda/src/audio/test_audio.cxx @@ -26,9 +26,9 @@ main(int argc, char* argv[]) { PT(AudioSound) tester = AudioPool::load_sound(argv[1]); AudioManager::play(tester); AudioPool::release_all_sounds(); - cerr << "all sounds but 1 released" << endl; + std::cerr << "all sounds but 1 released" << std::endl; } - cerr << "all sounds released" << endl; + std::cerr << "all sounds released" << std::endl; } /* diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 529f6facb0..42fd08c536 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -409,7 +409,7 @@ configure_filters(FilterProperties *config) { * This is what creates a sound instance. */ PT(AudioSound) FmodAudioManager:: -get_sound(const string &file_name, bool positional, int) { +get_sound(const std::string &file_name, bool positional, int) { ReMutexHolder holder(_lock); // Needed so People use Panda's Generic UNIX Style Paths for Filename. // path.to_os_specific() converts it back to the proper OS version later on. @@ -419,15 +419,19 @@ get_sound(const string &file_name, bool positional, int) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(path, get_model_path()); - // Build a new AudioSound from the audio data. - PT(AudioSound) audioSound; - PT(FmodAudioSound) fmodAudioSound = new FmodAudioSound(this, path, positional); + // Locate the file on disk. + path.set_binary(); + PT(VirtualFile) file = vfs->get_file(path); + if (file != nullptr) { + // Build a new AudioSound from the audio data. + PT(FmodAudioSound) sound = new FmodAudioSound(this, file, positional); - _all_sounds.insert(fmodAudioSound); - - audioSound = fmodAudioSound; - - return audioSound; + _all_sounds.insert(sound); + return sound; + } else { + audio_error("createSound(" << path << "): File not found."); + return get_null_sound(); + } } /** @@ -768,7 +772,7 @@ reduce_sounds_playing_to(unsigned int count) { * NOT USED FOR FMOD-EX!!! Clears a sound out of the sound cache. */ void FmodAudioManager:: -uncache_sound(const string& file_name) { +uncache_sound(const std::string& file_name) { audio_debug("FmodAudioManager::uncache_sound(\""<get_original_filename()); _active = manager->get_active(); _paused = false; @@ -74,20 +78,14 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { _manager = fmanager; _channel = 0; - _file_name = file_name; + _file_name = file->get_original_filename(); _file_name.set_binary(); // Get the Speaker Mode [Important for later on.] result = _manager->_system->getSpeakerMode( &_speakermode ); fmod_audio_errcheck("_system->getSpeakerMode()", result); - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - PT(VirtualFile) file = vfs->get_file(_file_name); - if (file == nullptr) { - // File not found. We will display the appropriate error message below. - result = FMOD_ERR_FILE_NOTFOUND; - - } else { + { bool preload = (fmod_audio_preload_threshold < 0) || (file->get_file_size() < fmod_audio_preload_threshold); int flags = FMOD_SOFTWARE; flags |= positional ? FMOD_3D : FMOD_2D; @@ -146,7 +144,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Otherwise, if the Panda threading system is compiled in, we can // assign callbacks to read the file through the VFS. - name_or_data = (const char *)file.p(); + name_or_data = (const char *)file; sound_info.length = (unsigned int)info.get_size(); sound_info.useropen = open_callback; sound_info.userclose = close_callback; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 8d0ad4408c..40de00823d 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -70,10 +70,11 @@ #include #include -class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { - public: +class VirtualFile; - FmodAudioSound(AudioManager *manager, Filename fn, bool positional ); +class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { +public: + FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional); ~FmodAudioSound(); // For best compatibility, set the loop_count, start_time, volume, and diff --git a/panda/src/audiotraits/globalMilesManager.cxx b/panda/src/audiotraits/globalMilesManager.cxx index 1795384b66..796b099425 100644 --- a/panda/src/audiotraits/globalMilesManager.cxx +++ b/panda/src/audiotraits/globalMilesManager.cxx @@ -26,6 +26,9 @@ #include #endif +using std::istream; +using std::string; + GlobalMilesManager *GlobalMilesManager::_global_ptr; /** @@ -414,15 +417,15 @@ seek_callback(UINTa file_handle, S32 offset, U32 type) { strm->clear(); switch (type) { case AIL_FILE_SEEK_BEGIN: - strm->seekg(offset, ios::beg); + strm->seekg(offset, std::ios::beg); break; case AIL_FILE_SEEK_CURRENT: - strm->seekg(offset, ios::cur); + strm->seekg(offset, std::ios::cur); break; case AIL_FILE_SEEK_END: - strm->seekg(offset, ios::end); + strm->seekg(offset, std::ios::end); break; } diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 24ed73d448..2aed1ce44b 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -31,6 +31,8 @@ #include +using std::string; + TypeHandle MilesAudioManager::_type_handle; @@ -153,7 +155,7 @@ get_sound(const string &file_name, bool, int) { } // Put it in the pool: The following is roughly like: _sounds[path] = // sd; But, it gives us an iterator into the map. - pair ib + std::pair ib = _sounds.insert(SoundMap::value_type(path, sd)); if (!ib.second) { // The insert failed. @@ -673,7 +675,7 @@ cleanup() { * */ void MilesAudioManager:: -output(ostream &out) const { +output(std::ostream &out) const { LightReMutexHolder holder(_lock); out << get_type() << ": " << _sounds_playing.size() << " / " << _sounds_on_loan.size() << " sounds playing / total"; @@ -683,7 +685,7 @@ output(ostream &out) const { * */ void MilesAudioManager:: -write(ostream &out) const { +write(std::ostream &out) const { LightReMutexHolder holder(_lock); out << (*this) << "\n"; @@ -899,7 +901,7 @@ load(const Filename &file_name) { bool is_midi_file = (downcase(extension) == "mid"); - if ((miles_audio_preload_threshold == -1 || file->get_file_size() < (streamsize)miles_audio_preload_threshold) || + if ((miles_audio_preload_threshold == -1 || file->get_file_size() < (std::streamsize)miles_audio_preload_threshold) || is_midi_file) { // If the file is sufficiently small, we'll preload it into memory. MIDI // files cannot be streamed, so we always preload them, regardless of diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index e953e77dad..8eb0ab2d26 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -34,7 +34,7 @@ TypeHandle MilesAudioSample::_type_handle; */ MilesAudioSample:: MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name) : + const std::string &file_name) : MilesAudioSound(manager, file_name), _sd(sd) { @@ -176,8 +176,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 1.0: F32 milesVolume = volume; - milesVolume = min(milesVolume, 1.0f); - milesVolume = max(milesVolume, 0.0f); + milesVolume = std::min(milesVolume, 1.0f); + milesVolume = std::max(milesVolume, 0.0f); // Convert balance of -1.0..1.0 to 0-1.0: F32 milesBalance = (F32)((_balance + 1.0f) * 0.5f); @@ -269,7 +269,7 @@ cleanup() { * */ void MilesAudioSample:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << " " << status(); if (!_sd.is_null()) { out << " " << (_sd->_raw_data.size() + 1023) / 1024 << "K"; diff --git a/panda/src/audiotraits/milesAudioSequence.cxx b/panda/src/audiotraits/milesAudioSequence.cxx index 9f16c0dd3d..b214644e54 100644 --- a/panda/src/audiotraits/milesAudioSequence.cxx +++ b/panda/src/audiotraits/milesAudioSequence.cxx @@ -34,7 +34,7 @@ TypeHandle MilesAudioSequence::_type_handle; */ MilesAudioSequence:: MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name) : + const std::string &file_name) : MilesAudioSound(manager, file_name), _sd(sd) { @@ -166,8 +166,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 127: S32 milesVolume = (S32)(volume * 127.0f); - milesVolume = min(milesVolume, 127); - milesVolume = max(milesVolume, 0); + milesVolume = std::min(milesVolume, 127); + milesVolume = std::max(milesVolume, 0); AIL_set_sequence_volume(_sequence, milesVolume, 0); } @@ -296,7 +296,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; AIL_sequence_ms_position(_sequence, &length_ms, nullptr); - time_ms = min(time_ms, length_ms); + time_ms = std::min(time_ms, length_ms); AIL_set_sequence_ms_position(_sequence, time_ms); } diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index de9d0edcff..75ca1d012b 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -16,6 +16,8 @@ #include "milesAudioManager.h" +using std::string; + TypeHandle MilesAudioSound::_type_handle; #undef miles_audio_debug diff --git a/panda/src/audiotraits/milesAudioStream.cxx b/panda/src/audiotraits/milesAudioStream.cxx index debf8dd08a..480d35c81c 100644 --- a/panda/src/audiotraits/milesAudioStream.cxx +++ b/panda/src/audiotraits/milesAudioStream.cxx @@ -32,7 +32,7 @@ TypeHandle MilesAudioStream::_type_handle; * */ MilesAudioStream:: -MilesAudioStream(MilesAudioManager *manager, const string &file_name, +MilesAudioStream(MilesAudioManager *manager, const std::string &file_name, const Filename &path) : MilesAudioSound(manager, file_name), _path(path) @@ -173,8 +173,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 1.0: F32 milesVolume = volume; - milesVolume = min(milesVolume, 1.0f); - milesVolume = max(milesVolume, 0.0f); + milesVolume = std::min(milesVolume, 1.0f); + milesVolume = std::max(milesVolume, 0.0f); // Convert balance of -1.0..1.0 to 0-1.0: F32 milesBalance = (F32)((_balance + 1.0f) * 0.5f); @@ -301,7 +301,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; AIL_stream_ms_position(_stream, &length_ms, nullptr); - time_ms = min(time_ms, length_ms); + time_ms = std::min(time_ms, length_ms); AIL_set_stream_ms_position(_stream, time_ms); } diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index f6b7caa22b..feee7a62aa 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -33,6 +33,9 @@ #define ALC_ALL_DEVICES_SPECIFIER 0x1013 #endif +using std::endl; +using std::string; + TypeHandle OpenALAudioManager::_type_handle; ReMutex OpenALAudioManager::_lock; diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 2a697a642b..8d41a61fa3 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -836,14 +836,14 @@ get_active() const { * */ void OpenALAudioSound:: -set_finished_event(const string& event) { +set_finished_event(const std::string& event) { _finished_event = event; } /** * */ -const string& OpenALAudioSound:: +const std::string& OpenALAudioSound:: get_finished_event() const { return _finished_event; } @@ -851,7 +851,7 @@ get_finished_event() const { /** * Get name of sound file */ -const string& OpenALAudioSound:: +const std::string& OpenALAudioSound:: get_name() const { return _basename; } diff --git a/panda/src/awesomium/AwMouseAndKeyboard.cxx b/panda/src/awesomium/AwMouseAndKeyboard.cxx index 2ee5728584..9948c0d49d 100644 --- a/panda/src/awesomium/AwMouseAndKeyboard.cxx +++ b/panda/src/awesomium/AwMouseAndKeyboard.cxx @@ -17,7 +17,7 @@ TypeHandle AwMouseAndKeyboard::_type_handle; -AwMouseAndKeyboard::AwMouseAndKeyboard(const string &name): +AwMouseAndKeyboard::AwMouseAndKeyboard(const std::string &name): DataNode(name) { _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); @@ -34,7 +34,7 @@ void AwMouseAndKeyboard::do_transmit_data(DataGraphTraverser *trav, const DataNo int num_events = button_events->get_num_events(); for (int i = 0; i < num_events; i++) { const ButtonEvent &be = button_events->get_event(i); - string event_name = be._button.get_name(); + std::string event_name = be._button.get_name(); printf("Button Event! : %s with code %i and index %i ", event_name.c_str(), be._keycode, be._button.get_index()); if(be._type == ButtonEvent::T_down) printf("down"); if(be._type == ButtonEvent::T_repeat) printf("repeat"); diff --git a/panda/src/awesomium/WebBrowserTexture.cxx b/panda/src/awesomium/WebBrowserTexture.cxx index 04908f4abc..1051a33e36 100644 --- a/panda/src/awesomium/WebBrowserTexture.cxx +++ b/panda/src/awesomium/WebBrowserTexture.cxx @@ -33,7 +33,7 @@ Texture(copy) /** * This initializes a web browser texture with the given AwWebView class. */ -WebBrowserTexture::WebBrowserTexture(const string &name, AwWebView* aw_web_view): +WebBrowserTexture::WebBrowserTexture(const std::string &name, AwWebView* aw_web_view): Texture(name), _update_active(true), _flip_texture_active(false) diff --git a/panda/src/awesomium/awWebView.cxx b/panda/src/awesomium/awWebView.cxx index 5ef0b95181..ebc3a63f89 100644 --- a/panda/src/awesomium/awWebView.cxx +++ b/panda/src/awesomium/awWebView.cxx @@ -28,7 +28,7 @@ AwWebView:: void AwWebView:: -loadURL2(const string& url, const string& frameName , const string& username , const string& password ) +loadURL2(const std::string& url, const std::string& frameName , const std::string& username , const std::string& password ) { _myWebView->loadURL2(url, frameName, username, password); diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 565cfa35a2..9067999599 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -20,6 +20,7 @@ #include "collisionPlane.h" #include "collisionSphere.h" #include "collisionPolygon.h" +#include "collisionTube.h" TypeHandle BulletBodyNode::_type_handle; @@ -150,7 +151,7 @@ safe_to_flatten_below() const { * */ void BulletBodyNode:: -do_output(ostream &out) const { +do_output(std::ostream &out) const { PandaNode::output(out); @@ -166,7 +167,7 @@ do_output(ostream &out) const { * */ void BulletBodyNode:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); do_output(out); @@ -427,7 +428,7 @@ remove_shape(BulletShape *shape) { found = find(_shapes.begin(), _shapes.end(), ptshape); if (found == _shapes.end()) { - bullet_cat.warning() << "shape not attached" << endl; + bullet_cat.warning() << "shape not attached" << std::endl; } else { _shapes.erase(found); @@ -784,7 +785,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { PT(BulletTriangleMesh) mesh = nullptr; - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); TypeHandle type = solid->get_type(); @@ -804,6 +805,14 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { do_add_shape(BulletBoxShape::make_from_solid(box), ts); } + // CollisionTube + else if (CollisionTube::get_class_type() == type) { + CPT(CollisionTube) tube = DCAST(CollisionTube, solid); + CPT(TransformState) ts = TransformState::make_pos((tube->get_point_b() + tube->get_point_a()) / 2.0); + + do_add_shape(BulletCapsuleShape::make_from_solid(tube), ts); + } + // CollisionPlane else if (CollisionPlane::get_class_type() == type) { CPT(CollisionPlane) plane = DCAST(CollisionPlane, solid); @@ -819,9 +828,9 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { mesh = new BulletTriangleMesh(); } - for (int i=2; i < polygon->get_num_points(); i++ ) { + for (size_t i = 2; i < polygon->get_num_points(); ++i) { LPoint3 p1 = polygon->get_point(0); - LPoint3 p2 = polygon->get_point(i-1); + LPoint3 p2 = polygon->get_point(i - 1); LPoint3 p3 = polygon->get_point(i); mesh->do_add_triangle(p1, p2, p3, true); diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 44fbc3e501..ba9e02ab83 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -35,7 +35,7 @@ BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _shape = new btCapsuleShapeZ(radius, height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << up << std::endl; break; } @@ -65,7 +65,7 @@ BulletCapsuleShape(const BulletCapsuleShape ©) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } @@ -82,6 +82,22 @@ ptr() const { return _shape; } + +/** + * Constructs a new BulletCapsuleShape using the information from a + * CollisionTube from the builtin collision system. + */ +BulletCapsuleShape *BulletCapsuleShape:: +make_from_solid(const CollisionTube *solid) { + + PN_stdfloat radius = solid->get_radius(); + // CollisionTube height includes the hemispheres, Bullet only wants the cylinder height. + PN_stdfloat height = (solid->get_point_b() - solid->get_point_a()).length() - (radius * 2); + + // CollisionTubes are always Z-Up. + return new BulletCapsuleShape(radius, height, Z_up); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ @@ -150,7 +166,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index 9994d9f1dc..f8eecfe3d7 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -20,6 +20,8 @@ #include "bullet_utils.h" #include "bulletShape.h" +#include "collisionTube.h" + /** * */ @@ -33,6 +35,8 @@ PUBLISHED: BulletCapsuleShape(const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); + static BulletCapsuleShape *make_from_solid(const CollisionTube *solid); + INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_half_height() const; diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index d65948a824..e9652de7e5 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -34,7 +34,7 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const // Get convex shape (for ghost object) if (!shape->is_convex()) { - bullet_cat.error() << "a convex shape is required!" << endl; + bullet_cat.error() << "a convex shape is required!" << std::endl; return; } diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index 84c1fc4157..c4c554ba2f 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -35,7 +35,7 @@ BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _shape = new btConeShapeZ((btScalar)radius, (btScalar)height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << up << std::endl; break; } @@ -65,7 +65,7 @@ BulletConeShape(const BulletConeShape ©) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } @@ -150,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 6d107bff7a..976daac96e 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -13,6 +13,8 @@ #include "bulletCylinderShape.h" +using std::endl; + TypeHandle BulletCylinderShape::_type_handle; /** diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index 743b5163ff..ce0c044758 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -256,12 +256,12 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { trav->_geoms_pcollector.add_level(2); { CullableObject *object = - new CullableObject(move(debug_lines), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); + new CullableObject(std::move(debug_lines), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); trav->get_cull_handler()->record_object(object, trav); } { CullableObject *object = - new CullableObject(move(debug_triangles), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); + new CullableObject(std::move(debug_triangles), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); trav->get_cull_handler()->record_object(object, trav); } } @@ -300,7 +300,7 @@ getDebugMode() const { void BulletDebugNode::DebugDraw:: reportErrorWarning(const char *warning) { - bullet_cat.error() << warning << endl; + bullet_cat.error() << warning << std::endl; } /** @@ -381,7 +381,7 @@ drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, cons void BulletDebugNode::DebugDraw:: drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, const btVector3 &n2, const btVector3 &color, btScalar alpha) { - bullet_cat.debug() << "drawTriangle(2) - not yet implemented!" << endl; + bullet_cat.debug() << "drawTriangle(2) - not yet implemented!" << std::endl; } /** @@ -402,7 +402,7 @@ drawContactPoint(const btVector3 &point, const btVector3 &normal, btScalar dista void BulletDebugNode::DebugDraw:: draw3dText(const btVector3 &location, const char *text) { - bullet_cat.debug() << "draw3dText - not yet implemented!" << endl; + bullet_cat.debug() << "draw3dText - not yet implemented!" << std::endl; } /** diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index fad9e8141a..b4008820a1 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -97,8 +97,7 @@ do_transform_changed() { if (ts->has_scale()) { LVecBase3 scale = ts->get_scale(); if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { - for (int i=0; i < _shapes.size(); i++) { - PT(BulletShape) shape = _shapes[i]; + for (BulletShape *shape : _shapes) { shape->do_set_local_scale(scale); } } diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 6f5f0529e3..15e8d6f75f 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -89,7 +89,7 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) : for (int row=0; row < _num_rows; row++) { for (int column=0; column < _num_cols; column++) { if (!peeker->lookup_bilinear(sample, row * step_x, column * step_y)) { - bullet_cat.error() << "Could not sample texture." << endl; + bullet_cat.error() << "Could not sample texture." << std::endl; } // Transpose _data[_num_rows * column + row] = max_height * sample.get_x(); diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index d5e3f503b4..e786e34d40 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -83,7 +83,7 @@ from_collision_solids(NodePath &np, bool clear) { bool BulletHelper:: is_tangible(CollisionNode *cnode) { - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); if (solid->is_tangible()) { return true; diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index ffaed8bafb..52d1edc42f 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -23,7 +23,7 @@ TypeHandle BulletMultiSphereShape::_type_handle; BulletMultiSphereShape:: BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) { - int num_spheres = min(points.size(), radii.size()); + int num_spheres = std::min(points.size(), radii.size()); // Convert points btVector3 *bt_points = new btVector3[num_spheres]; diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 0d1a97fd4e..98dce53577 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -15,6 +15,18 @@ TypeHandle BulletPlaneShape::_type_handle; +/** + * Creates a plane shape from a plane definition. + */ +BulletPlaneShape:: +BulletPlaneShape(LPlane plane) { + + btVector3 btNormal = LVecBase3_to_btVector3(plane.get_normal()); + + _shape = new btStaticPlaneShape(btNormal, plane.get_w()); + _shape->setUserPointer(this); +} + /** * */ @@ -50,6 +62,17 @@ ptr() const { return _shape; } +/** + * + */ +LPlane BulletPlaneShape:: +get_plane() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + btVector3 normal = _shape->getPlaneNormal(); + return LPlane(normal[0], normal[1], normal[2], (PN_stdfloat)_shape->getPlaneConstant()); +} + /** * */ diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 95aa16d9ef..4521007ecb 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -32,15 +32,18 @@ private: INLINE BulletPlaneShape() : _shape(nullptr) {}; PUBLISHED: + explicit BulletPlaneShape(LPlane plane); explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); + LPlane get_plane() const; LVector3 get_plane_normal() const; PN_stdfloat get_plane_constant() const; static BulletPlaneShape *make_from_solid(const CollisionPlane *solid); + MAKE_PROPERTY(plane, get_plane); MAKE_PROPERTY(plane_normal, get_plane_normal); MAKE_PROPERTY(plane_constant, get_plane_constant); diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index ab8c4327f9..b0d36f705e 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -74,7 +74,7 @@ make_copy() const { * */ void BulletRigidBodyNode:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); BulletBodyNode::do_output(out); diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 546a73f311..cf027f208d 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -207,7 +207,7 @@ transform_changed() { _soft->scale(new_scale); } - _sync = move(ts); + _sync = std::move(ts); } } @@ -276,8 +276,15 @@ do_sync_b2p() { // Update the synchronized transform with the current approximate center of // the soft body - LVecBase3 pos = this->do_get_aabb().get_approx_center(); - CPT(TransformState) ts = TransformState::make_pos(pos); + btVector3 pMin, pMax; + _soft->getAabb(pMin, pMax); + LPoint3 pos = (btVector3_to_LPoint3(pMin) + btVector3_to_LPoint3(pMax)) * 0.5; + CPT(TransformState) ts; + if (!pos.is_nan()) { + ts = TransformState::make_pos(pos); + } else { + ts = TransformState::make_identity(); + } NodePath np = NodePath::any_path((PandaNode *)this); LVecBase3 scale = np.get_net_transform()->get_scale(); @@ -883,7 +890,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon } // Read indices - for (int i=0; iget_num_primitives(); i++) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { CPT(GeomPrimitive) prim = geom->get_primitive(i); prim = prim->decompose(); diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 9286a2d010..368aa22fac 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -17,6 +17,8 @@ #include "geomVertexData.h" #include "geomVertexReader.h" +using std::endl; + TypeHandle BulletTriangleMesh::_type_handle; /** @@ -53,7 +55,7 @@ LPoint3 BulletTriangleMesh:: get_vertex(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(index < _vertices.size(), LPoint3::zero()); + nassertr(index < (size_t)_vertices.size(), LPoint3::zero()); const btVector3 &vertex = _vertices[index]; return LPoint3(vertex[0], vertex[1], vertex[2]); } @@ -66,7 +68,7 @@ get_triangle(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); index *= 3; - nassertr(index + 2 < _indices.size(), LVecBase3i::zero()); + nassertr(index + 2 < (size_t)_indices.size(), LVecBase3i::zero()); return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]); } @@ -226,7 +228,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } } - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -237,7 +239,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState CPT(GeomVertexArrayData) vertices = prim->get_vertices(); if (vertices != nullptr) { - GeomVertexReader index(move(vertices), 0); + GeomVertexReader index(std::move(vertices), 0); while (!index.is_at_end()) { _indices.push_back(index_offset + index.get_data1i()); } @@ -269,7 +271,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } // Add triangles - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -280,7 +282,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState CPT(GeomVertexArrayData) vertices = prim->get_vertices(); if (vertices != nullptr) { - GeomVertexReader index(move(vertices), 0); + GeomVertexReader index(std::move(vertices), 0); while (!index.is_at_end()) { _indices.push_back(find_or_add_vertex(points[index.get_data1i()])); } @@ -351,7 +353,7 @@ add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_dupli * */ void BulletTriangleMesh:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); out << get_type() << ", " << _indices.size() / 3 << " triangles"; @@ -361,11 +363,11 @@ output(ostream &out) const { * */ void BulletTriangleMesh:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":" << endl; const IndexedMeshArray &array = _mesh.getIndexedMeshArray(); - for (size_t i = 0; i < array.size(); ++i) { + for (int i = 0; i < array.size(); ++i) { indent(out, indent_level + 2) << "IndexedMesh " << i << ":" << endl; const btIndexedMesh &mesh = array[0]; indent(out, indent_level + 4) << "num triangles:" << mesh.m_numTriangles << endl; diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index ca9f7288cc..8416c52cbc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -46,13 +46,13 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b // Assert that mesh is not NULL if (!mesh) { - bullet_cat.warning() << "mesh is NULL! creating new mesh." << endl; + bullet_cat.warning() << "mesh is NULL! creating new mesh." << std::endl; mesh = new BulletTriangleMesh(); } // Assert that mesh has at least one triangle if (mesh->do_get_num_triangles() == 0) { - bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << endl; + bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << std::endl; mesh->add_triangle(LPoint3::zero(), LPoint3::zero(), LPoint3::zero()); } diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 8d0f479dee..5dbb70cc7f 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -52,7 +52,7 @@ set_coordinate_system(BulletUpAxis up) { _vehicle->setCoordinateSystem(0, 2, 1); break; default: - bullet_cat.error() << "invalid up axis:" << up << endl; + bullet_cat.error() << "invalid up axis:" << up << std::endl; break; } } @@ -232,6 +232,9 @@ void BulletVehicle:: do_sync_b2p() { for (int i=0; i < _vehicle->getNumWheels(); i++) { + // synchronize the wheels with the (interpolated) chassis worldtransform + _vehicle->updateWheelTransform(i, true); + btWheelInfo info = _vehicle->getWheelInfo(i); PandaNode *node = (PandaNode *)info.m_clientInfo; diff --git a/panda/src/bullet/bulletWheel.I b/panda/src/bullet/bulletWheel.I index cbf82a40bc..0523ba9727 100644 --- a/panda/src/bullet/bulletWheel.I +++ b/panda/src/bullet/bulletWheel.I @@ -34,7 +34,7 @@ INLINE BulletWheelRaycastInfo:: INLINE BulletWheel BulletWheel:: empty() { - btWheelInfoConstructionInfo ci; + btWheelInfoConstructionInfo ci {}; btWheelInfo info(ci); return BulletWheel(info); diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 6827140e93..e1e416a2bb 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -19,7 +19,12 @@ #include "collideMask.h" #include "lightMutexHolder.h" -#define clamp(x, x_min, x_max) max(min(x, x_max), x_min) +#define clamp(x, x_min, x_max) std::max(std::min(x, x_max), x_min) + +using std::endl; +using std::istream; +using std::ostream; +using std::string; TypeHandle BulletWorld::_type_handle; @@ -37,7 +42,7 @@ BulletWorld:: BulletWorld() { // Init groups filter matrix - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { _filter_cb2._collide[i].clear(); _filter_cb2._collide[i].set_bit(i); } @@ -248,20 +253,20 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { void BulletWorld:: do_sync_p2b(PN_stdfloat dt, int num_substeps) { - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_p2b(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_p2b(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_p2b(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_p2b(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_p2b(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_p2b(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_p2b(dt, num_substeps); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_p2b(dt, num_substeps); } } @@ -271,24 +276,24 @@ do_sync_p2b(PN_stdfloat dt, int num_substeps) { void BulletWorld:: do_sync_b2p() { - for (int i=0; i < _vehicles.size(); i++) { - _vehicles[i]->do_sync_b2p(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_b2p(); } - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_b2p(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_b2p(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_b2p(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_b2p(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_b2p(); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_b2p(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_b2p(); + for (BulletVehicle *vehicle : _vehicles) { + vehicle->do_sync_b2p(); } } @@ -942,7 +947,9 @@ ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask & } /** - * + * Performs a sweep test against all other shapes that match the given group + * mask. The provided shape must be a convex shape; it is an error to invoke + * this method using a non-convex shape. */ BulletClosestHitSweepResult BulletWorld:: sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const TransformState &to_ts, const CollideMask &mask, PN_stdfloat penetration) const { @@ -1268,7 +1275,7 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co // cout << mask0 << " " << mask1 << endl; - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { if (mask0.get_bit(i)) { if ((_collide[i] & mask1) != 0) // cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl; diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 4e228427b9..5997bf575b 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -207,7 +207,7 @@ init_libbullet() { // Initialize notification category bullet_cat.init(); - bullet_cat.debug() << "initialize module" << endl; + bullet_cat.debug() << "initialize module" << std::endl; // Register the Bullet system PandaSystem *ps = PandaSystem::get_global_ptr(); diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index 312483b3be..8313516485 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -51,7 +51,7 @@ copy_bundle() const { * Writes a one-line description of the bundle. */ void AnimBundle:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << ", " << get_num_frames() << " frames at " << get_base_frame_rate() << " fps"; } diff --git a/panda/src/chan/animChannel.cxx b/panda/src/chan/animChannel.cxx index dfaf152b7b..d34d364068 100644 --- a/panda/src/chan/animChannel.cxx +++ b/panda/src/chan/animChannel.cxx @@ -22,7 +22,7 @@ template class AnimChannel; * Outputs a very brief description of a matrix. */ void ACMatrixSwitchType:: -output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { +output_value(std::ostream &out, const ACMatrixSwitchType::ValueType &value) { LVecBase3 scale, shear, hpr, translate; if (decompose_matrix(value, scale, shear, hpr, translate)) { if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index 1fa762e782..53b2771685 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -49,7 +49,7 @@ AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic © * */ AnimChannelMatrixDynamic:: -AnimChannelMatrixDynamic(const string &name) +AnimChannelMatrixDynamic(const std::string &name) : AnimChannelMatrix(name) { _value = TransformState::make_identity(); diff --git a/panda/src/chan/animChannelMatrixFixed.cxx b/panda/src/chan/animChannelMatrixFixed.cxx index cf79e7ea5a..d5f0ef3d84 100644 --- a/panda/src/chan/animChannelMatrixFixed.cxx +++ b/panda/src/chan/animChannelMatrixFixed.cxx @@ -34,7 +34,7 @@ AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : * */ AnimChannelMatrixFixed:: -AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : +AnimChannelMatrixFixed(const std::string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : AnimChannel(name), _pos(pos), _hpr(hpr), _scale(scale) { @@ -116,7 +116,7 @@ get_shear(int, LVecBase3 &shear) { * */ void AnimChannelMatrixFixed:: -output(ostream &out) const { +output(std::ostream &out) const { AnimChannel::output(out); out << ": pos " << _pos << " hpr " << _hpr << " scale " << _scale; } diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index ec9564ee88..c6c27b8b7a 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -54,7 +54,7 @@ AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable &co * */ AnimChannelMatrixXfmTable:: -AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name) +AnimChannelMatrixXfmTable(AnimGroup *parent, const std::string &name) : AnimChannelMatrix(parent, name) { for (int i = 0; i < num_matrix_components; i++) { @@ -267,7 +267,7 @@ clear_all_tables() { * Writes a brief description of the table and all of its descendants. */ void AnimChannelMatrixXfmTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_name() << " "; @@ -369,7 +369,7 @@ write_datagram(BamWriter *manager, Datagram &me) { // Now, write out the joint angles. For these we need to build up a HPR // array. pvector hprs; - int hprs_length = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size()); + int hprs_length = std::max(std::max(_tables[6].size(), _tables[7].size()), _tables[8].size()); hprs.reserve(hprs_length); for (i = 0; i < hprs_length; i++) { PN_stdfloat h = _tables[6].empty() ? 0.0f : _tables[6][i % _tables[6].size()]; @@ -419,7 +419,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (!new_hpr) { // Convert between the old HPR form and the new HPR form. - size_t num_hprs = max(max(_tables[6].size(), _tables[7].size()), + size_t num_hprs = std::max(std::max(_tables[6].size(), _tables[7].size()), _tables[8].size()); LVecBase3 default_hpr(0.0, 0.0, 0.0); diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index a5597110ba..8a9835a550 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -51,7 +51,7 @@ AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic © * */ AnimChannelScalarDynamic:: -AnimChannelScalarDynamic(const string &name) +AnimChannelScalarDynamic(const std::string &name) : AnimChannelScalar(name) { _last_value = _value = TransformState::make_identity(); diff --git a/panda/src/chan/animChannelScalarTable.cxx b/panda/src/chan/animChannelScalarTable.cxx index 195258b9c7..54953164e7 100644 --- a/panda/src/chan/animChannelScalarTable.cxx +++ b/panda/src/chan/animChannelScalarTable.cxx @@ -47,7 +47,7 @@ AnimChannelScalarTable(AnimGroup *parent, const AnimChannelScalarTable ©) : * */ AnimChannelScalarTable:: -AnimChannelScalarTable(AnimGroup *parent, const string &name) : +AnimChannelScalarTable(AnimGroup *parent, const std::string &name) : AnimChannelScalar(parent, name), _table(get_class_type()) { @@ -115,7 +115,7 @@ set_table(const CPTA_stdfloat &table) { * Writes a brief description of the table and all of its descendants. */ void AnimChannelScalarTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_name() << " " << _table.size(); diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 34fd94646e..aa47ea7486 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -27,7 +27,7 @@ TypeHandle AnimControl::_type_handle; * being loaded during an asynchronous load-and-bind operation. */ AnimControl:: -AnimControl(const string &name, PartBundle *part, +AnimControl(const std::string &name, PartBundle *part, double frame_rate, int num_frames) : Namable(name), _pending_lock(name), @@ -131,7 +131,7 @@ wait_pending() { * binding, the event will be thrown immediately. */ void AnimControl:: -set_pending_done_event(const string &done_event) { +set_pending_done_event(const std::string &done_event) { MutexHolder holder(_pending_lock); _pending_done_event = done_event; if (!_pending) { @@ -143,7 +143,7 @@ set_pending_done_event(const string &done_event) { * Returns the event name that will be thrown when the AnimControl is finished * binding asynchronously. */ -string AnimControl:: +std::string AnimControl:: get_pending_done_event() const { MutexHolder holder(_pending_lock); return _pending_done_event; @@ -161,7 +161,7 @@ get_part() const { * */ void AnimControl:: -output(ostream &out) const { +output(std::ostream &out) const { out << "AnimControl(" << get_name() << ", " << get_part()->get_name() << ": "; AnimInterface::output(out); diff --git a/panda/src/chan/animControlCollection.cxx b/panda/src/chan/animControlCollection.cxx index 50783b5305..f8e6ed7b17 100644 --- a/panda/src/chan/animControlCollection.cxx +++ b/panda/src/chan/animControlCollection.cxx @@ -13,6 +13,8 @@ #include "animControlCollection.h" +using std::string; + /** * Returns the AnimControl associated with the given name, or NULL if no such @@ -252,7 +254,7 @@ which_anim_playing() const { * */ void AnimControlCollection:: -output(ostream &out) const { +output(std::ostream &out) const { out << _controls.size() << " anims."; } @@ -260,7 +262,7 @@ output(ostream &out) const { * */ void AnimControlCollection:: -write(ostream &out) const { +write(std::ostream &out) const { ControlsByName::const_iterator ci; for (ci = _controls_by_name.begin(); ci != _controls_by_name.end(); diff --git a/panda/src/chan/animGroup.cxx b/panda/src/chan/animGroup.cxx index 4c23b36110..17a83f1f20 100644 --- a/panda/src/chan/animGroup.cxx +++ b/panda/src/chan/animGroup.cxx @@ -24,6 +24,8 @@ #include +using std::string; + TypeHandle AnimGroup::_type_handle; @@ -179,7 +181,7 @@ get_value_type() const { * Writes a one-line description of the group. */ void AnimGroup:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } @@ -187,7 +189,7 @@ output(ostream &out) const { * Writes a brief description of the group and all of its descendants. */ void AnimGroup:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this; if (!_children.empty()) { out << " {\n"; @@ -201,7 +203,7 @@ write(ostream &out, int indent_level) const { * Writes a brief description of all of the group's descendants. */ void AnimGroup:: -write_descendants(ostream &out, int indent_level) const { +write_descendants(std::ostream &out, int indent_level) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -277,7 +279,7 @@ complete_pointers(TypedWritable **p_list, BamReader *) { for (int i = 1; i < _num_children+1; i++) { if (p_list[i] == TypedWritable::Null) { chan_cat->warning() << get_type().get_name() - << " Ignoring null child" << endl; + << " Ignoring null child" << std::endl; } else { _children.push_back(DCAST(AnimGroup, p_list[i])); } diff --git a/panda/src/chan/animPreloadTable.cxx b/panda/src/chan/animPreloadTable.cxx index 9303c11490..43958482b3 100644 --- a/panda/src/chan/animPreloadTable.cxx +++ b/panda/src/chan/animPreloadTable.cxx @@ -60,7 +60,7 @@ get_num_anims() const { * Filename::get_basename_wo_extension(). */ int AnimPreloadTable:: -find_anim(const string &basename) const { +find_anim(const std::string &basename) const { consider_sort(); AnimRecord record; record._basename = basename; @@ -96,7 +96,7 @@ remove_anim(int n) { * See find_anim(). This will invalidate existing index numbers. */ void AnimPreloadTable:: -add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames) { +add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames) { AnimRecord record; record._basename = basename; record._base_frame_rate = base_frame_rate; @@ -124,7 +124,7 @@ add_anims_from(const AnimPreloadTable *other) { * */ void AnimPreloadTable:: -output(ostream &out) const { +output(std::ostream &out) const { consider_sort(); out << "AnimPreloadTable, " << _anims.size() << " animation records."; } @@ -133,7 +133,7 @@ output(ostream &out) const { * */ void AnimPreloadTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { consider_sort(); indent(out, indent_level) << "AnimPreloadTable, " << _anims.size() << " animation records:\n"; diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index e9e827b319..993201a8ef 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -18,6 +18,8 @@ #include "string_utils.h" #include "partGroup.h" +using std::string; + typedef pset AnimBundles; typedef pmap Anims; diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index c1b34038ff..637f44831d 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -22,7 +22,7 @@ TypeHandle BindAnimRequest::_type_handle; * */ BindAnimRequest:: -BindAnimRequest(const string &name, +BindAnimRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader, AnimControl *control, int hierarchy_match_flags, diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index cc60dabe3c..e4016edd2c 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -26,7 +26,7 @@ TypeHandle MovingPartBase::_type_handle; * */ MovingPartBase:: -MovingPartBase(PartGroup *parent, const string &name) : +MovingPartBase(PartGroup *parent, const std::string &name) : PartGroup(parent, name), _num_effective_channels(0), _effective_control(nullptr) @@ -70,7 +70,7 @@ get_forced_channel() const { * Writes a brief description of the channel and all of its descendants. */ void MovingPartBase:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name(); if (_children.empty()) { out << "\n"; @@ -86,7 +86,7 @@ write(ostream &out, int indent_level) const { * with their values. */ void MovingPartBase:: -write_with_value(ostream &out, int indent_level) const { +write_with_value(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name() << "\n"; indent(out, indent_level); output_value(out); diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index d2aa343774..966987995a 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -31,6 +31,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + TypeHandle PartBundle::_type_handle; @@ -150,10 +154,11 @@ apply_transform(const TransformState *transform) { AppliedTransforms::iterator ati = _applied_transforms.find(transform); if (ati != _applied_transforms.end()) { - if ((*ati).first.is_valid_pointer() && - (*ati).second.is_valid_pointer()) { - // Here's our cached result. - return (*ati).second.lock(); + if ((*ati).first.is_valid_pointer()) { + if (auto new_bundle = (*ati).second.lock()) { + // Here's our cached result. + return new_bundle; + } } } diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index 7a611a80de..f8fda4bd47 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -172,7 +172,7 @@ private: typedef pvector Nodes; Nodes _nodes; - typedef pmap AppliedTransforms; + typedef pmap > AppliedTransforms; AppliedTransforms _applied_transforms; double _update_delay; diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index ad501ca24c..52cee4ce19 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -25,6 +25,8 @@ #include +using std::ostream; + TypeHandle PartGroup::_type_handle; /** @@ -32,7 +34,7 @@ TypeHandle PartGroup::_type_handle; * to delete it subsequently is to delete the entire hierarchy. */ PartGroup:: -PartGroup(PartGroup *parent, const string &name) : +PartGroup(PartGroup *parent, const std::string &name) : Namable(name), _children(get_class_type()) { @@ -113,7 +115,7 @@ get_child(int n) const { * find_child(). */ PartGroup *PartGroup:: -get_child_named(const string &name) const { +get_child_named(const std::string &name) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { PartGroup *child = (*ci); @@ -131,7 +133,7 @@ get_child_named(const string &name) const { * this PartGroup; see also get_child_named(). */ PartGroup *PartGroup:: -find_child(const string &name) const { +find_child(const std::string &name) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { PartGroup *child = (*ci); diff --git a/panda/src/chan/partSubset.cxx b/panda/src/chan/partSubset.cxx index 6e88cce020..5e2a6c5831 100644 --- a/panda/src/chan/partSubset.cxx +++ b/panda/src/chan/partSubset.cxx @@ -89,7 +89,7 @@ append(const PartSubset &other) { * */ void PartSubset:: -output(ostream &out) const { +output(std::ostream &out) const { if (_include_joints.empty() && _exclude_joints.empty()) { out << "PartSubset, empty"; } else { @@ -120,7 +120,7 @@ is_include_empty() const { * false otherwise. */ bool PartSubset:: -matches_include(const string &joint_name) const { +matches_include(const std::string &joint_name) const { Joints::const_iterator ji; for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) { if ((*ji).matches(joint_name)) { @@ -137,7 +137,7 @@ matches_include(const string &joint_name) const { * false otherwise. */ bool PartSubset:: -matches_exclude(const string &joint_name) const { +matches_exclude(const std::string &joint_name) const { Joints::const_iterator ji; for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) { if ((*ji).matches(joint_name)) { diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 8b5bac116a..0e2655de54 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -73,7 +73,7 @@ Character(const Character ©, bool copy_bundles) : * */ Character:: -Character(const string &name) : +Character(const std::string &name) : PartBundleNode(name, new CharacterJointBundle(name)), _joints_pcollector(PStatCollector(_animation_pcollector, name), "Joints"), _skinning_pcollector(PStatCollector(_animation_pcollector, name), "Vertices") @@ -355,7 +355,7 @@ clear_lod_animation() { * to a slider. */ CharacterJoint *Character:: -find_joint(const string &name) const { +find_joint(const std::string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); @@ -373,7 +373,7 @@ find_joint(const string &name) const { * to a joint. */ CharacterSlider *Character:: -find_slider(const string &name) const { +find_slider(const std::string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); @@ -391,7 +391,7 @@ find_slider(const string &name) const { * structure, to the indicated output stream. */ void Character:: -write_parts(ostream &out) const { +write_parts(std::ostream &out) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { get_bundle(i)->write(out, 0); @@ -404,7 +404,7 @@ write_parts(ostream &out) const { * stream. */ void Character:: -write_part_values(ostream &out) const { +write_part_values(std::ostream &out) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { get_bundle(i)->write_with_value(out, 0); @@ -671,7 +671,7 @@ r_merge_bundles(Character::JointMap &joint_map, int new_num_children = new_group->get_num_children(); PartGroup::Children new_children(PartGroup::get_class_type()); - new_children.reserve(max(old_num_children, new_num_children)); + new_children.reserve(std::max(old_num_children, new_num_children)); while (i < old_num_children && j < new_num_children) { PartGroup *pc = old_group->get_child(i); diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 8a424d91c1..7e3e1c9b9a 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -50,7 +50,7 @@ CharacterJoint(const CharacterJoint ©) : */ CharacterJoint:: CharacterJoint(Character *character, - PartBundle *root, PartGroup *parent, const string &name, + PartBundle *root, PartGroup *parent, const std::string &name, const LMatrix4 &default_value) : MovingPartMatrix(parent, name, default_value), _character(character) diff --git a/panda/src/char/characterJointBundle.cxx b/panda/src/char/characterJointBundle.cxx index 980e9058dc..86a43f7e13 100644 --- a/panda/src/char/characterJointBundle.cxx +++ b/panda/src/char/characterJointBundle.cxx @@ -24,7 +24,7 @@ TypeHandle CharacterJointBundle::_type_handle; * Character node will automatically create one for itself. */ CharacterJointBundle:: -CharacterJointBundle(const string &name) : PartBundle(name) { +CharacterJointBundle(const std::string &name) : PartBundle(name) { } /** diff --git a/panda/src/char/characterJointEffect.I b/panda/src/char/characterJointEffect.I index e4d596dafe..34e2502afa 100644 --- a/panda/src/char/characterJointEffect.I +++ b/panda/src/char/characterJointEffect.I @@ -35,5 +35,9 @@ get_character() const { */ INLINE bool CharacterJointEffect:: matches_character(Character *character) const { - return _character == character; + // This works because while the Character is destructing, the ref count will + // be 0 but was_deleted() will still return false. We cannot construct a + // PointerTo to the character (via lock() or otherwise) when the reference + // count is 0 since that will cause double deletion. + return _character.get_orig() == character && !_character.was_deleted(); } diff --git a/panda/src/char/characterJointEffect.cxx b/panda/src/char/characterJointEffect.cxx index 50b1a878e8..b4bc263c20 100644 --- a/panda/src/char/characterJointEffect.cxx +++ b/panda/src/char/characterJointEffect.cxx @@ -87,7 +87,7 @@ safe_to_combine() const { * */ void CharacterJointEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); PT(Character) character = get_character(); if (character != nullptr) { diff --git a/panda/src/char/characterSlider.cxx b/panda/src/char/characterSlider.cxx index 824b7e2737..b4ced5e782 100644 --- a/panda/src/char/characterSlider.cxx +++ b/panda/src/char/characterSlider.cxx @@ -40,7 +40,7 @@ CharacterSlider(const CharacterSlider ©) : * */ CharacterSlider:: -CharacterSlider(PartGroup *parent, const string &name) +CharacterSlider(PartGroup *parent, const std::string &name) : MovingPartScalar(parent, name) { } diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index 5212aa6cd9..5f60777ff1 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -83,7 +83,7 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { * */ void JointVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << _joint->get_name(); } diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm index 07f44b6c94..f45837ed87 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm @@ -25,7 +25,7 @@ TypeHandle CocoaGraphicsBuffer::_type_handle; */ CocoaGraphicsBuffer:: CocoaGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index dd554e2a77..91bd0fbbb9 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -169,7 +169,7 @@ CocoaGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string CocoaGraphicsPipe:: +std::string CocoaGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -199,7 +199,7 @@ CocoaGraphicsPipe::get_preferred_window_thread() const { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) CocoaGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index ec25b94486..26d4dbdf71 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -190,7 +190,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // make it grab one with 8 bits, though. Dirty hack. Needs more research. if (properties.get_alpha_bits() > 0) { attribs.push_back(NSOpenGLPFAAlphaSize); - attribs.push_back(max(8, properties.get_alpha_bits())); + attribs.push_back(std::max(8, properties.get_alpha_bits())); } if (properties.get_multisamples() > 0) { diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index df12a69985..7d461817f1 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -50,7 +50,7 @@ TypeHandle CocoaGraphicsWindow::_type_handle; */ CocoaGraphicsWindow:: CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -1293,7 +1293,7 @@ load_image(const Filename &filename) { if (vfile == NULL) { return nil; } - istream *str = vfile->open_read_file(true); + std::istream *str = vfile->open_read_file(true); if (str == NULL) { cocoadisplay_cat.error() << "Could not open file " << filename << " for reading\n"; @@ -1449,7 +1449,7 @@ handle_foreground_event(bool foreground) { */ bool CocoaGraphicsWindow:: handle_close_request() { - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the request // and process it directly. diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx index 2ef46e4a99..90ea8a21cf 100644 --- a/panda/src/collada/colladaBindMaterial.cxx +++ b/panda/src/collada/colladaBindMaterial.cxx @@ -48,7 +48,7 @@ get_material(const ColladaPrimitive *prim) const { * found. */ CPT(RenderState) ColladaBindMaterial:: -get_material(const string &symbol) const { +get_material(const std::string &symbol) const { if (_states.count(symbol) == 0) { return nullptr; } diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index be6522b23f..09ce788655 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -37,7 +37,7 @@ * Pretty obvious what this does. */ ColladaInput:: -ColladaInput(const string &semantic) : +ColladaInput(const std::string &semantic) : _column_name (nullptr), _semantic (semantic), _offset (0), @@ -69,14 +69,14 @@ ColladaInput(const string &semantic) : * Pretty obvious what this does. */ ColladaInput:: -ColladaInput(const string &semantic, unsigned int set) : +ColladaInput(const std::string &semantic, unsigned int set) : _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (true), _set (set) { - ostringstream setstr; + std::ostringstream setstr; setstr << _set; if (semantic == "POSITION") { diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index 7414af0a7f..1347d492a1 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -76,7 +76,7 @@ bool ColladaLoader:: read(const Filename &filename) { _filename = filename; - string data; + std::string data; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); if (!vfs->read_file(_filename, data, true)) { @@ -299,7 +299,7 @@ load_tags(domExtra &extra, PandaNode *node) { daeElement &child = *children[c]; if (cmp_nocase(child.getElementName(), "tag") == 0) { - const string &name = child.getAttribute("name"); + const std::string &name = child.getAttribute("name"); if (name.size() > 0) { node->set_tag(name, child.getCharData()); } else { diff --git a/panda/src/collada/loaderFileTypeDae.cxx b/panda/src/collada/loaderFileTypeDae.cxx index 9fc5785514..a35223f30c 100644 --- a/panda/src/collada/loaderFileTypeDae.cxx +++ b/panda/src/collada/loaderFileTypeDae.cxx @@ -26,7 +26,7 @@ LoaderFileTypeDae() { /** * */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_name() const { #if PANDA_COLLADA_VERSION == 14 return "COLLADA 1.4"; @@ -40,7 +40,7 @@ get_name() const { /** * */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_extension() const { return "dae"; } @@ -49,7 +49,7 @@ get_extension() const { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this loader. */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_additional_extensions() const { return "zae"; } diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index ad025f8682..a8af257456 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -16,6 +16,7 @@ #include "collisionRay.h" #include "collisionSphere.h" #include "collisionSegment.h" +#include "collisionTube.h" #include "collisionHandler.h" #include "collisionEntry.h" #include "config_collide.h" @@ -35,6 +36,9 @@ #include +using std::max; +using std::min; + PStatCollector CollisionBox::_volume_pcollector("Collision Volumes:CollisionBox"); PStatCollector CollisionBox::_test_pcollector("Collision Tests:CollisionBox"); TypeHandle CollisionBox::_type_handle; @@ -181,7 +185,7 @@ get_test_pcollector() { * */ void CollisionBox:: -output(ostream &out) const { +output(std::ostream &out) const { } /** @@ -395,6 +399,49 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } +/** + * + */ +PT(CollisionEntry) CollisionBox:: +test_intersection_from_line(const CollisionEntry &entry) const { + const CollisionLine *line; + DCAST_INTO_R(line, entry.get_from(), nullptr); + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; + + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction)) { + // No intersection. + return nullptr; + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); + + if (has_effective_normal() && line->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } + + return new_entry; +} /** * Double dispatch point for ray as a FROM object @@ -408,51 +455,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 from_origin = ray->get_origin() * wrt_mat; LVector3 from_direction = ray->get_direction() * wrt_mat; - int i, j; - PN_stdfloat t; - PN_stdfloat near_t = 0.0; - bool intersect; - LPlane plane; - LPlane near_plane; - - // Returns the details about the first plane of the box that the ray - // intersects. - for (i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { - plane = get_plane(i); - - if (!plane.intersects_line(t, from_origin, from_direction)) { - // No intersection. The ray is parallel to the plane. - continue; - } - - if (t < 0.0f) { - // The intersection point is before the start of the ray, and so the ray - // is entirely in front of the plane. - continue; - } - LPoint3 plane_point = from_origin + t * from_direction; - LPoint2 p = to_2d(plane_point, i); - - if (!point_is_inside(p, _points[i])){ - continue; - } - intersect = true; - if (j) { - if(t < near_t) { - near_plane = plane; - near_t = t; - } - } - else { - near_plane = plane; - near_t = t; - } - ++j; - } - - - if(!intersect) { - // No intersection with ANY of the box's planes has been detected + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction) || (t1 < 0.0 && t2 < 0.0)) { + // No intersection. return nullptr; } @@ -461,22 +466,32 @@ test_intersection_from_ray(const CollisionEntry &entry) const { << "intersection detected from " << entry.get_from_node_path() << " into " << entry.get_into_node_path() << "\n"; } - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3 into_intersection_point = from_origin + near_t * from_direction; + if (t1 < 0.0) { + // The origin is inside the box, so we take the exit as our surface point. + new_entry->set_interior_point(from_origin); + t1 = t2; + } - LVector3 normal = - (has_effective_normal() && ray->get_respect_effective_normal()) - ? get_effective_normal() : near_plane.get_normal(); + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); - new_entry->set_surface_normal(normal); - new_entry->set_surface_point(into_intersection_point); + if (has_effective_normal() && ray->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } return new_entry; } - /** * Double dispatch point for segment as a FROM object */ @@ -490,51 +505,10 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPoint3 from_extent = seg->get_point_b() * wrt_mat; LVector3 from_direction = from_extent - from_origin; - int i, j; - PN_stdfloat t; - PN_stdfloat near_t = 0.0; - bool intersect; - LPlane plane; - LPlane near_plane; - - // Returns the details about the first plane of the box that the segment - // intersects. - for(i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { - plane = get_plane(i); - - if (!plane.intersects_line(t, from_origin, from_direction)) { - // No intersection. The segment is parallel to the plane. - continue; - } - - if (t < 0.0f || t > 1.0f) { - // The intersection point is before the start of the segment, or after - // the end of the segment, so the segment is either entirely in front of - // or behind the plane. - continue; - } - LPoint3 plane_point = from_origin + t * from_direction; - LPoint2 p = to_2d(plane_point, i); - - if (!point_is_inside(p, _points[i])){ - continue; - } - intersect = true; - if(j) { - if(t < near_t) { - near_plane = plane; - near_t = t; - } - } - else { - near_plane = plane; - near_t = t; - } - ++j; - } - - if(!intersect) { - // No intersection with ANY of the box's planes has been detected + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction) || + (t1 < 0.0 && t2 < 0.0) || (t1 > 1.0 && t2 > 1.0)) { + // No intersection. return nullptr; } @@ -543,17 +517,176 @@ test_intersection_from_segment(const CollisionEntry &entry) const { << "intersection detected from " << entry.get_from_node_path() << " into " << entry.get_into_node_path() << "\n"; } - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3 into_intersection_point = from_origin + near_t * from_direction; + // In case the segment is entirely inside the cube, we consider the point + // closest to the surface as our entry point. + if (t1 < (1.0 - t2)) { + std::swap(t1, t2); + } - LVector3 normal = - (has_effective_normal() && seg->get_respect_effective_normal()) - ? get_effective_normal() : near_plane.get_normal(); + // Our interior point is the closest point to t2 that is inside the segment. + new_entry->set_interior_point(from_origin + std::min(std::max(t2, 0.0), 1.0) * from_direction); - new_entry->set_surface_normal(normal); - new_entry->set_surface_point(into_intersection_point); + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); + + if (has_effective_normal() && seg->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } + + return new_entry; +} + +/** + * Double dispatch point for tube as a FROM object + */ +PT(CollisionEntry) CollisionBox:: +test_intersection_from_tube(const CollisionEntry &entry) const { + const CollisionTube *tube; + DCAST_INTO_R(tube, entry.get_from(), nullptr); + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_a = tube->get_point_a() * wrt_mat; + LPoint3 from_b = tube->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; + PN_stdfloat radius_sq = wrt_mat.xform_vec(LVector3(0, 0, tube->get_radius())).length_squared(); + PN_stdfloat radius = csqrt(radius_sq); + + LPoint3 box_min = get_min(); + LPoint3 box_max = get_max(); + LVector3 dimensions = box_max - box_min; + + // The method below is inspired by Christer Ericson's book Real-Time + // Collision Detection. Instead of testing a capsule against a box, we test + // a segment against an box that is oversized by the capsule radius. + + // First, we test if the line segment intersects a box with its faces + // expanded outwards by the capsule radius. If not, there is no collision. + double t1, t2; + if (!intersects_line(t1, t2, from_a, from_direction, radius)) { + return nullptr; + } + + if (t2 < 0.0 || t1 > 1.0) { + return nullptr; + } + + t1 = std::min(1.0, std::max(0.0, (t1 + t2) * 0.5)); + LPoint3 point = from_a + from_direction * t1; + + // We now have a point of intersection between the line segment and the + // oversized box. Check on how many axes it lies outside the box. If it is + // less than two, we know that it does not lie in one of the rounded regions + // of the oversized rounded box, and it is a guaranteed hit. Otherwise, we + // will need to test against the edge regions. + if ((point[0] < box_min[0] || point[0] > box_max[0]) + + (point[1] < box_min[1] || point[1] > box_max[1]) + + (point[2] < box_min[2] || point[2] > box_max[2]) > 1) { + // Test the capsule against each edge of the box. + static const struct { + LPoint3 point; + int axis; + } edges[] = { + {{0, 0, 0}, 0}, + {{0, 1, 0}, 0}, + {{0, 0, 1}, 0}, + {{0, 1, 1}, 0}, + {{0, 0, 0}, 1}, + {{0, 0, 1}, 1}, + {{1, 0, 0}, 1}, + {{1, 0, 1}, 1}, + {{0, 0, 0}, 2}, + {{0, 1, 0}, 2}, + {{1, 0, 0}, 2}, + {{1, 1, 0}, 2}, + }; + + PN_stdfloat best_dist_sq = FLT_MAX; + + for (int i = 0; i < 12; ++i) { + LPoint3 vertex = edges[i].point; + vertex.componentwise_mult(dimensions); + vertex += box_min; + LVector3 delta(0); + delta[edges[i].axis] = dimensions[edges[i].axis]; + double u1, u2; + CollisionTube::calc_closest_segment_points(u1, u2, from_a, from_direction, vertex, delta); + PN_stdfloat dist_sq = ((from_a + from_direction * u1) - (vertex + delta * u2)).length_squared(); + if (dist_sq < best_dist_sq) { + best_dist_sq = dist_sq; + } + } + + if (best_dist_sq > radius_sq) { + // It is not actually touching any edge. + return nullptr; + } + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + // Which is the longest axis? + LVector3 diff = point - _center; + diff[0] /= dimensions[0]; + diff[1] /= dimensions[1]; + diff[2] /= dimensions[2]; + int axis = 0; + if (cabs(diff[0]) > cabs(diff[1])) { + if (cabs(diff[0]) > cabs(diff[2])) { + axis = 0; + } else { + axis = 2; + } + } else { + if (cabs(diff[1]) > cabs(diff[2])) { + axis = 1; + } else { + axis = 2; + } + } + LVector3 normal(0); + normal[axis] = std::copysign(1, diff[axis]); + + LPoint3 clamped = point.fmax(box_min).fmin(box_max); + LPoint3 surface_point = clamped; + surface_point[axis] = (diff[axis] >= 0.0f) ? box_max[axis] : box_min[axis]; + + // Is the point inside the box? + LVector3 interior_vec; + if (clamped != point) { + // No, it is outside. The interior point is in the direction of the + // surface point. + interior_vec = point - surface_point; + if (!interior_vec.normalize()) { + interior_vec = normal; + } + } else { + // It is inside. I think any point will work for this. + interior_vec = normal; + } + new_entry->set_interior_point(point - interior_vec * radius); + new_entry->set_surface_point(surface_point); + + if (has_effective_normal() && tube->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + new_entry->set_surface_normal(normal); + } return new_entry; } @@ -820,6 +953,51 @@ fill_viz_geom() { _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } +/** + * Determine the point(s) of intersection of a parametric line with the box. + * The line is infinite in both directions, and passes through "from" and + * from+delta. If the line does not intersect the box, the function returns + * false, and t1 and t2 are undefined. If it does intersect the box, it + * returns true, and t1 and t2 are set to the points along the equation + * from+t*delta that correspond to the two points of intersection. + */ +bool CollisionBox:: +intersects_line(double &t1, double &t2, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_size) const { + + LPoint3 bmin = _min - LVector3(inflate_size); + LPoint3 bmax = _max + LVector3(inflate_size); + + double tmin = -DBL_MAX; + double tmax = DBL_MAX; + + for (int i = 0; i < 3; ++i) { + PN_stdfloat d = delta[i]; + if (!IS_NEARLY_ZERO(d)) { + double tmin2 = (bmin[i] - from[i]) / d; + double tmax2 = (bmax[i] - from[i]) / d; + if (tmin2 > tmax2) { + std::swap(tmin2, tmax2); + } + tmin = std::max(tmin, tmin2); + tmax = std::min(tmax, tmax2); + + if (tmin > tmax) { + return false; + } + + } else if (from[i] < bmin[i] || from[i] > bmax[i]) { + // The line is entirely parallel in this dimension. + return false; + } + } + + t1 = tmin; + t2 = tmax; + return true; +} + /** * Clips the polygon by all of the clip planes named in the clip plane * attribute and fills new_points up with the resulting points. diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index 0888d7e4da..cf9e8bc15b 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -75,15 +75,24 @@ protected: virtual PT(BoundingVolume) compute_internal_bounds() const; virtual PT(CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) + test_intersection_from_line(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_ray(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) + test_intersection_from_tube(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_box(const CollisionEntry &entry) const; virtual void fill_viz_geom(); +protected: + bool intersects_line(double &t1, double &t2, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_size=0) const; + private: LPoint3 _center; LPoint3 _min; diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 237c725579..2a8c97fa2c 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -209,7 +209,7 @@ get_all_contact_info(const NodePath &space, LPoint3 &contact_pos, * */ void CollisionEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << _from_node_path; if (!_into_node_path.is_empty()) { out << " into " << _into_node_path; @@ -223,7 +223,7 @@ output(ostream &out) const { * */ void CollisionEntry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionEntry:\n"; if (!_from_node_path.is_empty()) { diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index fa7ac93949..5f0ab0cabc 100644 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -33,6 +33,10 @@ #include "geomLinestrips.h" #include "geomVertexWriter.h" #include + +using std::max; +using std::min; + PStatCollector CollisionFloorMesh::_volume_pcollector("Collision Volumes:CollisionFloorMesh"); PStatCollector CollisionFloorMesh::_test_pcollector("Collision Tests:CollisionFloorMesh"); TypeHandle CollisionFloorMesh::_type_handle; @@ -86,7 +90,7 @@ get_collision_origin() const { * */ void CollisionFloorMesh:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cfloor"; } @@ -406,7 +410,7 @@ register_with_read_factory() { * */ void CollisionFloorMesh:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/panda/src/collide/collisionGeom.cxx b/panda/src/collide/collisionGeom.cxx index 15211b9598..b90bebe38b 100644 --- a/panda/src/collide/collisionGeom.cxx +++ b/panda/src/collide/collisionGeom.cxx @@ -47,6 +47,6 @@ get_test_pcollector() { * */ void CollisionGeom:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cgeom"; } diff --git a/panda/src/collide/collisionHandlerEvent.cxx b/panda/src/collide/collisionHandlerEvent.cxx index 872044bb22..0fd949074e 100644 --- a/panda/src/collide/collisionHandlerEvent.cxx +++ b/panda/src/collide/collisionHandlerEvent.cxx @@ -17,6 +17,8 @@ #include "eventParameter.h" #include "throw_event.h" +using std::string; + TypeHandle CollisionHandlerEvent::_type_handle; diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index 3c8c8e80bf..506101cb41 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -18,6 +18,9 @@ #include "clockObject.h" +using std::cout; +using std::endl; + TypeHandle CollisionHandlerFloor::_type_handle; /** @@ -204,7 +207,7 @@ handle_entries() { if (adjust < 0.0f && _max_velocity != 0.0f) { PN_stdfloat max_adjust = _max_velocity * ClockObject::get_global_clock()->get_dt(); - adjust = max(adjust, -max_adjust); + adjust = std::max(adjust, -max_adjust); } CPT(TransformState) trans = def._target.get_transform(); diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index 42a52a54b6..023d220cd4 100644 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -18,6 +18,9 @@ #include "collisionPlane.h" #include "clockObject.h" +using std::cout; +using std::endl; + TypeHandle CollisionHandlerGravity::_type_handle; /** @@ -254,10 +257,10 @@ handle_entries() { // ...the node is under the floor, so it has landed. Keep the // adjust to bring us up to the ground and then add the // gravity_adjust to get us airborne: - adjust += max((PN_stdfloat)0.0, gravity_adjust); + adjust += std::max((PN_stdfloat)0.0, gravity_adjust); } else { // ...the node is above the floor, so it is airborne. - adjust = max(adjust, gravity_adjust); + adjust = std::max(adjust, gravity_adjust); } _current_velocity -= _gravity * dt; // Record the airborne height in case someone else needs it: diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 7a2fefd271..75761362bd 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -126,7 +126,7 @@ get_entry(int n) const { * */ void CollisionHandlerQueue:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CollisionHandlerQueue, " << _entries.size() << " entries"; } @@ -134,7 +134,7 @@ output(ostream &out) const { * */ void CollisionHandlerQueue:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionHandlerQueue, " << _entries.size() << " entries:\n"; diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 2074fb9522..8a75135e55 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -72,7 +72,7 @@ get_test_pcollector() { * */ void CollisionInvSphere:: -output(ostream &out) const { +output(std::ostream &out) const { out << "invsphere, c (" << get_center() << "), r " << get_radius(); } @@ -198,7 +198,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { t1 = t2 = 0.0; } - t2 = max(t2, 0.0); + t2 = std::max(t2, 0.0); if (collide_cat.is_debug()) { collide_cat.debug() @@ -254,11 +254,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } else if (t2 <= 1.0) { // The bottom edge of the segment intersects the shell. - t = min(t2, 1.0); + t = std::min(t2, 1.0); } else if (t1 >= 0.0) { // The top edge of the segment intersects the shell. - t = max(t1, 0.0); + t = std::max(t1, 0.0); } else { // Neither edge of the segment intersects the shell. It follows that both diff --git a/panda/src/collide/collisionLine.cxx b/panda/src/collide/collisionLine.cxx index 5e98087145..27b066b3c9 100644 --- a/panda/src/collide/collisionLine.cxx +++ b/panda/src/collide/collisionLine.cxx @@ -51,7 +51,7 @@ test_intersection(const CollisionEntry &entry) const { * */ void CollisionLine:: -output(ostream &out) const { +output(std::ostream &out) const { out << "line, o (" << get_origin() << "), d (" << get_direction() << ")"; } diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 803a5f058d..ce037f917f 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -37,7 +37,7 @@ TypeHandle CollisionNode::_type_handle; * */ CollisionNode:: -CollisionNode(const string &name) : +CollisionNode(const std::string &name) : PandaNode(name), _from_collide_mask(get_default_collide_mask()), _collider_sort(0) @@ -252,7 +252,7 @@ is_collision_node() const { * classes to include some information relevant to the class. */ void CollisionNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " (" << _solids.size() << " solids)"; } diff --git a/panda/src/collide/collisionParabola.cxx b/panda/src/collide/collisionParabola.cxx index 734647b16c..b758cf037a 100644 --- a/panda/src/collide/collisionParabola.cxx +++ b/panda/src/collide/collisionParabola.cxx @@ -90,7 +90,7 @@ get_test_pcollector() { * */ void CollisionParabola:: -output(ostream &out) const { +output(std::ostream &out) const { out << _parabola << ", t1 = " << _t1 << ", t2 = " << _t2; } @@ -145,8 +145,8 @@ compute_internal_bounds() const { for (int i = 0; i < num_points; ++i) { double t = (double)(i + 1) / (double)(num_points + 1); LPoint3 p = psp.calc_point(get_t1() + t * (get_t2() - get_t1())); - min_z = min(min_z, p[2]); - max_z = max(max_z, p[2]); + min_z = std::min(min_z, p[2]); + max_z = std::max(max_z, p[2]); } // That gives us a simple bounding volume in parabola space. @@ -157,7 +157,7 @@ compute_internal_bounds() const { LPoint3(0.01, 0, max_z), LPoint3(-0.01, 0, max_z)); // And convert that back into real space. volume->xform(from_parabola); - return volume.p(); + return volume; } /** diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index f869f6c2d1..8a325ea082 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -89,7 +89,7 @@ get_test_pcollector() { * */ void CollisionPlane:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cplane, (" << _plane << ")"; } @@ -397,7 +397,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { // Both intersection points are within our segment of the parabola. // Choose the first of the two. - t = min(t1, t2); + t = std::min(t1, t2); } else { // Only t1 is within our segment. t = t1; diff --git a/panda/src/collide/collisionPolygon.I b/panda/src/collide/collisionPolygon.I index 4a048a3995..6c7785d730 100644 --- a/panda/src/collide/collisionPolygon.I +++ b/panda/src/collide/collisionPolygon.I @@ -57,7 +57,7 @@ CollisionPolygon() { /** * Returns the number of vertices of the CollisionPolygon. */ -INLINE int CollisionPolygon:: +INLINE size_t CollisionPolygon:: get_num_points() const { return _points.size(); } @@ -66,8 +66,8 @@ get_num_points() const { * Returns the nth vertex of the CollisionPolygon, expressed in 3-D space. */ INLINE LPoint3 CollisionPolygon:: -get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); +get_point(size_t n) const { + nassertr(n < _points.size(), LPoint3::zero()); LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); return to_3d(_points[n]._p, to_3d_mat); diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 2e907c0695..24c8230d2f 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -41,6 +41,9 @@ #include +using std::max; +using std::min; + PStatCollector CollisionPolygon::_volume_pcollector("Collision Volumes:CollisionPolygon"); PStatCollector CollisionPolygon::_test_pcollector("Collision Tests:CollisionPolygon"); TypeHandle CollisionPolygon::_type_handle; @@ -268,9 +271,9 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, draw_polygon(viz_geom_node, bounds_viz_geom_node, new_points); if (bounds_only) { - return bounds_viz_geom_node.p(); + return bounds_viz_geom_node; } else { - return viz_geom_node.p(); + return viz_geom_node; } } @@ -296,7 +299,7 @@ get_test_pcollector() { * */ void CollisionPolygon:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cpolygon, (" << get_plane() << "), " << _points.size() << " vertices"; } @@ -305,7 +308,7 @@ output(ostream &out) const { * */ void CollisionPolygon:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 1ef095fd92..f7fa771bfa 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -45,8 +45,8 @@ public: PUBLISHED: virtual LPoint3 get_collision_origin() const; - INLINE int get_num_points() const; - INLINE LPoint3 get_point(int n) const; + INLINE size_t get_num_points() const; + INLINE LPoint3 get_point(size_t n) const; MAKE_SEQ(get_points, get_num_points, get_point); diff --git a/panda/src/collide/collisionRay.cxx b/panda/src/collide/collisionRay.cxx index 05aa445aa1..9cbf9223fe 100644 --- a/panda/src/collide/collisionRay.cxx +++ b/panda/src/collide/collisionRay.cxx @@ -72,7 +72,7 @@ get_collision_origin() const { * */ void CollisionRay:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ray, o (" << get_origin() << "), d (" << get_direction() << ")"; } diff --git a/panda/src/collide/collisionRecorder.cxx b/panda/src/collide/collisionRecorder.cxx index 45580e97f1..9abd0814a7 100644 --- a/panda/src/collide/collisionRecorder.cxx +++ b/panda/src/collide/collisionRecorder.cxx @@ -42,7 +42,7 @@ CollisionRecorder:: * */ void CollisionRecorder:: -output(ostream &out) const { +output(std::ostream &out) const { out << "tested " << _num_missed + _num_detected << ", detected " << _num_detected << "\n"; } diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index 3fa0fe0524..f0ea03f12a 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -75,7 +75,7 @@ get_collision_origin() const { * */ void CollisionSegment:: -output(ostream &out) const { +output(std::ostream &out) const { out << "segment, a (" << _a << "), b (" << _b << ")"; } @@ -131,7 +131,7 @@ compute_internal_bounds() const { LPoint3(0.01, -0.01, 0.01), LPoint3(-0.01, -0.01, 0.01)); volume->xform(from_segment); - return volume.p(); + return volume; } /** diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index f812c836f2..b862ec7c73 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -146,9 +146,9 @@ get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) cons } if (bounds_only) { - return _bounds_viz_geom.p(); + return _bounds_viz_geom; } else { - return _viz_geom.p(); + return _viz_geom; } } @@ -174,7 +174,7 @@ get_test_pcollector() { * */ void CollisionSolid:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -182,7 +182,7 @@ output(ostream &out) const { * */ void CollisionSolid:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index 898fbd86c6..a07b1fbcbc 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -33,6 +33,9 @@ #include "geomTristrips.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + PStatCollector CollisionSphere::_volume_pcollector( "Collision Volumes:CollisionSphere"); PStatCollector CollisionSphere::_test_pcollector( @@ -102,7 +105,7 @@ get_test_pcollector() { * */ void CollisionSphere:: -output(ostream &out) const { +output(std::ostream &out) const { out << "sphere, c (" << get_center() << "), r " << get_radius(); } diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 65f33cba31..6e8a01d68f 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -38,6 +38,8 @@ #include +using std::min; + PStatCollector CollisionTraverser::_collisions_pcollector("App:Collisions"); PStatCollector CollisionTraverser::_cnode_volume_pcollector("Collision Volumes:CollisionNode"); @@ -67,7 +69,7 @@ public: * */ CollisionTraverser:: -CollisionTraverser(const string &name) : +CollisionTraverser(const std::string &name) : Namable(name), _this_pcollector(_collisions_pcollector, name) { @@ -421,7 +423,7 @@ hide_collisions() { * */ void CollisionTraverser:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CollisionTraverser, " << _colliders.size() << " colliders and " << _handlers.size() << " handlers.\n"; } @@ -430,7 +432,7 @@ output(ostream &out) const { * */ void CollisionTraverser:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionTraverser, " << _colliders.size() << " colliders and " << _handlers.size() << " handlers:\n"; @@ -1389,7 +1391,7 @@ PStatCollector &CollisionTraverser:: get_pass_collector(int pass) { nassertr(pass >= 0, _this_pcollector); while ((int)_pass_collectors.size() <= pass) { - ostringstream name; + std::ostringstream name; name << "pass" << (_pass_collectors.size() + 1); PStatCollector col(_this_pcollector, name.str()); _pass_collectors.push_back(col); diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index b84e308395..90f82a3630 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -104,7 +104,7 @@ get_test_pcollector() { * */ void CollisionTube:: -output(ostream &out) const { +output(std::ostream &out) const { out << "tube, a (" << _a << "), b (" << _b << "), r " << _radius; } @@ -183,7 +183,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } // doubles, not floats, to satisfy min and max templates. - actual_t = min(1.0, max(0.0, t1)); + actual_t = std::min(1.0, std::max(0.0, t1)); contact_point = from_a + actual_t * (from_b - from_a); if (collide_cat.is_debug()) { @@ -391,6 +391,70 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } +/** + * + */ +PT(CollisionEntry) CollisionTube:: +test_intersection_from_tube(const CollisionEntry &entry) const { + const CollisionTube *tube; + DCAST_INTO_R(tube, entry.get_from(), nullptr); + + LPoint3 into_a = _a; + LVector3 into_direction = _b - into_a; + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_a = tube->get_point_a() * wrt_mat; + LPoint3 from_b = tube->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; + + LVector3 from_radius_v = + LVector3(tube->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); + + // Determine the points on each segment with the smallest distance between. + double into_t, from_t; + calc_closest_segment_points(into_t, from_t, + into_a, into_direction, + from_a, from_direction); + LPoint3 into_closest = into_a + into_direction * into_t; + LPoint3 from_closest = from_a + from_direction * from_t; + + // If the distance is greater than the sum of tube radii, the test fails. + LVector3 closest_vec = from_closest - into_closest; + PN_stdfloat distance = closest_vec.length(); + if (distance > _radius + from_radius) { + return nullptr; + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + if (distance != 0) { + // This is the most common case, where the line segments don't touch + // exactly. We point the normal along the vector of the closest distance. + LVector3 surface_normal = closest_vec * (1.0 / distance); + + new_entry->set_surface_point(into_closest + surface_normal * _radius); + new_entry->set_interior_point(from_closest - surface_normal * from_radius); + + if (has_effective_normal() && tube->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else if (distance != 0) { + new_entry->set_surface_normal(surface_normal); + } + } else { + // The rare case of the line segments touching exactly. + set_intersection_point(new_entry, into_closest, 0); + } + + return new_entry; +} + /** * */ @@ -578,6 +642,80 @@ calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, return LVertex(x, y, z); } +/** + * Given line segments s1 and s2 defined by two points each, computes the + * point on each segment with the closest distance between them. + */ +void CollisionTube:: +calc_closest_segment_points(double &t1, double &t2, + const LPoint3 &from1, const LVector3 &delta1, + const LPoint3 &from2, const LVector3 &delta2) { + // Copyright 2001 softSurfer, 2012 Dan Sunday + // This code may be freely used, distributed and modified for any purpose + // providing that this copyright notice is included with it. + // SoftSurfer makes no warranty for this code, and cannot be held + // liable for any real or imagined damage resulting from its use. + // Users of this code must verify correctness for their application. + LVector3 w = from1 - from2; + PN_stdfloat a = delta1.dot(delta1); // always >= 0 + PN_stdfloat b = delta1.dot(delta2); + PN_stdfloat c = delta2.dot(delta2); // always >= 0 + PN_stdfloat d = delta1.dot(w); + PN_stdfloat e = delta2.dot(w); + PN_stdfloat D = a * c - b * b; // always >= 0 + PN_stdfloat sN, sD = D; + PN_stdfloat tN, tD = D; + + // compute the line parameters of the two closest points + if (IS_NEARLY_ZERO(D)) { // the lines are almost parallel + sN = 0.0; // force using point P0 on segment S1 + sD = 1.0; // to prevent possible division by 0.0 later + tN = e; + tD = c; + } else { + // get the closest points on the infinite lines + sN = (b*e - c*d); + tN = (a*e - b*d); + if (sN < 0.0) { // sc < 0 => the s=0 edge is visible + sN = 0.0; + tN = e; + tD = c; + } else if (sN > sD) { // sc > 1 => the s=1 edge is visible + sN = sD; + tN = e + b; + tD = c; + } + } + + if (tN < 0.0) { // tc < 0 => the t=0 edge is visible + tN = 0.0; + // recompute sc for this edge + if (-d < 0.0) { + sN = 0.0; + } else if (-d > a) { + sN = sD; + } else { + sN = -d; + sD = a; + } + } else if (tN > tD) { // tc > 1 => the t=1 edge is visible + tN = tD; + // recompute sc for this edge + if ((-d + b) < 0.0) { + sN = 0; + } else if ((-d + b) > a) { + sN = sD; + } else { + sN = (-d + b); + sD = a; + } + } + + // finally do the division to get sc and tc + t1 = (IS_NEARLY_ZERO(sN) ? 0.0 : sN / sD); + t2 = (IS_NEARLY_ZERO(tN) ? 0.0 : tN / tD); +} + /** * Determine the point(s) of intersection of a parametric line with the tube. * The line is infinite in both directions, and passes through "from" and @@ -692,7 +830,7 @@ intersects_line(double &t1, double &t2, // The starting point is off the bottom of the tube. Test the line // against the first endcap. double t1a, t2a; - if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -703,7 +841,7 @@ intersects_line(double &t1, double &t2, // The starting point is off the top of the tube. Test the line against // the second endcap. double t1b, t2b; - if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -715,7 +853,7 @@ intersects_line(double &t1, double &t2, // The ending point is off the bottom of the tube. Test the line against // the first endcap. double t1a, t2a; - if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -726,7 +864,7 @@ intersects_line(double &t1, double &t2, // The ending point is off the top of the tube. Test the line against the // second endcap. double t1b, t2b; - if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -740,16 +878,14 @@ intersects_line(double &t1, double &t2, /** * After confirming that the line intersects an infinite cylinder, test * whether it intersects one or the other endcaps. The y parameter specifies - * the center of the sphere (and hence the particular endcap. + * the center of the sphere (and hence the particular endcap). */ bool CollisionTube:: sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, const LPoint3 &from, const LVector3 &delta, - PN_stdfloat inflate_radius) const { + PN_stdfloat radius) { // See CollisionSphere::intersects_line() for a derivation of the formula // here. - PN_stdfloat radius = _radius + inflate_radius; - double A = dot(delta, delta); nassertr(A != 0.0, false); @@ -824,7 +960,7 @@ intersects_parabola(double &t, const LParabola ¶bola, return false; } - t = max(t1a, 0.0); + t = std::max(t1a, 0.0); return true; } diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 1742e24927..3d91ce2506 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -82,6 +82,8 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) + test_intersection_from_tube(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; virtual void fill_viz_geom(); @@ -93,12 +95,15 @@ private: LVertex calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, PN_stdfloat length); + static void calc_closest_segment_points(double &t1, double &t2, + const LPoint3 &from1, const LVector3 &delta1, + const LPoint3 &from2, const LVector3 &delta2); bool intersects_line(double &t1, double &t2, const LPoint3 &from, const LVector3 &delta, PN_stdfloat inflate_radius) const; - bool sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, - const LPoint3 &from, const LVector3 &delta, - PN_stdfloat inflate_radius) const; + static bool sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat radius); bool intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, const LPoint3 &p1, const LPoint3 &p2) const; @@ -146,6 +151,8 @@ public: private: static TypeHandle _type_handle; + + friend class CollisionBox; }; #include "collisionTube.I" diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 0c7861b5eb..0cebbeffdf 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -41,7 +41,7 @@ TypeHandle CollisionVisualizer::_type_handle; * */ CollisionVisualizer:: -CollisionVisualizer(const string &name) : PandaNode(name), _lock("CollisionVisualizer") { +CollisionVisualizer(const std::string &name) : PandaNode(name), _lock("CollisionVisualizer") { set_cull_callback(); // We always want to render the CollisionVisualizer node itself (even if it @@ -263,7 +263,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void CollisionVisualizer:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " "; CollisionRecorder::output(out); @@ -296,9 +296,9 @@ collision_tested(const CollisionEntry &entry, bool detected) { nassertv(!solid.is_null()); LightMutexHolder holder(_lock); - VizInfo &viz_info = _data[move(net_transform)]; + VizInfo &viz_info = _data[std::move(net_transform)]; if (detected) { - viz_info._solids[move(solid)]._detected_count++; + viz_info._solids[std::move(solid)]._detected_count++; if (entry.has_surface_point()) { CollisionPoint p; @@ -308,7 +308,7 @@ collision_tested(const CollisionEntry &entry, bool detected) { } } else { - viz_info._solids[move(solid)]._missed_count++; + viz_info._solids[std::move(solid)]._missed_count++; } } diff --git a/panda/src/collide/test_collide.cxx b/panda/src/collide/test_collide.cxx deleted file mode 100644 index 38736d5d38..0000000000 --- a/panda/src/collide/test_collide.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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." - * - * @file test_collide.cxx - * @author drose - * @date 2000-04-24 - */ - -#include "collisionTraverser.h" -#include "collisionNode.h" -#include "collisionSphere.h" -#include "collisionPlane.h" -#include "collisionHandlerPusher.h" - -#include "namedNode.h" -#include "pt_NamedNode.h" -#include "pointerTo.h" -#include "transformTransition.h" -#include "luse.h" -#include "get_rel_pos.h" -#include "renderRelation.h" - -int -main(int argc, char *argv[]) { - PT_NamedNode r = new NamedNode("r"); - - PT_NamedNode a = new NamedNode("a"); - PT_NamedNode b = new NamedNode("b"); - - PT(CollisionNode) aa = new CollisionNode("aa"); - PT(CollisionNode) ab = new CollisionNode("ab"); - PT(CollisionNode) ba = new CollisionNode("ba"); - - RenderRelation *r_a = new RenderRelation(r, a); - RenderRelation *r_b = new RenderRelation(r, b); - - RenderRelation *a_aa = new RenderRelation(a, aa); - RenderRelation *a_ab = new RenderRelation(a, ab); - RenderRelation *b_ba = new RenderRelation(b, ba); - - - CollisionSphere *aa1 = new CollisionSphere(LPoint3f(0, 0, 0), 1); - aa->add_solid(aa1); - a_aa->set_transition(new TransformTransition(LMatrix4f::translate_mat(0, -5, 0))); - - CollisionSphere *ab1 = new CollisionSphere(LPoint3f(0, 2, 0), 1.5); - ab->add_solid(ab1); - - Planef plane(LVector3f(0, 1, 0), LPoint3f(0, 0, 0)); - CollisionPlane *ba1 = new CollisionPlane(plane); - ba->add_solid(ba1); - - CollisionTraverser ct; - PT(CollisionHandlerPusher) chp = new CollisionHandlerPusher; - chp->add_collider(aa, a_aa); - ct.add_collider(aa, chp); - - ct.traverse(r); - - nout << "\nFrame 2:\n\n"; - - ct.traverse(r); - - return (0); -} diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index 99da6cf5ac..34eef90ccf 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -39,7 +39,7 @@ CullBinBackToFront:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinBackToFront:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinBackToFront(name, gsg, draw_region_pcollector); } @@ -85,9 +85,6 @@ void CullBinBackToFront:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; @@ -96,9 +93,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index e3e5637ad9..8bd81cf8fe 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -39,7 +39,7 @@ CullBinFixed:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinFixed:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFixed(name, gsg, draw_region_pcollector); } @@ -71,9 +71,6 @@ void CullBinFixed:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; @@ -82,9 +79,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 4d297d1c94..a552c027fa 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -39,7 +39,7 @@ CullBinFrontToBack:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinFrontToBack:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFrontToBack(name, gsg, draw_region_pcollector); } @@ -85,9 +85,6 @@ void CullBinFrontToBack:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; @@ -96,9 +93,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinStateSorted.cxx b/panda/src/cull/cullBinStateSorted.cxx index 04890af48c..2bd71094bd 100644 --- a/panda/src/cull/cullBinStateSorted.cxx +++ b/panda/src/cull/cullBinStateSorted.cxx @@ -38,7 +38,7 @@ CullBinStateSorted:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinStateSorted:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinStateSorted(name, gsg, draw_region_pcollector); } @@ -70,9 +70,6 @@ void CullBinStateSorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; @@ -81,9 +78,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinUnsorted.cxx b/panda/src/cull/cullBinUnsorted.cxx index 4ef8c35ae6..0f37ae97b0 100644 --- a/panda/src/cull/cullBinUnsorted.cxx +++ b/panda/src/cull/cullBinUnsorted.cxx @@ -35,7 +35,7 @@ CullBinUnsorted:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinUnsorted:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinUnsorted(name, gsg, draw_region_pcollector); } @@ -55,9 +55,6 @@ void CullBinUnsorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi); @@ -66,9 +63,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index 4f331c7bae..59e57f4179 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -23,7 +23,7 @@ TypeHandle AnalogNode::_type_handle; * */ AnalogNode:: -AnalogNode(ClientBase *client, const string &device_name) : +AnalogNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _xy_output = define_output("xy", EventStoreVec2::get_class_type()); @@ -63,7 +63,7 @@ AnalogNode:: * */ void AnalogNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_analog != nullptr) { diff --git a/panda/src/device/buttonNode.cxx b/panda/src/device/buttonNode.cxx index e2bb18eeee..67803cf658 100644 --- a/panda/src/device/buttonNode.cxx +++ b/panda/src/device/buttonNode.cxx @@ -23,7 +23,7 @@ TypeHandle ButtonNode::_type_handle; * */ ButtonNode:: -ButtonNode(ClientBase *client, const string &device_name) : +ButtonNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); @@ -63,7 +63,7 @@ ButtonNode:: * */ void ButtonNode:: -output(ostream &out) const { +output(std::ostream &out) const { DataNode::output(out); if (_button != nullptr) { @@ -79,7 +79,7 @@ output(ostream &out) const { * */ void ButtonNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_button != nullptr) { diff --git a/panda/src/device/clientAnalogDevice.cxx b/panda/src/device/clientAnalogDevice.cxx index 47ddde620b..eb9c72ee06 100644 --- a/panda/src/device/clientAnalogDevice.cxx +++ b/panda/src/device/clientAnalogDevice.cxx @@ -37,7 +37,7 @@ ensure_control_index(int index) { * */ void ClientAnalogDevice:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_device_name() << ":\n"; write_controls(out, indent_level + 2); } @@ -46,7 +46,7 @@ write(ostream &out, int indent_level) const { * Writes a multi-line description of the current analog control states. */ void ClientAnalogDevice:: -write_controls(ostream &out, int indent_level) const { +write_controls(std::ostream &out, int indent_level) const { bool any_controls = false; Controls::const_iterator ai; for (ai = _controls.begin(); ai != _controls.end(); ++ai) { diff --git a/panda/src/device/clientBase.cxx b/panda/src/device/clientBase.cxx index 2ad270b81b..b7c6c3347c 100644 --- a/panda/src/device/clientBase.cxx +++ b/panda/src/device/clientBase.cxx @@ -85,7 +85,7 @@ fork_asynchronous_thread(double poll_time) { if (device_cat.is_debug()) { device_cat.debug() << "fork_asynchronous_thread() - forking client thread" - << endl; + << std::endl; } return true; } @@ -113,7 +113,7 @@ fork_asynchronous_thread(double poll_time) { * NULL is returned. */ PT(ClientDevice) ClientBase:: -get_device(TypeHandle device_type, const string &device_name) { +get_device(TypeHandle device_type, const std::string &device_name) { DevicesByName &dbn = _devices[device_type]; DevicesByName::iterator dbni; @@ -143,7 +143,7 @@ get_device(TypeHandle device_type, const string &device_name) { * unknown (e.g. it was disconnected previously). */ bool ClientBase:: -disconnect_device(TypeHandle device_type, const string &device_name, +disconnect_device(TypeHandle device_type, const std::string &device_name, ClientDevice *device) { DevicesByName &dbn = _devices[device_type]; diff --git a/panda/src/device/clientButtonDevice.cxx b/panda/src/device/clientButtonDevice.cxx index 60952f6a2c..27451c2887 100644 --- a/panda/src/device/clientButtonDevice.cxx +++ b/panda/src/device/clientButtonDevice.cxx @@ -15,13 +15,15 @@ #include "indent.h" +using std::ostream; + TypeHandle ClientButtonDevice::_type_handle; /** * */ ClientButtonDevice:: -ClientButtonDevice(ClientBase *client, const string &device_name): +ClientButtonDevice(ClientBase *client, const std::string &device_name): ClientDevice(client, get_class_type(), device_name) { _button_events = new ButtonEventList(); diff --git a/panda/src/device/clientDevice.cxx b/panda/src/device/clientDevice.cxx index f6bca213e5..6da404eca4 100644 --- a/panda/src/device/clientDevice.cxx +++ b/panda/src/device/clientDevice.cxx @@ -23,7 +23,7 @@ TypeHandle ClientDevice::_type_handle; */ ClientDevice:: ClientDevice(ClientBase *client, TypeHandle device_type, - const string &device_name) : + const std::string &device_name) : _client(client), _device_type(device_type), _device_name(device_name) @@ -87,7 +87,7 @@ poll() { * */ void ClientDevice:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_device_name(); } @@ -95,6 +95,6 @@ output(ostream &out) const { * */ void ClientDevice:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/device/dialNode.cxx b/panda/src/device/dialNode.cxx index 86fa011908..04f46a7805 100644 --- a/panda/src/device/dialNode.cxx +++ b/panda/src/device/dialNode.cxx @@ -22,7 +22,7 @@ TypeHandle DialNode::_type_handle; * */ DialNode:: -DialNode(ClientBase *client, const string &device_name) : +DialNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { nassertv(client != nullptr); diff --git a/panda/src/device/mouseAndKeyboard.cxx b/panda/src/device/mouseAndKeyboard.cxx index 4a431c5e5e..4a8e599afe 100644 --- a/panda/src/device/mouseAndKeyboard.cxx +++ b/panda/src/device/mouseAndKeyboard.cxx @@ -24,7 +24,7 @@ TypeHandle MouseAndKeyboard::_type_handle; * */ MouseAndKeyboard:: -MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : +MouseAndKeyboard(GraphicsWindow *window, int device, const std::string &name) : DataNode(name), _window(window), _device(device) diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index cf4a8d0f01..0ec33af92f 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -21,7 +21,7 @@ TypeHandle TrackerNode::_type_handle; * */ TrackerNode:: -TrackerNode(ClientBase *client, const string &device_name) : +TrackerNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _transform_output = define_output("transform", TransformState::get_class_type()); diff --git a/panda/src/device/virtualMouse.cxx b/panda/src/device/virtualMouse.cxx index fc0782828b..cdbf5aa678 100644 --- a/panda/src/device/virtualMouse.cxx +++ b/panda/src/device/virtualMouse.cxx @@ -20,7 +20,7 @@ TypeHandle VirtualMouse::_type_handle; * */ VirtualMouse:: -VirtualMouse(const string &name) : +VirtualMouse(const std::string &name) : DataNode(name) { _pixel_xy_output = define_output("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/dgraph/dataNode.cxx b/panda/src/dgraph/dataNode.cxx index 564a19f45d..a67c0b0c0d 100644 --- a/panda/src/dgraph/dataNode.cxx +++ b/panda/src/dgraph/dataNode.cxx @@ -16,6 +16,8 @@ #include "config_dgraph.h" #include "dcast.h" +using std::string; + TypeHandle DataNode::_type_handle; /** @@ -100,7 +102,7 @@ transmit_data(DataGraphTraverser *trav, * might expect to receive. */ void DataNode:: -write_inputs(ostream &out) const { +write_inputs(std::ostream &out) const { Wires::const_iterator wi; for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) { const string &name = (*wi).first; @@ -114,7 +116,7 @@ write_inputs(ostream &out) const { * might generate. */ void DataNode:: -write_outputs(ostream &out) const { +write_outputs(std::ostream &out) const { Wires::const_iterator wi; for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) { const string &name = (*wi).first; @@ -128,7 +130,7 @@ write_outputs(ostream &out) const { * showing between this DataNode and its parent(s). */ void DataNode:: -write_connections(ostream &out) const { +write_connections(std::ostream &out) const { DataConnections::const_iterator ci; for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) { const DataConnection &connect = (*ci); diff --git a/panda/src/display/callbackGraphicsWindow.cxx b/panda/src/display/callbackGraphicsWindow.cxx index 7774b149c2..ebe2442d17 100644 --- a/panda/src/display/callbackGraphicsWindow.cxx +++ b/panda/src/display/callbackGraphicsWindow.cxx @@ -24,7 +24,7 @@ TypeHandle CallbackGraphicsWindow::RenderCallbackData::_type_handle; */ CallbackGraphicsWindow:: CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -65,7 +65,7 @@ get_input_device(int device) { * Returns the index of the new device. */ int CallbackGraphicsWindow:: -create_input_device(const string &name) { +create_input_device(const std::string &name) { GraphicsWindowInputDevice device = GraphicsWindowInputDevice::pointer_and_keyboard(this, name); return add_input_device(device); diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index df1cec1420..337da59699 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -46,7 +46,7 @@ operator != (const DisplayMode &other) const { * */ void DisplayMode:: -output(ostream &out) const { +output(std::ostream &out) const { out << width << 'x' << height; if (bits_per_pixel > 0) { out << ' ' << bits_per_pixel << "bpp"; @@ -489,7 +489,7 @@ get_driver_date_year() { /** * */ -const string &DisplayInformation:: +const std::string &DisplayInformation:: get_cpu_vendor_string() const { return _cpu_vendor_string; } @@ -497,7 +497,7 @@ get_cpu_vendor_string() const { /** * */ -const string &DisplayInformation:: +const std::string &DisplayInformation:: get_cpu_brand_string() const { return _cpu_brand_string; } diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index b1d99df839..e1765861e1 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -23,6 +23,8 @@ #include +using std::string; + TypeHandle DisplayRegion::_type_handle; TypeHandle DisplayRegionPipelineReader::_type_handle; @@ -339,7 +341,7 @@ set_target_tex_page(int page) { * */ void DisplayRegion:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); out << "DisplayRegion(" << cdata->_regions[0]._dimensions << ")=pixels(" << cdata->_regions[0]._pixels << ")"; @@ -363,7 +365,7 @@ make_screenshot_filename(const string &prefix) { static const int buffer_size = 1024; char buffer[buffer_size]; - ostringstream filename_strm; + std::ostringstream filename_strm; size_t i = 0; while (i < screenshot_filename.length()) { @@ -481,6 +483,14 @@ get_screenshot() { GraphicsStateGuardian *gsg = window->get_gsg(); nassertr(gsg != nullptr, nullptr); + // Are we on the draw thread? + if (gsg->get_threading_model().get_draw_stage() != current_thread->get_pipeline_stage()) { + // Ask the engine to do on the draw thread. + GraphicsEngine *engine = window->get_engine(); + return engine->do_get_screenshot(this, gsg); + } + + // We are on the draw thread. if (!window->begin_frame(GraphicsOutput::FM_refresh, current_thread)) { return nullptr; } @@ -668,7 +678,7 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { void DisplayRegion:: set_active_index(int index) { #ifdef DO_PSTATS - ostringstream strm; + std::ostringstream strm; strm << "dr_" << index; string name = strm.str(); diff --git a/panda/src/display/displayRegionCullCallbackData.cxx b/panda/src/display/displayRegionCullCallbackData.cxx index 39268fbabe..822ecdce7b 100644 --- a/panda/src/display/displayRegionCullCallbackData.cxx +++ b/panda/src/display/displayRegionCullCallbackData.cxx @@ -33,7 +33,7 @@ DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup * */ void DisplayRegionCullCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_cull_handler << ", " << (void *)_scene_setup << ")"; } diff --git a/panda/src/display/displayRegionDrawCallbackData.cxx b/panda/src/display/displayRegionDrawCallbackData.cxx index 194aa6bbef..b95a3086e2 100644 --- a/panda/src/display/displayRegionDrawCallbackData.cxx +++ b/panda/src/display/displayRegionDrawCallbackData.cxx @@ -37,7 +37,7 @@ DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup) * */ void DisplayRegionDrawCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_cull_result << ", " << (void *)_scene_setup << ")"; } diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 5b6453af24..756a98c0be 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -322,7 +322,7 @@ set_accum_bits(int n) { */ INLINE void FrameBufferProperties:: set_aux_rgba(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_rgba] = n; _specified |= (1 << FBP_aux_rgba); } @@ -332,7 +332,7 @@ set_aux_rgba(int n) { */ INLINE void FrameBufferProperties:: set_aux_hrgba(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_hrgba] = n; _specified |= (1 << FBP_aux_hrgba); } @@ -342,7 +342,7 @@ set_aux_hrgba(int n) { */ INLINE void FrameBufferProperties:: set_aux_float(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_float] = n; _specified |= (1 << FBP_aux_float); } diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 81d12a98ba..cb6d14da3f 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -213,7 +213,7 @@ add_properties(const FrameBufferProperties &other) { * Generates a string representation. */ void FrameBufferProperties:: -output(ostream &out) const { +output(std::ostream &out) const { if ((_flags & FBF_float_depth) != 0) { out << "float_depth "; } @@ -542,7 +542,7 @@ get_quality(const FrameBufferProperties &reqs) const { for (int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) { int extra = _property[prop] > reqs._property[prop]; if (extra > 0) { - extra = min(extra, 3); + extra = std::min(extra, 3); quality -= extra*50; } } @@ -601,7 +601,7 @@ get_quality(const FrameBufferProperties &reqs) const { * false. */ bool FrameBufferProperties:: -verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const { +verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const { if (get_force_hardware() < props.get_force_hardware()) { display_cat.error() diff --git a/panda/src/display/graphicsBuffer.cxx b/panda/src/display/graphicsBuffer.cxx index bb0b086309..6955305a96 100644 --- a/panda/src/display/graphicsBuffer.cxx +++ b/panda/src/display/graphicsBuffer.cxx @@ -21,7 +21,7 @@ TypeHandle GraphicsBuffer::_type_handle; */ GraphicsBuffer:: GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg, diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index b27eaa5c39..dd637d7a9a 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -57,6 +57,8 @@ #include #endif +using std::string; + PT(GraphicsEngine) GraphicsEngine::_global_ptr; PStatCollector GraphicsEngine::_wait_pcollector("Wait:Thread sync"); @@ -1247,6 +1249,43 @@ texture_uploaded(Texture *tex) { // Usually only called by DisplayRegion::do_cull. } +/** + * Called by DisplayRegion::do_get_screenshot + */ +PT(Texture) GraphicsEngine:: +do_get_screenshot(DisplayRegion *region, GraphicsStateGuardian *gsg) { + // A multi-threaded environment. We have to wait until the draw thread + // has finished its current task. + + ReMutexHolder holder(_lock); + + const std::string &draw_name = gsg->get_threading_model().get_draw_name(); + WindowRenderer *wr = get_window_renderer(draw_name, 0); + RenderThread *thread = (RenderThread *)wr; + MutexHolder cv_holder(thread->_cv_mutex); + + while (thread->_thread_state != TS_wait) { + thread->_cv_done.wait(); + } + + // Now that the draw thread is idle, signal it to do the extraction task. + thread->_region = region; + thread->_thread_state = TS_do_screenshot; + thread->_cv_start.notify(); + thread->_cv_mutex.release(); + thread->_cv_mutex.acquire(); + + //XXX is this necessary, or is acquiring the mutex enough? + while (thread->_thread_state != TS_wait) { + thread->_cv_done.wait(); + } + + PT(Texture) tex = std::move(thread->_texture); + thread->_region = nullptr; + thread->_texture = nullptr; + return tex; +} + /** * Fires off a cull traversal using the indicated camera. */ @@ -1511,7 +1550,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { key._lens_index = dr_reader.get_lens_index(); } - AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(move(key), nullptr)).first; + AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(std::move(key), nullptr)).first; if ((*aci).second == nullptr) { // We have not used this camera already in this thread. Perform // the cull operation. @@ -1537,7 +1576,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { } // Save the results for next frame. - dr->set_cull_result(move(cull_result), MOVE(scene_setup), current_thread); + dr->set_cull_result(std::move(cull_result), MOVE(scene_setup), current_thread); } } } @@ -2631,6 +2670,11 @@ thread_main() { _result = _gsg->extract_texture_data(_texture); break; + case TS_do_screenshot: + nassertd(_region != nullptr) break; + _texture = _region->get_screenshot(); + break; + case TS_terminate: do_pending(_engine, current_thread); do_close(_engine, current_thread); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 667490b3d3..3371f20b39 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -125,11 +125,13 @@ public: TS_do_windows, TS_do_compute, TS_do_extract, + TS_do_screenshot, TS_terminate, TS_done }; void texture_uploaded(Texture *tex); + PT(Texture) do_get_screenshot(DisplayRegion *region, GraphicsStateGuardian *gsg); public: static void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, @@ -304,8 +306,9 @@ private: // These are stored for extract_texture_data and dispatch_compute. GraphicsStateGuardian *_gsg; - Texture *_texture; + PT(Texture) _texture; const RenderState *_state; + DisplayRegion *_region; LVecBase3i _work_groups; bool _result; }; diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 1f3141e9fc..7c6cef51cb 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -34,6 +34,8 @@ #include "throw_event.h" #include "config_gobj.h" +using std::string; + TypeHandle GraphicsOutput::_type_handle; PStatCollector GraphicsOutput::_make_current_pcollector("Draw:Make current"); @@ -895,7 +897,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, return nullptr; } if (max_dimension > 0) { - size = min(max_dimension, size); + size = std::min(max_dimension, size); } } @@ -1629,8 +1631,8 @@ make_copy() const { /** * */ -ostream & -operator << (ostream &out, GraphicsOutput::FrameMode fm) { +std::ostream & +operator << (std::ostream &out, GraphicsOutput::FrameMode fm) { switch (fm) { case GraphicsOutput::FM_render: return out << "render"; diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index 62a8ec5ad0..937987f567 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -134,8 +134,8 @@ GraphicsPipe() : if (max_cpuid >= 1) { get_cpuid(0, info); - swap(info.ecx, info.edx); - _display_information->_cpu_vendor_string = string(info.str + 4, 12); + std::swap(info.ecx, info.edx); + _display_information->_cpu_vendor_string = std::string(info.str + 4, 12); get_cpuid(1, info); _display_information->_cpu_version_information = info.eax; @@ -260,7 +260,7 @@ close_gsg(GraphicsStateGuardian *gsg) { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) GraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index d2b145da39..9c4f52ff63 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -23,6 +23,8 @@ #include +using std::string; + GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = nullptr; /** @@ -121,7 +123,7 @@ print_pipe_types() const { load_default_module(); LightMutexHolder holder(_lock); - nout << "Known pipe types:" << endl; + nout << "Known pipe types:" << std::endl; PipeTypes::const_iterator pi; for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) { const PipeType &pipe_type = (*pi); @@ -406,11 +408,11 @@ load_named_module(const string &name) { // We have not yet loaded this module. Load it now. Filename dlname = Filename::dso_filename("lib" + name + ".so"); display_cat.info() - << "loading display module: " << dlname.to_os_specific() << endl; + << "loading display module: " << dlname.to_os_specific() << std::endl; void *handle = load_dso(get_plugin_path().get_value(), dlname); if (handle == nullptr) { display_cat.warning() - << "Unable to load: " << load_dso_error() << endl; + << "Unable to load: " << load_dso_error() << std::endl; return TypeHandle::none(); } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index d0353717c9..1050f8372f 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -63,6 +63,8 @@ #include #include +using std::string; + PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Buffer switch:Vertex"); PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Buffer switch:Index"); PStatCollector GraphicsStateGuardian::_shader_buffer_switch_pcollector("Buffer switch:Shader"); @@ -761,7 +763,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { // multiple times during a frame. Also, this might well be the only GSG // in the world anyway. int mi = state->_last_mi; - if (mi >= 0 && mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { + if (mi >= 0 && (size_t)mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { PT(GeomMunger) munger = mungers.get_data(mi); if (munger->is_registered()) { return munger; @@ -2194,7 +2196,7 @@ flush_timer_queries() { if (_last_num_queried > 0) { // We know how many queries were available last frame, and this usually // stays fairly constant, so use this as a starting point. - int i = min(_last_num_queried, count) - 1; + int i = std::min(_last_num_queried, count) - 1; if (_pending_timer_queries[i]->is_answer_ready()) { first = count; @@ -2763,7 +2765,7 @@ do_issue_light() { // LightAttrib guarantees that the on lights are sorted, and that // non-ambient lights come before ambient lights. any_on_lights = target_light->has_any_on_light(); - size_t filtered_lights = min((size_t)_max_lights, target_light->get_num_non_ambient_lights()); + size_t filtered_lights = std::min((size_t)_max_lights, target_light->get_num_non_ambient_lights()); for (size_t li = 0; li < filtered_lights; ++li) { NodePath light = target_light->get_on_light(li); nassertv(!light.is_empty()); @@ -3241,7 +3243,7 @@ async_reload_texture(TextureContext *tc) { ((TextureReloadRequest *)task)->get_texture() == tc->get_texture()) { // This texture is already queued to be reloaded. Don't queue it again, // just make sure the priority is updated, and return. - task->set_priority(max(task->get_priority(), priority)); + task->set_priority(std::max(task->get_priority(), priority)); return (AsyncFuture *)task; } } @@ -3498,8 +3500,8 @@ get_driver_shader_version_minor() { return -1; } -ostream & -operator << (ostream &out, GraphicsStateGuardian::ShaderModel sm) { +std::ostream & +operator << (std::ostream &out, GraphicsStateGuardian::ShaderModel sm) { static const char *sm_strings[] = {"none", "1.1", "2.0", "2.x", "3.0", "4.0", "5.0", "5.1"}; nassertr(sm >= 0 && sm <= GraphicsStateGuardian::SM_51, out); out << sm_strings[sm]; diff --git a/panda/src/display/graphicsThreadingModel.cxx b/panda/src/display/graphicsThreadingModel.cxx index 113352ecba..22357206da 100644 --- a/panda/src/display/graphicsThreadingModel.cxx +++ b/panda/src/display/graphicsThreadingModel.cxx @@ -13,6 +13,8 @@ #include "graphicsThreadingModel.h" +using std::string; + /** * The threading model accepts a string representing the names of the two * threads that will process cull and draw for the given window, separated by diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index c3dadfa08c..8d618f3d9b 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -21,6 +21,8 @@ #include "throw_event.h" #include "string_utils.h" +using std::string; + TypeHandle GraphicsWindow::_type_handle; /** diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index e41dad65ba..c9c9900d3e 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -93,7 +93,7 @@ PUBLISHED: void enable_pointer_mode(int device, double speed); void disable_pointer_mode(int device); - MouseData get_pointer(int device) const; + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual void close_ime(); diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index f2af1e9df1..377f3986e4 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -23,6 +23,8 @@ #include "vector_src.cxx" +using std::string; + /** * Defines a new InputDevice for the window. Most windows will have exactly * one InputDevice: a keyboard/mouse pair. Some may also add joystick data, @@ -281,7 +283,7 @@ keystroke(int keycode, double time) { * especially Chinese/Japanese/Korean. */ void GraphicsWindowInputDevice:: -candidate(const wstring &candidate_string, size_t highlight_start, +candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(candidate_string, diff --git a/panda/src/display/graphicsWindowProcCallbackData.cxx b/panda/src/display/graphicsWindowProcCallbackData.cxx index 8bf1da03af..82e57ef382 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.cxx +++ b/panda/src/display/graphicsWindowProcCallbackData.cxx @@ -20,7 +20,7 @@ TypeHandle GraphicsWindowProcCallbackData::_type_handle; * */ void GraphicsWindowProcCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef WIN32 out << get_type() << "(" << (void*)_graphicsWindow << ", " << _hwnd << ", " << _msg << ", " << _wparam << ", " << _lparam << ")"; diff --git a/panda/src/display/nativeWindowHandle.cxx b/panda/src/display/nativeWindowHandle.cxx index 7616471172..2ae1973a6f 100644 --- a/panda/src/display/nativeWindowHandle.cxx +++ b/panda/src/display/nativeWindowHandle.cxx @@ -13,6 +13,8 @@ #include "nativeWindowHandle.h" +using std::ostream; + TypeHandle NativeWindowHandle::_type_handle; TypeHandle NativeWindowHandle::IntHandle::_type_handle; TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle; diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index c03d799f4c..1b23fdb653 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -21,7 +21,7 @@ TypeHandle ParasiteBuffer::_type_handle; * created instead via the GraphicsEngine::make_parasite() function. */ ParasiteBuffer:: -ParasiteBuffer(GraphicsOutput *host, const string &name, +ParasiteBuffer(GraphicsOutput *host, const std::string &name, int x_size, int y_size, int flags) : GraphicsOutput(host->get_engine(), host->get_pipe(), name, host->get_fb_properties(), @@ -95,7 +95,7 @@ set_size_and_recalc(int x, int y) { y = Texture::down_to_power_2(y); } if (_creation_flags & GraphicsPipe::BF_size_square) { - x = y = min(x, y); + x = y = std::min(x, y); } } @@ -180,8 +180,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { } else { if (_host->get_x_size() < get_x_size() || _host->get_y_size() < get_y_size()) { - set_size_and_recalc(min(get_x_size(), _host->get_x_size()), - min(get_y_size(), _host->get_y_size())); + set_size_and_recalc(std::min(get_x_size(), _host->get_x_size()), + std::min(get_y_size(), _host->get_y_size())); } } diff --git a/panda/src/display/stereoDisplayRegion.cxx b/panda/src/display/stereoDisplayRegion.cxx index 3b3a7cf9f8..5151920cab 100644 --- a/panda/src/display/stereoDisplayRegion.cxx +++ b/panda/src/display/stereoDisplayRegion.cxx @@ -262,7 +262,7 @@ set_target_tex_page(int page) { * */ void StereoDisplayRegion:: -output(ostream &out) const { +output(std::ostream &out) const { out << "StereoDisplayRegion(" << *_left_eye << ")"; } diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index 261c7f161a..fe4b2eff5d 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -19,6 +19,8 @@ #include "config_display.h" #include "nativeWindowHandle.h" +using std::string; + TypeHandle SubprocessWindow::_type_handle; /** diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index f2f7eea2cb..168e7f0758 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -19,6 +19,9 @@ #include +using std::cerr; +using std::string; + const char SubprocessWindowBuffer:: _magic_number[SubprocessWindowBuffer::magic_number_length] = "pNdaSWB"; diff --git a/panda/src/display/test_display.cxx b/panda/src/display/test_display.cxx deleted file mode 100644 index 6adfdaf269..0000000000 --- a/panda/src/display/test_display.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * 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." - * - * @file test_display.cxx - * @author shochet - * @date 2000-02-02 - */ - -#include "graphicsWindow.h" - -int main() { - return 0; -} diff --git a/panda/src/display/windowHandle.cxx b/panda/src/display/windowHandle.cxx index c114da8adf..0bfec17af7 100644 --- a/panda/src/display/windowHandle.cxx +++ b/panda/src/display/windowHandle.cxx @@ -52,7 +52,7 @@ get_int_handle() const { * */ void WindowHandle:: -output(ostream &out) const { +output(std::ostream &out) const { if (_os_handle == nullptr) { out << "(null)"; } else { @@ -117,6 +117,6 @@ get_int_handle() const { * */ void WindowHandle::OSHandle:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(no type)"; } diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index fec24e4faf..93cd0a7144 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -15,6 +15,10 @@ #include "config_display.h" #include "nativeWindowHandle.h" +using std::istream; +using std::ostream; +using std::string; + WindowProperties *WindowProperties::_default_properties = nullptr; /** diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index 551caac4d1..e0f86670a2 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -71,7 +71,7 @@ add_screen(ProjectionScreen *screen) { * The return value is the index number of the new screen. */ int NonlinearImager:: -add_screen(const NodePath &screen, const string &name) { +add_screen(const NodePath &screen, const std::string &name) { nassertr(!screen.is_empty() && screen.node()->is_of_type(ProjectionScreen::get_class_type()), -1); diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 0ac8fd9edf..e3bed91e27 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -30,7 +30,7 @@ TypeHandle ProjectionScreen::_type_handle; * */ ProjectionScreen:: -ProjectionScreen(const string &name) : PandaNode(name) +ProjectionScreen(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -151,7 +151,7 @@ set_projector(const NodePath &projector) { * fraction, and make the screen smaller by the inverse fraction. */ PT(GeomNode) ProjectionScreen:: -generate_screen(const NodePath &projector, const string &screen_name, +generate_screen(const NodePath &projector, const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio) { nassertr(!projector.is_empty() && @@ -237,7 +237,7 @@ generate_screen(const NodePath &projector, const string &screen_name, * generated child returned by generate_screen(). */ void ProjectionScreen:: -regenerate_screen(const NodePath &projector, const string &screen_name, +regenerate_screen(const NodePath &projector, const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio) { // First, remove all existing children. diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index 8c5c76f636..eb12b2bd8b 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -31,6 +31,8 @@ #include #endif +using std::string; + #ifdef _WIN32 static string format_error() { PVOID buffer; diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index f6ddd39713..f9580b8e91 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -131,7 +131,7 @@ read_chars(char *start, size_t length) { if (_chunk_remaining != 0) { // Extract some of the bytes remaining in the chunk. - length = min(length, _chunk_remaining); + length = std::min(length, _chunk_remaining); (*_source)->read(start, length); size_t read_count = (*_source)->gcount(); if (!_wanted_nonblocking) { @@ -153,7 +153,7 @@ read_chars(char *start, size_t length) { } // Read the next chunk. - string line; + std::string line; bool got_line = http_getline(line); while (got_line && line.empty()) { // Skip blank lines. There really should be exactly one blank line, but @@ -212,7 +212,7 @@ read_chars(char *start, size_t length) { * received or if the connection has been closed. */ bool ChunkedStreamBuf:: -http_getline(string &str) { +http_getline(std::string &str) { nassertr(!_source.is_null(), false); int ch = (*_source)->get(); while (!(*_source)->eof() && !(*_source)->fail()) { @@ -220,7 +220,7 @@ http_getline(string &str) { case '\n': // end-of-line character, we're done. str = _working_getline; - _working_getline = string(); + _working_getline = std::string(); { // Trim trailing whitespace. We're not required to do this per the // HTTP spec, but let's be generous. diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index b6bc542e60..272279047d 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -54,7 +54,7 @@ Decompressor:: */ int Decompressor:: initiate(const Filename &source_file) { - string extension = source_file.get_extension(); + std::string extension = source_file.get_extension(); if (extension == "pz" || extension == "gz") { Filename dest_file = source_file; dest_file = source_file.get_fullpath_wo_extension(); @@ -64,7 +64,7 @@ initiate(const Filename &source_file) { if (downloader_cat.is_debug()) { downloader_cat.debug() << "Unknown file extension for decompressor: ." - << extension << endl; + << extension << std::endl; } return EU_error_abort; } @@ -90,14 +90,14 @@ initiate(const Filename &source_file, const Filename &dest_file) { } // Determine source file length - source_pfstream->seekg(0, ios::end); + source_pfstream->seekg(0, std::ios::end); _source_length = source_pfstream->tellg(); if (_source_length == 0) { downloader_cat.warning() << "Zero length file: " << source_file << "\n"; return EU_error_file_empty; } - source_pfstream->seekg(0, ios::beg); + source_pfstream->seekg(0, std::ios::beg); // Open destination file Filename dest_filename(dest_file); @@ -201,8 +201,8 @@ decompress(const Filename &source_file) { */ bool Decompressor:: decompress(Ramfile &source_and_dest_file) { - istringstream source(source_and_dest_file._data); - ostringstream dest; + std::istringstream source(source_and_dest_file._data); + std::ostringstream dest; IDecompressStream decompress(&source, false); diff --git a/panda/src/downloader/documentSpec.cxx b/panda/src/downloader/documentSpec.cxx index b9ccc7097d..6ca2a9b260 100644 --- a/panda/src/downloader/documentSpec.cxx +++ b/panda/src/downloader/documentSpec.cxx @@ -51,7 +51,7 @@ compare_to(const DocumentSpec &other) const { * output() or write(). Returns true on success, false on failure. */ bool DocumentSpec:: -input(istream &in) { +input(std::istream &in) { // First, clear the spec. (*this) = DocumentSpec(); @@ -64,7 +64,7 @@ input(istream &in) { in >> ch; if (ch == '(') { // Scan the tag, up to but not including the closing paren. - string tag; + std::string tag; in >> ch; while (!in.fail() && !in.eof() && ch != ')') { tag += ch; @@ -80,7 +80,7 @@ input(istream &in) { // Scan the date, up to but not including the closing bracket. if (ch != ']') { - string date; + std::string date; while (!in.fail() && !in.eof() && ch != ']') { date += ch; ch = in.get(); @@ -99,7 +99,7 @@ input(istream &in) { * */ void DocumentSpec:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << get_url(); if (has_tag()) { out << " (" << get_tag() << ")"; @@ -114,7 +114,7 @@ output(ostream &out) const { * */ void DocumentSpec:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "[ " << get_url(); if (has_tag()) { diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index d532009e2b..0679614c8b 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -20,6 +20,13 @@ #include +using std::endl; +using std::istream; +using std::istringstream; +using std::move; +using std::ostream; +using std::string; + // Defines // Written at the top of the file so we know this is a downloadDb diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx index e090627362..ebeec3a97c 100644 --- a/panda/src/downloader/download_utils.cxx +++ b/panda/src/downloader/download_utils.cxx @@ -19,13 +19,15 @@ #include "config_downloader.h" #include +using std::ios; + unsigned long check_crc(Filename name) { pifstream read_stream; name.set_binary(); if (!name.open_read(read_stream)) { downloader_cat.error() - << "check_crc() - Failed to open input file: " << name << endl; + << "check_crc() - Failed to open input file: " << name << std::endl; return 0; } @@ -51,7 +53,7 @@ check_adler(Filename name) { name.set_binary(); if (!name.open_read(read_stream)) { downloader_cat.error() - << "check_adler() - Failed to open input file: " << name << endl; + << "check_adler() - Failed to open input file: " << name << std::endl; return 0; } diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 81568ae951..a78e9a340d 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -192,7 +192,7 @@ step() { static const size_t buffer_size = 1024; char buffer[buffer_size]; - size_t max_bytes = min(buffer_size, _subfile_length - _subfile_pos); + size_t max_bytes = std::min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); size_t count = _read->gcount(); while (count != 0) { @@ -217,7 +217,7 @@ step() { return EU_ok; } - max_bytes = min(buffer_size, _subfile_length - _subfile_pos); + max_bytes = std::min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); count = _read->gcount(); } diff --git a/panda/src/downloader/httpAuthorization.cxx b/panda/src/downloader/httpAuthorization.cxx index d067b96d97..081f16532d 100644 --- a/panda/src/downloader/httpAuthorization.cxx +++ b/panda/src/downloader/httpAuthorization.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_OPENSSL +using std::string; + static const char base64_table[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', diff --git a/panda/src/downloader/httpBasicAuthorization.cxx b/panda/src/downloader/httpBasicAuthorization.cxx index 8e86c25a94..a8abd67979 100644 --- a/panda/src/downloader/httpBasicAuthorization.cxx +++ b/panda/src/downloader/httpBasicAuthorization.cxx @@ -15,6 +15,8 @@ #ifdef HAVE_OPENSSL +using std::string; + const string HTTPBasicAuthorization::_mechanism = "basic"; /** diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 990c89d4e6..17c12d806a 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -35,6 +35,12 @@ #undef X509_NAME #endif // WIN32_VC +using std::istream; +using std::min; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle HTTPChannel::_type_handle; #define _NOTIFY_HTTP_CHANNEL_ID "[" << this << "] " @@ -250,7 +256,7 @@ will_close_connection() const { * requests which can change their minds midstream about how much data they're * sending you. */ -streamsize HTTPChannel:: +std::streamsize HTTPChannel:: get_file_size() const { if (_got_file_size) { return _file_size; @@ -2678,7 +2684,7 @@ open_download_file() { // Windows doesn't complain if you try to seek past the end of file--it // happily appends enough zero bytes to make the difference. Blecch. // That means we need to get the file size first to check it ourselves. - _download_to_stream->seekp(0, ios::end); + _download_to_stream->seekp(0, std::ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID @@ -2716,7 +2722,7 @@ open_download_file() { // Windows doesn't complain if you try to seek past the end of file--it // happily appends enough zero bytes to make the difference. Blecch. // That means we need to get the file size first to check it ourselves. - _download_to_stream->seekp(0, ios::end); + _download_to_stream->seekp(0, std::ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID @@ -3711,7 +3717,7 @@ reset_url(const URLSpec &old_url, const URLSpec &new_url) { */ void HTTPChannel:: store_header_field(const string &field_name, const string &field_value) { - pair insert_result = + std::pair insert_result = _headers.insert(Headers::value_type(field_name, field_value)); if (!insert_result.second) { diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index 7183b36ddf..1f80bf61fd 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -26,6 +26,8 @@ #include "openSSLWrapper.h" +using std::string; + PT(HTTPClient) HTTPClient::_global_ptr; /** @@ -78,7 +80,7 @@ tokenize(const string &str, vector_string &words, const string &delimiters) { static void ssl_msg_callback(int write_p, int version, int content_type, const void *, size_t len, SSL *, void *) { - ostringstream describe; + std::ostringstream describe; if (write_p) { describe << "sent "; } else { @@ -701,7 +703,7 @@ set_cookie(const HTTPCookie &cookie) { clear_cookie(cookie); } else { - pair result = _cookies.insert(cookie); + std::pair result = _cookies.insert(cookie); if (!result.second) { // We already had a cookie matching the supplied domainpathname, so // replace it. @@ -778,7 +780,7 @@ copy_cookies_from(const HTTPClient &other) { * host). */ void HTTPClient:: -write_cookies(ostream &out) const { +write_cookies(std::ostream &out) const { Cookies::const_iterator ci; for (ci = _cookies.begin(); ci != _cookies.end(); ++ci) { out << *ci << "\n"; @@ -791,7 +793,7 @@ write_cookies(ostream &out) const { * also removes expired cookies. */ void HTTPClient:: -send_cookies(ostream &out, const URLSpec &url) { +send_cookies(std::ostream &out, const URLSpec &url) { HTTPDate now = HTTPDate::now(); bool any_expired = false; bool first_cookie = true; diff --git a/panda/src/downloader/httpCookie.cxx b/panda/src/downloader/httpCookie.cxx index cbe095cd8d..d09f12b856 100644 --- a/panda/src/downloader/httpCookie.cxx +++ b/panda/src/downloader/httpCookie.cxx @@ -18,6 +18,8 @@ #include "ctype.h" #include "httpChannel.h" +using std::string; + /** * The sorting operator allows the cookies to be stored in a single * dictionary; it returns nonequal only if the cookies are different in name, @@ -139,7 +141,7 @@ matches_url(const URLSpec &url) const { * */ void HTTPCookie:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name << "=" << _value << "; path=" << _path << "; domain=" << _domain; diff --git a/panda/src/downloader/httpDate.cxx b/panda/src/downloader/httpDate.cxx index f8877a65c8..a651b50f89 100644 --- a/panda/src/downloader/httpDate.cxx +++ b/panda/src/downloader/httpDate.cxx @@ -15,6 +15,10 @@ #include +using std::setfill; +using std::setw; +using std::string; + static const int num_weekdays = 7; static const char * const weekdays[num_weekdays] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -245,7 +249,7 @@ get_string() const { struct tm *tp = gmtime(&_time); - ostringstream result; + std::ostringstream result; result << weekdays[tp->tm_wday] << ", " << setw(2) << setfill('0') << tp->tm_mday << " " @@ -263,7 +267,7 @@ get_string() const { * */ bool HTTPDate:: -input(istream &in) { +input(std::istream &in) { (*this) = HTTPDate(); // Extract out the quoted date string. @@ -294,7 +298,7 @@ input(istream &in) { * */ void HTTPDate:: -output(ostream &out) const { +output(std::ostream &out) const { // We put quotes around the string on output, so we can reliably detect the // end of the date string on input, above. out << '"' << get_string() << '"'; diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index 8bb2804bcf..1e59ea560c 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -21,6 +21,10 @@ #include "openssl/md5.h" #include +using std::ostream; +using std::ostringstream; +using std::string; + const string HTTPDigestAuthorization::_mechanism = "digest"; /** @@ -277,7 +281,7 @@ get_a2(HTTPEnum::Method method, const string &request_path, string HTTPDigestAuthorization:: get_hex_nonce_count() const { ostringstream strm; - strm << hex << setfill('0') << setw(8) << _nonce_count; + strm << std::hex << std::setfill('0') << std::setw(8) << _nonce_count; return strm.str(); } diff --git a/panda/src/downloader/httpEntityTag.cxx b/panda/src/downloader/httpEntityTag.cxx index 9c756024ee..1d4b79922a 100644 --- a/panda/src/downloader/httpEntityTag.cxx +++ b/panda/src/downloader/httpEntityTag.cxx @@ -13,6 +13,8 @@ #include "httpEntityTag.h" +using std::string; + /** * This constructor accepts a string as formatted from an HTTP server (e.g. @@ -52,7 +54,7 @@ HTTPEntityTag(const string &text) { */ string HTTPEntityTag:: get_string() const { - ostringstream result; + std::ostringstream result; if (_weak) { result << "W/"; } diff --git a/panda/src/downloader/httpEnum.cxx b/panda/src/downloader/httpEnum.cxx index 1ef09de254..ebe7914110 100644 --- a/panda/src/downloader/httpEnum.cxx +++ b/panda/src/downloader/httpEnum.cxx @@ -18,8 +18,8 @@ /** * */ -ostream & -operator << (ostream &out, HTTPEnum::Method method) { +std::ostream & +operator << (std::ostream &out, HTTPEnum::Method method) { switch (method) { case HTTPEnum::M_options: out << "OPTIONS"; diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index 4d98540423..852c252f32 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -140,7 +140,7 @@ read_chars(char *start, size_t length) { // content_length restriction. if (_bytes_remaining != 0) { - length = min(length, _bytes_remaining); + length = std::min(length, _bytes_remaining); (*_source)->read(start, length); read_count = (*_source)->gcount(); if (!_wanted_nonblocking) { diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 3b6b0a8b10..aa42d33f9e 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -24,6 +24,8 @@ // recursion. #include +using std::string; + /** * Closes or deletes the relevant pointers, if _owns_obj is true. */ @@ -107,7 +109,7 @@ MultiplexStreamBuf:: void MultiplexStreamBuf:: add_output(MultiplexStreamBuf::BufferType buffer_type, MultiplexStreamBuf::OutputType output_type, - ostream *out, FILE *fout, bool owns_obj) { + std::ostream *out, FILE *fout, bool owns_obj) { Output o; o._buffer_type = buffer_type; @@ -141,7 +143,7 @@ int MultiplexStreamBuf:: overflow(int ch) { _lock.lock(); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0) { write_chars(pbase(), n, false); @@ -166,7 +168,7 @@ int MultiplexStreamBuf:: sync() { _lock.lock(); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); // We pass in false for the flush value, even though our transmitting // ostream said to sync. This allows us to get better line buffering, since diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index 4d52a82cb5..eec65d1857 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -23,7 +23,7 @@ * */ SSReader:: -SSReader(istream *stream) : _istream(stream) { +SSReader(std::istream *stream) : _istream(stream) { _data_expected = 0; _tcp_header_size = tcp_header_size; @@ -84,13 +84,13 @@ do_receive_datagram(Datagram &dg) { static const size_t buffer_size = 1024; char buffer[buffer_size]; - size_t read_count = min(_data_expected - _data_so_far.size(), buffer_size); + size_t read_count = std::min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); size_t count = _istream->gcount(); while (count != 0) { _data_so_far.insert(_data_so_far.end(), buffer, buffer + count); - read_count = min(_data_expected - _data_so_far.size(), + read_count = std::min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); count = _istream->gcount(); @@ -126,7 +126,7 @@ do_receive_datagram(Datagram &dg) { void SSReader:: start_delay(double min_delay, double max_delay) { _min_delay = min_delay; - _delay_variance = max(max_delay - min_delay, 0.0); + _delay_variance = std::max(max_delay - min_delay, 0.0); _delay_active = true; } #endif // SIMULATE_NETWORK_DELAY @@ -194,7 +194,7 @@ get_delayed(Datagram &datagram) { * */ SSWriter:: -SSWriter(ostream *stream) : _ostream(stream) { +SSWriter(std::ostream *stream) : _ostream(stream) { _collect_tcp = collect_tcp; _collect_tcp_interval = collect_tcp_interval; _queued_data_start = 0.0; diff --git a/panda/src/downloader/stringStreamBuf.cxx b/panda/src/downloader/stringStreamBuf.cxx index 4067ca1acb..f9a6cc99f9 100644 --- a/panda/src/downloader/stringStreamBuf.cxx +++ b/panda/src/downloader/stringStreamBuf.cxx @@ -15,6 +15,10 @@ #include "pnotify.h" #include "config_express.h" +using std::ios; +using std::streamoff; +using std::streampos; + /** * */ @@ -82,7 +86,7 @@ read_chars(char *start, size_t length) { return 0; } - length = min(length, _data.size() - _gpos); + length = std::min(length, _data.size() - _gpos); memcpy(start, &_data[_gpos], length); _gpos += length; return length; @@ -102,7 +106,7 @@ write_chars(const char *start, size_t length) { if (_data.size() > _ppos) { // We are overwriting some data. size_t remaining_length = _data.size() - _ppos; - size_t overwrite_length = min(remaining_length, length); + size_t overwrite_length = std::min(remaining_length, length); memcpy(&_data[_ppos], start, overwrite_length); length -= overwrite_length; _ppos += overwrite_length; diff --git a/panda/src/downloader/urlSpec.cxx b/panda/src/downloader/urlSpec.cxx index 09769f3693..1925c6a775 100644 --- a/panda/src/downloader/urlSpec.cxx +++ b/panda/src/downloader/urlSpec.cxx @@ -17,6 +17,13 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::setfill; +using std::setw; +using std::string; + /** * */ @@ -711,7 +718,7 @@ output(ostream &out) const { string URLSpec:: quote(const string &source, const string &safe) { ostringstream result; - result << hex << setfill('0'); + result << std::hex << setfill('0'); for (string::const_iterator si = source.begin(); si != source.end(); ++si) { char ch = (*si); @@ -750,7 +757,7 @@ quote(const string &source, const string &safe) { string URLSpec:: quote_plus(const string &source, const string &safe) { ostringstream result; - result << hex << setfill('0'); + result << std::hex << setfill('0'); for (string::const_iterator si = source.begin(); si != source.end(); ++si) { char ch = (*si); diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index 27f33c644a..527e9c619b 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/panda/src/downloader/virtualFileHTTP.cxx @@ -18,6 +18,10 @@ #ifdef HAVE_OPENSSL +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileHTTP::_type_handle; @@ -205,7 +209,7 @@ was_read_successful() const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileHTTP:: +std::streamsize VirtualFileHTTP:: get_file_size(istream *stream) const { return _channel->get_file_size(); } @@ -214,7 +218,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileHTTP:: +std::streamsize VirtualFileHTTP:: get_file_size() const { return _channel->get_file_size(); } diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index c9cc4759a0..09625d53bc 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_OPENSSL +using std::string; + TypeHandle VirtualFileMountHTTP::_type_handle; @@ -166,7 +168,7 @@ make_virtual_file(const Filename &local_filename, new VirtualFileHTTP(this, local_filename, implicit_pz_file, open_flags); vfile->set_original_filename(original_filename); - return vfile.p(); + return vfile; } /** @@ -174,7 +176,7 @@ make_virtual_file(const Filename &local_filename, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountHTTP:: +std::istream *VirtualFileMountHTTP:: open_read_file(const Filename &) const { return nullptr; } @@ -184,8 +186,8 @@ open_read_file(const Filename &) const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountHTTP:: -get_file_size(const Filename &, istream *) const { +std::streamsize VirtualFileMountHTTP:: +get_file_size(const Filename &, std::istream *) const { return 0; } @@ -193,7 +195,7 @@ get_file_size(const Filename &, istream *) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountHTTP:: +std::streamsize VirtualFileMountHTTP:: get_file_size(const Filename &) const { return 0; } @@ -227,7 +229,7 @@ scan_directory(vector_string &, const Filename &) const { * */ void VirtualFileMountHTTP:: -output(ostream &out) const { +output(std::ostream &out) const { out << _root; } diff --git a/panda/src/downloadertools/apply_patch.cxx b/panda/src/downloadertools/apply_patch.cxx index 908f3c8189..502d67c89b 100644 --- a/panda/src/downloadertools/apply_patch.cxx +++ b/panda/src/downloadertools/apply_patch.cxx @@ -15,6 +15,9 @@ #include "patchfile.h" #include "filename.h" +using std::cerr; +using std::endl; + int main(int argc, char **argv) { preprocess_argv(argc, argv); diff --git a/panda/src/downloadertools/build_patch.cxx b/panda/src/downloadertools/build_patch.cxx index d14e27db9f..5c705bb38d 100644 --- a/panda/src/downloadertools/build_patch.cxx +++ b/panda/src/downloadertools/build_patch.cxx @@ -15,6 +15,9 @@ #include "patchfile.h" #include "filename.h" +using std::cerr; +using std::endl; + void usage() { cerr << "Usage: build_patch [opts] " << endl; diff --git a/panda/src/downloadertools/check_adler.cxx b/panda/src/downloadertools/check_adler.cxx index b53eb2839f..dbea94f8b7 100644 --- a/panda/src/downloadertools/check_adler.cxx +++ b/panda/src/downloadertools/check_adler.cxx @@ -14,13 +14,13 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "Usage: check_adler " << endl; + std::cerr << "Usage: check_adler " << std::endl; return 1; } Filename source_file = argv[1]; - cout << check_adler(source_file); + std::cout << check_adler(source_file); return 0; } diff --git a/panda/src/downloadertools/check_crc.cxx b/panda/src/downloadertools/check_crc.cxx index 9afadd4fb2..e98de20b57 100644 --- a/panda/src/downloadertools/check_crc.cxx +++ b/panda/src/downloadertools/check_crc.cxx @@ -14,13 +14,13 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "Usage: check_crc " << endl; + std::cerr << "Usage: check_crc " << std::endl; return 1; } Filename source_file = argv[1]; - cout << check_crc(source_file); + std::cout << check_crc(source_file); return 0; } diff --git a/panda/src/downloadertools/check_md5.cxx b/panda/src/downloadertools/check_md5.cxx index 5b386c7c1e..2cc3ce508e 100644 --- a/panda/src/downloadertools/check_md5.cxx +++ b/panda/src/downloadertools/check_md5.cxx @@ -15,6 +15,9 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cout; + bool output_decimal = false; bool suppress_filename = false; pofstream binary_output; @@ -45,7 +48,7 @@ help() { } void -output_hash(const string &filename, const HashVal &hash) { +output_hash(const std::string &filename, const HashVal &hash) { if (!suppress_filename && !filename.empty()) { cout << filename << " "; } @@ -69,7 +72,7 @@ main(int argc, char **argv) { const char *optstr = "i:db:qh"; bool got_input_string = false; - string input_string; + std::string input_string; Filename binary_output_filename; preprocess_argv(argc, argv); @@ -87,7 +90,7 @@ main(int argc, char **argv) { break; case 'b': - binary_output_filename = Filename::binary_filename(string(optarg)); + binary_output_filename = Filename::binary_filename(std::string(optarg)); break; case 'q': diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index 3b58ca0d23..bea4c5bedd 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -21,6 +21,11 @@ #include #include +using std::cerr; +using std::cout; +using std::endl; +using std::string; + bool create = false; // -c bool append = false; // -r @@ -634,7 +639,7 @@ list_files(const vector_string ¶ms) { // We happen to know that we can read the index without doing a seek. // So this is the only place where we accept a .pz/.gz compressed .mf. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *istr = vfs->open_read_file(multifile_name, true); + std::istream *istr = vfs->open_read_file(multifile_name, true); if (istr == nullptr) { cerr << "Unable to open " << multifile_name << " for reading.\n"; return false; diff --git a/panda/src/downloadertools/pdecrypt.cxx b/panda/src/downloadertools/pdecrypt.cxx index 9ce3445bf0..7763286b09 100644 --- a/panda/src/downloadertools/pdecrypt.cxx +++ b/panda/src/downloadertools/pdecrypt.cxx @@ -17,7 +17,10 @@ #include "panda_getopt.h" #include "preprocess_argv.h" -string password; +using std::cerr; +using std::endl; + +std::string password; bool got_password = false; void diff --git a/panda/src/downloadertools/pencrypt.cxx b/panda/src/downloadertools/pencrypt.cxx index 3d61651348..e40fbaba2c 100644 --- a/panda/src/downloadertools/pencrypt.cxx +++ b/panda/src/downloadertools/pencrypt.cxx @@ -17,9 +17,12 @@ #include "panda_getopt.h" #include "preprocess_argv.h" -string password; +using std::cerr; +using std::endl; + +std::string password; bool got_password = false; -string algorithm; +std::string algorithm; bool got_algorithm = false; int key_length = -1; bool got_key_length = false; diff --git a/panda/src/downloadertools/punzip.cxx b/panda/src/downloadertools/punzip.cxx index 5753f7b6ec..84a593c795 100644 --- a/panda/src/downloadertools/punzip.cxx +++ b/panda/src/downloadertools/punzip.cxx @@ -15,6 +15,11 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cin; +using std::cout; +using std::endl; + void usage() { cerr diff --git a/panda/src/downloadertools/pzip.cxx b/panda/src/downloadertools/pzip.cxx index 6364be0130..37c80e7f9f 100644 --- a/panda/src/downloadertools/pzip.cxx +++ b/panda/src/downloadertools/pzip.cxx @@ -15,6 +15,11 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cin; +using std::cout; +using std::endl; + void usage() { cerr diff --git a/panda/src/downloadertools/show_ddb.cxx b/panda/src/downloadertools/show_ddb.cxx index d19c3be9cd..1b1a4abce4 100644 --- a/panda/src/downloadertools/show_ddb.cxx +++ b/panda/src/downloadertools/show_ddb.cxx @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { if (argc != 3) { - cerr << "Usage: show_ddb server.ddb client.ddb\n"; + std::cerr << "Usage: show_ddb server.ddb client.ddb\n"; return 1; } @@ -26,7 +26,7 @@ main(int argc, char *argv[]) { Filename client_ddb = Filename::from_os_specific(argv[2]); DownloadDb db(server_ddb, client_ddb); - db.write(cout); + db.write(std::cout); return 0; } diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index 596802b871..cc972bf94b 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -17,14 +17,21 @@ INLINE DXGeomMunger9:: DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : StandardMunger(gsg, state, 1, NT_packed_dabc, C_color), - _texture(DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot()))), - _tex_gen(DCAST(TexGenAttrib, state->get_attrib(TexGenAttrib::get_class_slot()))) + _texture(nullptr), + _tex_gen(nullptr) { + const TextureAttrib *texture = nullptr; + const TexGenAttrib *tex_gen = nullptr; + state->get_attrib(texture); + state->get_attrib(tex_gen); + _texture = texture; + _tex_gen = tex_gen; + _filtered_texture = nullptr; _reffed_filtered_texture = false; - if (_texture != nullptr) { - _filtered_texture = _texture->filter_to_max(gsg->get_max_texture_stages()); - if (_filtered_texture != _texture) { + if (texture != nullptr) { + _filtered_texture = texture->filter_to_max(gsg->get_max_texture_stages()); + if (_filtered_texture != texture) { _filtered_texture->ref(); _reffed_filtered_texture = true; } diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index cce0f2e6f0..638b121f27 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -140,7 +140,7 @@ munge_format_impl(const GeomVertexFormat *orig, int tc_index = _filtered_texture->get_ff_tc_index(si); nassertr(tc_index < num_stages, orig); ff_tc_index[tc_index] = si; - max_tc_index = max(tc_index, max_tc_index); + max_tc_index = std::max(tc_index, max_tc_index); } // Now walk through the texture coordinates in the order they will appear @@ -243,7 +243,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { int tc_index = _filtered_texture->get_ff_tc_index(si); nassertr(tc_index < num_stages, orig); ff_tc_index[tc_index] = si; - max_tc_index = max(tc_index, max_tc_index); + max_tc_index = std::max(tc_index, max_tc_index); } // Now walk through the texture coordinates in the order they will appear @@ -300,8 +300,11 @@ compare_to_impl(const GeomMunger *other) const { if (_filtered_texture != om->_filtered_texture) { return _filtered_texture < om->_filtered_texture ? -1 : 1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } return StandardMunger::compare_to_impl(other); @@ -321,8 +324,11 @@ geom_compare_to_impl(const GeomMunger *other) const { if (_filtered_texture != om->_filtered_texture) { return _filtered_texture < om->_filtered_texture ? -1 : 1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } return StandardMunger::geom_compare_to_impl(other); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 389baa4dca..0e5687d490 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -77,6 +77,10 @@ #define SDK_VERSION(major,minor) tostring(major) << "." << tostring(minor) #define DIRECTX_SDK_VERSION SDK_VERSION (_DXSDK_PRODUCT_MAJOR, _DXSDK_PRODUCT_MINOR) << "." << SDK_VERSION (_DXSDK_BUILD_MAJOR, _DXSDK_BUILD_MINOR) +using std::endl; +using std::max; +using std::min; + TypeHandle DXGraphicsStateGuardian9::_type_handle; D3DMATRIX DXGraphicsStateGuardian9::_d3d_ident_mat; @@ -3312,7 +3316,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { static PStatCollector _draw_set_state_light_bind_directional_pcollector("Draw:Set State:Light:Bind:Directional"); // PStatTimer timer(_draw_set_state_light_bind_directional_pcollector); - pair lookup = _dlights.insert(DirectionalLights::value_type(light, D3DLIGHT9())); + std::pair lookup = _dlights.insert(DirectionalLights::value_type(light, D3DLIGHT9())); D3DLIGHT9 &fdata = (*lookup.first).second; if (lookup.second) { // Get the light in "world coordinates" (actually, view coordinates). @@ -4548,7 +4552,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, // release graphics buffer surfaces { wdxGraphicsBuffer9 *graphics_buffer; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; for (graphics_buffer_iterator = _graphics_buffer_list.begin( ); graphics_buffer_iterator != _graphics_buffer_list.end( ); graphics_buffer_iterator++) { @@ -5372,7 +5376,7 @@ atexit_function(void) { * Profile. */ bool DXGraphicsStateGuardian9:: -get_supports_cg_profile(const string &name) const { +get_supports_cg_profile(const std::string &name) const { #ifndef HAVE_CG return false; #else @@ -5400,7 +5404,7 @@ set_cg_device(LPDIRECT3DDEVICE9 cg_device) { #endif // HAVE_CG } -typedef string KEY; +typedef std::string KEY; typedef struct _KEY_ELEMENT { diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx index d0556d44c7..17d5b2f88e 100644 --- a/panda/src/dxgsg9/dxInput9.cxx +++ b/panda/src/dxgsg9/dxInput9.cxx @@ -17,6 +17,8 @@ #define AXIS_RESOLUTION 2000 // use this many levels of resolution by default (could be more if needed and device supported it) #define AXIS_RANGE_CENTERED // if defined, axis range is centered on 0, instead of starting on 0 +using std::endl; + BOOL CALLBACK EnumGameCtrlsCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { DI_DeviceInfos *pDevInfos = (DI_DeviceInfos *)pContext; diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index c3b1970bd9..6513ce8a89 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -207,7 +207,7 @@ issue_parameters(GSG *gsg, int altered) { // Calculate how many elements to transfer; no more than it expects, // but certainly no more than we have. - int input_size = min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), (int)ptr_data->_size); + int input_size = std::min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), (int)ptr_data->_size); CGparameter p = _cg_parameter_map[spec._id._seqno]; switch (ptr_data->_type) { @@ -313,7 +313,7 @@ issue_parameters(GSG *gsg, int altered) { } if (FAILED(hr)) { - string name = "unnamed"; + std::string name = "unnamed"; if (spec._arg[0]) { name = spec._arg[0]->get_basename(); diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 12ad6dfdfe..70c9db7803 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -24,6 +24,10 @@ #define DEBUG_SURFACES false #define DEBUG_TEXTURES true +using std::endl; +using std::max; +using std::min; + TypeHandle DXTextureContext9::_type_handle; static const DWORD g_LowByteMask = 0x000000FF; @@ -686,7 +690,7 @@ create_texture(DXScreenData &scrn) { << "NumColorChannels: " << num_color_channels << "; NumAlphaBits: " << num_alpha_bits << "; targetbpp: " <::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; graphics_buffer_iterator = _shared_depth_buffer_list.begin( ); while (graphics_buffer_iterator != _shared_depth_buffer_list.end( )) { diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 7ff6f28e5d..6c85c6652f 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -17,6 +17,8 @@ #include "wdxGraphicsBuffer9.h" #include "config_dxgsg9.h" +using std::endl; + TypeHandle wdxGraphicsPipe9::_type_handle; static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) { @@ -60,7 +62,7 @@ wdxGraphicsPipe9:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string wdxGraphicsPipe9:: +std::string wdxGraphicsPipe9:: get_interface_name() const { return "DirectX9"; } @@ -78,7 +80,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) wdxGraphicsPipe9:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -844,7 +846,7 @@ make_device(void *scrn) { _device = device; wdxdisplay9_cat.info() << "walla: device" << device << "\n"; - return device.p(); + return device; } pmap g_D3DFORMATmap; diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index d173881ac0..3136d75fd0 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -26,6 +26,8 @@ #include #include +using std::endl; + TypeHandle wdxGraphicsWindow9::_type_handle; /** @@ -33,7 +35,7 @@ TypeHandle wdxGraphicsWindow9::_type_handle; */ wdxGraphicsWindow9:: wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -880,10 +882,10 @@ choose_device() { << ", Driver: " << adapter_info.Driver << ", DriverVersion: (" << HIWORD(DrvVer->HighPart) << "." << LOWORD(DrvVer->HighPart) << "." << HIWORD(DrvVer->LowPart) << "." << LOWORD(DrvVer->LowPart) - << ")\nVendorID: 0x" << hex << adapter_info.VendorId + << ")\nVendorID: 0x" << std::hex << adapter_info.VendorId << " DeviceID: 0x" << adapter_info.DeviceId << " SubsysID: 0x" << adapter_info.SubSysId - << " Revision: 0x" << adapter_info.Revision << dec << endl; + << " Revision: 0x" << adapter_info.Revision << std::dec << endl; HMONITOR _monitor = dxpipe->__d3d9->GetAdapterMonitor(i); if (_monitor == nullptr) { diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 9c9a65533b..0441f1fdc5 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -54,7 +54,7 @@ BEGIN_PUBLISH // Returns the document, or NULL on error. //////////////////////////////////////////////////////////////////// TiXmlDocument * -read_xml_stream(istream &in) { +read_xml_stream(std::istream &in) { TiXmlDocument *doc = new TiXmlDocument; in >> *doc; if (in.fail() && !in.eof()) { @@ -72,7 +72,7 @@ BEGIN_PUBLISH // Description: Writes an XML document to the indicated stream. //////////////////////////////////////////////////////////////////// void -write_xml_stream(ostream &out, TiXmlDocument *doc) { +write_xml_stream(std::ostream &out, TiXmlDocument *doc) { out << *doc; } END_PUBLISH @@ -97,7 +97,7 @@ BEGIN_PUBLISH //////////////////////////////////////////////////////////////////// void print_xml_to_file(const Filename &filename, TiXmlNode *xnode) { - string os_name = filename.to_os_specific(); + std::string os_name = filename.to_os_specific(); #ifdef _WIN32 FILE *file; if (fopen_s(&file, os_name.c_str(), "w") != 0) { diff --git a/panda/src/egg/eggAnimPreload.cxx b/panda/src/egg/eggAnimPreload.cxx index ff05b12a3c..894df329ce 100644 --- a/panda/src/egg/eggAnimPreload.cxx +++ b/panda/src/egg/eggAnimPreload.cxx @@ -23,7 +23,7 @@ TypeHandle EggAnimPreload::_type_handle; * Egg format. */ void EggAnimPreload:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggAttributes.cxx b/panda/src/egg/eggAttributes.cxx index 4f27c5a8b3..26fe007524 100644 --- a/panda/src/egg/eggAttributes.cxx +++ b/panda/src/egg/eggAttributes.cxx @@ -62,7 +62,7 @@ EggAttributes:: * Writes the attributes to the indicated output stream in Egg format. */ void EggAttributes:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (has_normal()) { if (_dnormals.empty()) { indent(out, indent_level) diff --git a/panda/src/egg/eggBin.cxx b/panda/src/egg/eggBin.cxx index 789eaffb21..95a8bdc0a9 100644 --- a/panda/src/egg/eggBin.cxx +++ b/panda/src/egg/eggBin.cxx @@ -21,7 +21,7 @@ TypeHandle EggBin::_type_handle; * */ EggBin:: -EggBin(const string &name) : EggGroup(name) { +EggBin(const std::string &name) : EggGroup(name) { _bin_number = 0; } diff --git a/panda/src/egg/eggBinMaker.cxx b/panda/src/egg/eggBinMaker.cxx index 9200afde6b..4c0214eb92 100644 --- a/panda/src/egg/eggBinMaker.cxx +++ b/panda/src/egg/eggBinMaker.cxx @@ -112,9 +112,9 @@ collapse_group(const EggGroup *, int) { * May be overridden in derived classes to define a name for each new bin, * based on its bin number, and a sample child. */ -string EggBinMaker:: +std::string EggBinMaker:: get_bin_name(int, const EggNode *) { - return string(); + return std::string(); } /** @@ -162,7 +162,7 @@ collect_nodes(EggGroupNode *group) { // If this is the first time this group has been encountered, we need // to create a new entry in _group_nodes for it. - pair result; + std::pair result; result = _group_nodes.insert (GroupNodes::value_type (group, SortedNodes(EggBinMakerCompareNodes(this)))); @@ -286,7 +286,7 @@ setup_bin(EggBin *bin, const Nodes &nodes) { int bin_number = get_bin_number(nodes.front()); bin->set_bin_number(bin_number); - string bin_name = get_bin_name(bin_number, nodes.front()); + std::string bin_name = get_bin_name(bin_number, nodes.front()); if (!bin_name.empty()) { bin->set_name(bin_name); } diff --git a/panda/src/egg/eggComment.cxx b/panda/src/egg/eggComment.cxx index a55dd0787c..1379623c03 100644 --- a/panda/src/egg/eggComment.cxx +++ b/panda/src/egg/eggComment.cxx @@ -24,7 +24,7 @@ TypeHandle EggComment::_type_handle; * Writes the comment definition to the indicated output stream in Egg format. */ void EggComment:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); enquote_string(out, get_comment(), indent_level + 2) << "\n"; indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index 94c4b1d625..fe42870846 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -330,7 +330,7 @@ post_apply_flat_attribute() { int num_lead_vertices = get_num_lead_vertices(); for (int i = 0; i < (int)size(); i++) { EggVertex *vertex = get_vertex(i); - EggAttributes *component = get_component(max(i - num_lead_vertices, 0)); + EggAttributes *component = get_component(std::max(i - num_lead_vertices, 0)); // Use set_normal() instead of copy_normal(), to avoid getting the // morphs--we don't want them here, since we're just putting a bogus @@ -376,7 +376,7 @@ prepare_add_vertex(EggVertex *vertex, int i, int n) { int num_lead_vertices = get_num_lead_vertices(); if (n >= num_lead_vertices + 1) { - i = max(i - num_lead_vertices, 0); + i = std::max(i - num_lead_vertices, 0); nassertv(i <= (int)_components.size()); _components.insert(_components.begin() + i, new EggAttributes(*this)); } @@ -400,7 +400,7 @@ prepare_remove_vertex(EggVertex *vertex, int i, int n) { int num_lead_vertices = get_num_lead_vertices(); if (n >= num_lead_vertices + 1) { - i = max(i - num_lead_vertices, 0); + i = std::max(i - num_lead_vertices, 0); nassertv(i < (int)_components.size()); delete _components[i]; _components.erase(_components.begin() + i); @@ -428,10 +428,10 @@ do_triangulate(EggGroupNode *container) const { * indicated output stream in Egg format. */ void EggCompositePrimitive:: -write_body(ostream &out, int indent_level) const { +write_body(std::ostream &out, int indent_level) const { EggPrimitive::write_body(out, indent_level); - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { const EggAttributes *attrib = get_component(i); if (attrib->compare_to(*this) != 0 && (attrib->has_color() || attrib->has_normal())) { diff --git a/panda/src/egg/eggCoordinateSystem.cxx b/panda/src/egg/eggCoordinateSystem.cxx index 9ef0ce14f9..a646de21c7 100644 --- a/panda/src/egg/eggCoordinateSystem.cxx +++ b/panda/src/egg/eggCoordinateSystem.cxx @@ -23,7 +23,7 @@ TypeHandle EggCoordinateSystem::_type_handle; * Egg format. */ void EggCoordinateSystem:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (get_value() != CS_default && get_value() != CS_invalid) { indent(out, indent_level) diff --git a/panda/src/egg/eggCurve.cxx b/panda/src/egg/eggCurve.cxx index 932e4a6c9d..1c18a9ac5e 100644 --- a/panda/src/egg/eggCurve.cxx +++ b/panda/src/egg/eggCurve.cxx @@ -25,7 +25,7 @@ TypeHandle EggCurve::_type_handle; * CurveType value. */ EggCurve::CurveType EggCurve:: -string_curve_type(const string &string) { +string_curve_type(const std::string &string) { if (cmp_nocase_uh(string, "xyz") == 0) { return CT_xyz; } else if (cmp_nocase_uh(string, "hpr") == 0) { @@ -40,7 +40,7 @@ string_curve_type(const string &string) { /** * */ -ostream &operator << (ostream &out, EggCurve::CurveType t) { +std::ostream &operator << (std::ostream &out, EggCurve::CurveType t) { switch (t) { case EggCurve::CT_none: return out << "none"; diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 84fe2cde3c..75c9ad68d0 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -26,6 +26,9 @@ #include "lightMutexHolder.h" #include "zStream.h" +using std::istream; +using std::ostream; + extern int eggyyparse(); #include "parserDefs.h" #include "lexerDefs.h" @@ -59,7 +62,7 @@ resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) { * error is the output stream to which to write error messages. */ bool EggData:: -read(Filename filename, string display_name) { +read(Filename filename, std::string display_name) { filename.set_text(); set_egg_filename(filename); @@ -230,8 +233,8 @@ write_egg(ostream &out) { if (egg_precision > 0) { // Change the egg precision as requested. - streamsize orig_precision = out.precision(); - out.precision((streamsize)egg_precision); + std::streamsize orig_precision = out.precision(); + out.precision((std::streamsize)egg_precision); write(out, 0); out.precision(orig_precision); } else { diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index ad5d3a9917..0352de17e3 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -68,6 +68,12 @@ PUBLISHED: INLINE void set_egg_timestamp(time_t egg_timestamp); INLINE time_t get_egg_timestamp() const; + MAKE_PROPERTY(auto_resolve_externals, get_auto_resolve_externals, + set_auto_resolve_externals); + MAKE_PROPERTY(coordinate_system, get_coordinate_system, set_coordinate_system); + MAKE_PROPERTY(egg_filename, get_egg_filename, set_egg_filename); + MAKE_PROPERTY(egg_timestamp, get_egg_timestamp, set_egg_timestamp); + INLINE void recompute_vertex_normals(double threshold); INLINE void recompute_polygon_normals(); INLINE void strip_normals(); diff --git a/panda/src/egg/eggExternalReference.cxx b/panda/src/egg/eggExternalReference.cxx index d70a5003db..e124e05238 100644 --- a/panda/src/egg/eggExternalReference.cxx +++ b/panda/src/egg/eggExternalReference.cxx @@ -24,7 +24,7 @@ TypeHandle EggExternalReference::_type_handle; * */ EggExternalReference:: -EggExternalReference(const string &node_name, const string &filename) +EggExternalReference(const std::string &node_name, const std::string &filename) : EggFilenameNode(node_name, filename) { } @@ -49,7 +49,7 @@ operator = (const EggExternalReference ©) { * Writes the reference to the indicated output stream in Egg format. */ void EggExternalReference:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); enquote_string(out, get_filename(), indent_level + 2) << "\n"; indent(out, indent_level) << "}\n"; @@ -58,7 +58,7 @@ write(ostream &out, int indent_level) const { /** * Returns the default extension for this filename type. */ -string EggExternalReference:: +std::string EggExternalReference:: get_default_extension() const { - return string("egg"); + return std::string("egg"); } diff --git a/panda/src/egg/eggFilenameNode.cxx b/panda/src/egg/eggFilenameNode.cxx index b0a257c9a4..83e26aff5f 100644 --- a/panda/src/egg/eggFilenameNode.cxx +++ b/panda/src/egg/eggFilenameNode.cxx @@ -18,7 +18,7 @@ TypeHandle EggFilenameNode::_type_handle; /** * Returns the default extension for this filename type. */ -string EggFilenameNode:: +std::string EggFilenameNode:: get_default_extension() const { - return string(); + return std::string(); } diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index b67d079cce..a5ff1dee06 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -22,6 +22,9 @@ #include "lmatrix.h" #include "dcast.h" +using std::ostream; +using std::string; + TypeHandle EggGroup::_type_handle; diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index ef31289424..851eba7f48 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -39,6 +39,8 @@ #include +using std::string; + TypeHandle EggGroupNode::_type_handle; @@ -79,7 +81,7 @@ EggGroupNode:: * Egg format. */ void EggGroupNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { iterator i; // Since joints tend to reference vertex pools, which sometimes appear later @@ -738,7 +740,7 @@ triangulate_polygons(int flags) { } } - num_produced += max(0, (int)(_children.size() - children_copy.size())); + num_produced += std::max(0, (int)(_children.size() - children_copy.size())); return num_produced; } diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 346c2ed817..8bbf48aea0 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -109,6 +109,7 @@ PUBLISHED: EggNode *get_next_child(); EXTENSION(PyObject *get_children() const); + MAKE_PROPERTY(children, get_children); EggNode *add_child(EggNode *node); PT(EggNode) remove_child(EggNode *node); diff --git a/panda/src/egg/eggGroupUniquifier.cxx b/panda/src/egg/eggGroupUniquifier.cxx index f19b15e10d..b43529a092 100644 --- a/panda/src/egg/eggGroupUniquifier.cxx +++ b/panda/src/egg/eggGroupUniquifier.cxx @@ -18,6 +18,8 @@ #include +using std::string; + TypeHandle EggGroupUniquifier::_type_handle; @@ -95,7 +97,7 @@ filter_name(EggNode *node) { */ string EggGroupUniquifier:: generate_name(EggNode *node, const string &category, int index) { - ostringstream str; + std::ostringstream str; str << node->get_name() << "_group" << index; return str.str(); } diff --git a/panda/src/egg/eggLine.cxx b/panda/src/egg/eggLine.cxx index fca1efd7f1..6ba445a5c8 100644 --- a/panda/src/egg/eggLine.cxx +++ b/panda/src/egg/eggLine.cxx @@ -37,7 +37,7 @@ make_copy() const { * Writes the point to the indicated output stream in Egg format. */ void EggLine:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { diff --git a/panda/src/egg/eggMaterial.cxx b/panda/src/egg/eggMaterial.cxx index 8a77c9c0cc..3d543645a1 100644 --- a/panda/src/egg/eggMaterial.cxx +++ b/panda/src/egg/eggMaterial.cxx @@ -22,7 +22,7 @@ TypeHandle EggMaterial::_type_handle; * */ EggMaterial:: -EggMaterial(const string &mref_name) +EggMaterial(const std::string &mref_name) : EggNode(mref_name) { _flags = 0; @@ -54,7 +54,7 @@ EggMaterial(const EggMaterial ©) * format. */ void EggMaterial:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_base()) { diff --git a/panda/src/egg/eggMaterialCollection.cxx b/panda/src/egg/eggMaterialCollection.cxx index 3ccc9c330f..527bd7a0a6 100644 --- a/panda/src/egg/eggMaterialCollection.cxx +++ b/panda/src/egg/eggMaterialCollection.cxx @@ -221,7 +221,7 @@ collapse_equivalent_materials(int eq, EggMaterialCollection::MaterialReplacement ++oti) { EggMaterial *tex = (*oti); - pair result = collapser.insert(tex); + std::pair result = collapser.insert(tex); if (!result.second) { // This material is non-unique; another one was already there. EggMaterial *first = *(result.first); @@ -383,7 +383,7 @@ create_unique_material(const EggMaterial ©, int eq) { * matches. */ EggMaterial *EggMaterialCollection:: -find_mref(const string &mref_name) const { +find_mref(const std::string &mref_name) const { // This requires a complete linear traversal, not terribly efficient. OrderedMaterials::const_iterator oti; for (oti = _ordered_materials.begin(); diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index 89261d9855..da2334cfaa 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -113,7 +113,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { * */ void EggMesher:: -write(ostream &out) const { +write(std::ostream &out) const { /* out << _edges.size() << " edges:\n"; copy(_edges.begin(), _edges.end(), ostream_iterator(out, "\n")); @@ -704,8 +704,8 @@ make_quads() { // and pair them up right away. The others we'll get to later. This way, // the uncertain matches won't pollute the quad alignment for everyone else. - typedef pair Pair; - typedef pair Matched; + typedef std::pair Pair; + typedef std::pair Matched; typedef pvector SoulMates; SoulMates soulmates; diff --git a/panda/src/egg/eggMesherEdge.cxx b/panda/src/egg/eggMesherEdge.cxx index 1b24891b4e..f270b30de8 100644 --- a/panda/src/egg/eggMesherEdge.cxx +++ b/panda/src/egg/eggMesherEdge.cxx @@ -52,7 +52,7 @@ change_strip(EggMesherStrip *from, EggMesherStrip *to) { * Formats the edge for output in some sensible way. */ void EggMesherEdge:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Edge [" << _vi_a << " to " << _vi_b << "], " << _strips.size() << " strips:"; diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index 51396dd32e..09f91e0f0f 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -326,7 +326,7 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end, * */ void EggMesherFanMaker:: -output(ostream &out) const { +output(std::ostream &out) const { out << _vertex << ":["; if (!_edges.empty()) { Edges::const_iterator ei; diff --git a/panda/src/egg/eggMesherStrip.cxx b/panda/src/egg/eggMesherStrip.cxx index cec01dfe36..27260b96b0 100644 --- a/panda/src/egg/eggMesherStrip.cxx +++ b/panda/src/egg/eggMesherStrip.cxx @@ -849,7 +849,7 @@ count_neighbors() const { * Writes all the neighbor indexes to the ostream. */ void EggMesherStrip:: -output_neighbors(ostream &out) const { +output_neighbors(std::ostream &out) const { Edges::const_iterator ei; EggMesherEdge::Strips::const_iterator si; @@ -1350,7 +1350,7 @@ pick_sheet_mate(const EggMesherStrip &a_strip, * Formats the vertex for output in some sensible way. */ void EggMesherStrip:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_status) { case MS_alive: break; diff --git a/panda/src/egg/eggMiscFuncs.cxx b/panda/src/egg/eggMiscFuncs.cxx index 2181622df5..11d684a185 100644 --- a/panda/src/egg/eggMiscFuncs.cxx +++ b/panda/src/egg/eggMiscFuncs.cxx @@ -17,6 +17,9 @@ #include +using std::ostream; +using std::string; + /** * Writes the string to the indicated output stream. If the string contains diff --git a/panda/src/egg/eggNameUniquifier.cxx b/panda/src/egg/eggNameUniquifier.cxx index 34a7123d48..239a2b692b 100644 --- a/panda/src/egg/eggNameUniquifier.cxx +++ b/panda/src/egg/eggNameUniquifier.cxx @@ -19,6 +19,8 @@ #include "pnotify.h" +using std::string; + TypeHandle EggNameUniquifier::_type_handle; @@ -173,7 +175,7 @@ string EggNameUniquifier:: generate_name(EggNode *node, const string &category, int index) { string name = filter_name(node); - ostringstream str; + std::ostringstream str; if (name.empty()) { str << category << index; } else { diff --git a/panda/src/egg/eggNamedObject.cxx b/panda/src/egg/eggNamedObject.cxx index 663cfc3ed6..d397e26f91 100644 --- a/panda/src/egg/eggNamedObject.cxx +++ b/panda/src/egg/eggNamedObject.cxx @@ -22,7 +22,7 @@ TypeHandle EggNamedObject::_type_handle; * */ void EggNamedObject:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (has_name()) { out << " " << get_name(); @@ -36,7 +36,7 @@ output(ostream &out) const { * "". */ void EggNamedObject:: -write_header(ostream &out, int indent_level, const char *egg_keyword) const { +write_header(std::ostream &out, int indent_level, const char *egg_keyword) const { indent(out, indent_level) << egg_keyword << " "; if (has_name()) { diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 531f57f2c0..efca0825c7 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -34,9 +34,9 @@ int EggNode:: rename_node(vector_string strip_prefix) { int num_renamed = 0; for (unsigned int ni = 0; ni < strip_prefix.size(); ++ni) { - string axe_name = strip_prefix[ni]; + std::string axe_name = strip_prefix[ni]; if (this->get_name().substr(0, axe_name.size()) == axe_name) { - string new_name = this->get_name().substr(axe_name.size()); + std::string new_name = this->get_name().substr(axe_name.size()); // cout << "renaming " << this->get_name() << "->" << new_name << endl; this->set_name(new_name); num_renamed += 1; @@ -221,13 +221,13 @@ determine_decal() { * error or if the object does not support this functionality. */ bool EggNode:: -parse_egg(const string &egg_syntax) { +parse_egg(const std::string &egg_syntax) { EggGroupNode *group = get_parent(); if (is_of_type(EggGroupNode::get_class_type())) { DCAST_INTO_R(group, this, false); } - istringstream in(egg_syntax); + std::istringstream in(egg_syntax); LightMutexHolder holder(egg_lock); diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index c2d811859e..950ae5e257 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -44,6 +44,9 @@ PUBLISHED: INLINE bool is_under_transform() const; INLINE bool is_local_coord() const; + MAKE_PROPERTY(parent, get_parent); + MAKE_PROPERTY(depth, get_depth); + INLINE const LMatrix4d &get_vertex_frame() const; INLINE const LMatrix4d &get_node_frame() const; INLINE const LMatrix4d &get_vertex_frame_inv() const; @@ -51,12 +54,12 @@ PUBLISHED: INLINE const LMatrix4d &get_vertex_to_node() const; INLINE const LMatrix4d &get_node_to_vertex() const; - INLINE const LMatrix4d *get_vertex_frame_ptr()const; - INLINE const LMatrix4d *get_node_frame_ptr()const; - INLINE const LMatrix4d *get_vertex_frame_inv_ptr()const; - INLINE const LMatrix4d *get_node_frame_inv_ptr()const; - INLINE const LMatrix4d *get_vertex_to_node_ptr()const; - INLINE const LMatrix4d *get_node_to_vertex_ptr()const; + INLINE const LMatrix4d *get_vertex_frame_ptr() const; + INLINE const LMatrix4d *get_node_frame_ptr() const; + INLINE const LMatrix4d *get_vertex_frame_inv_ptr() const; + INLINE const LMatrix4d *get_node_frame_inv_ptr() const; + INLINE const LMatrix4d *get_vertex_to_node_ptr() const; + INLINE const LMatrix4d *get_node_to_vertex_ptr() const; INLINE void transform(const LMatrix4d &mat); INLINE void transform_vertices_only(const LMatrix4d &mat); diff --git a/panda/src/egg/eggNurbsCurve.cxx b/panda/src/egg/eggNurbsCurve.cxx index 79b1d5011b..f0f18a41b5 100644 --- a/panda/src/egg/eggNurbsCurve.cxx +++ b/panda/src/egg/eggNurbsCurve.cxx @@ -118,7 +118,7 @@ is_closed() const { * Writes the nurbsCurve to the indicated output stream in Egg format. */ void EggNurbsCurve:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (get_curve_type() != CT_none) { diff --git a/panda/src/egg/eggNurbsSurface.cxx b/panda/src/egg/eggNurbsSurface.cxx index c89ebfe157..8dc19be6fb 100644 --- a/panda/src/egg/eggNurbsSurface.cxx +++ b/panda/src/egg/eggNurbsSurface.cxx @@ -168,7 +168,7 @@ is_closed_v() const { * Writes the nurbsSurface to the indicated output stream in Egg format. */ void EggNurbsSurface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); Trims::const_iterator ti; diff --git a/panda/src/egg/eggPatch.cxx b/panda/src/egg/eggPatch.cxx index 0bed947622..f3bbd30444 100644 --- a/panda/src/egg/eggPatch.cxx +++ b/panda/src/egg/eggPatch.cxx @@ -33,7 +33,7 @@ make_copy() const { * Writes the patch to the indicated output stream in Egg format. */ void EggPatch:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggPoint.cxx b/panda/src/egg/eggPoint.cxx index a344ee59cd..1545b6649d 100644 --- a/panda/src/egg/eggPoint.cxx +++ b/panda/src/egg/eggPoint.cxx @@ -41,7 +41,7 @@ cleanup() { * Writes the point to the indicated output stream in Egg format. */ void EggPoint:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { diff --git a/panda/src/egg/eggPolygon.cxx b/panda/src/egg/eggPolygon.cxx index cb783925e1..5863d988e5 100644 --- a/panda/src/egg/eggPolygon.cxx +++ b/panda/src/egg/eggPolygon.cxx @@ -159,7 +159,7 @@ triangulate_in_place(bool convex_also) { * Writes the polygon to the indicated output stream in Egg format. */ void EggPolygon:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggPolysetMaker.cxx b/panda/src/egg/eggPolysetMaker.cxx index ddd2200df6..83d0de6d89 100644 --- a/panda/src/egg/eggPolysetMaker.cxx +++ b/panda/src/egg/eggPolysetMaker.cxx @@ -66,7 +66,7 @@ sorts_less(int bin_number, const EggNode *a, const EggNode *b) { } } if ((_properties & (P_texture)) != 0) { - int num_textures = min(pa->get_num_textures(), pb->get_num_textures()); + int num_textures = std::min(pa->get_num_textures(), pb->get_num_textures()); for (int i = 0; i < num_textures; i++) { EggTexture *a_texture = pa->get_texture(i); EggTexture *b_texture = pb->get_texture(i); diff --git a/panda/src/egg/eggPoolUniquifier.cxx b/panda/src/egg/eggPoolUniquifier.cxx index 859bd0aff0..86f8eea1e3 100644 --- a/panda/src/egg/eggPoolUniquifier.cxx +++ b/panda/src/egg/eggPoolUniquifier.cxx @@ -33,7 +33,7 @@ EggPoolUniquifier() { * Returns the category name into which the given node should be collected, or * the empty string if the node's name should be left alone. */ -string EggPoolUniquifier:: +std::string EggPoolUniquifier:: get_category(EggNode *node) { if (node->is_of_type(EggTexture::get_class_type())) { return "tex"; @@ -43,5 +43,5 @@ get_category(EggNode *node) { return "vpool"; } - return string(); + return std::string(); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index ee35080416..f4985dfc90 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -821,7 +821,7 @@ prepare_remove_vertex(EggVertex *vertex, int i, int n) { * indicated output stream in Egg format. */ void EggPrimitive:: -write_body(ostream &out, int indent_level) const { +write_body(std::ostream &out, int indent_level) const { test_vref_integrity(); EggAttributes::write(out, indent_level); @@ -977,7 +977,7 @@ r_apply_texmats(EggTextureCollection &textures) { EggTexture *unique = textures.create_unique_texture(new_texture, ~0); new_textures.push_back(unique); - string uv_name = unique->get_uv_name(); + std::string uv_name = unique->get_uv_name(); // Now apply the matrix to the vertex UV's. Create new vertices as // necessary. diff --git a/panda/src/egg/eggRenderMode.cxx b/panda/src/egg/eggRenderMode.cxx index 7c7e478a6d..5ac4b05844 100644 --- a/panda/src/egg/eggRenderMode.cxx +++ b/panda/src/egg/eggRenderMode.cxx @@ -16,6 +16,10 @@ #include "string_utils.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle EggRenderMode::_type_handle; /** diff --git a/panda/src/egg/eggSAnimData.cxx b/panda/src/egg/eggSAnimData.cxx index 27d3a88ed6..2dd63d24a1 100644 --- a/panda/src/egg/eggSAnimData.cxx +++ b/panda/src/egg/eggSAnimData.cxx @@ -48,7 +48,7 @@ optimize() { * Writes the data to the indicated output stream in Egg format. */ void EggSAnimData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (get_num_rows() <= 1) { // We get a lot of these little tiny tables. For brevity, we'll write // these all on one line, because we can. This just makes it easier for a diff --git a/panda/src/egg/eggSwitchCondition.cxx b/panda/src/egg/eggSwitchCondition.cxx index d461c406f7..1515563d50 100644 --- a/panda/src/egg/eggSwitchCondition.cxx +++ b/panda/src/egg/eggSwitchCondition.cxx @@ -45,7 +45,7 @@ make_copy() const { * */ void EggSwitchConditionDistance:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << " {\n"; indent(out, indent_level+2) << " { " << _switch_in << " " << _switch_out; diff --git a/panda/src/egg/eggTable.cxx b/panda/src/egg/eggTable.cxx index b8372e41af..234c40c5f8 100644 --- a/panda/src/egg/eggTable.cxx +++ b/panda/src/egg/eggTable.cxx @@ -41,7 +41,7 @@ has_transform() const { * Egg format. */ void EggTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); switch (get_table_type()) { @@ -69,7 +69,7 @@ write(ostream &out, int indent_level) const { * TableType value. */ EggTable::TableType EggTable:: -string_table_type(const string &string) { +string_table_type(const std::string &string) { if (cmp_nocase_uh(string, "table") == 0) { return TT_table; } else if (cmp_nocase_uh(string, "bundle") == 0) { @@ -137,7 +137,7 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, /** * */ -ostream &operator << (ostream &out, EggTable::TableType t) { +std::ostream &operator << (std::ostream &out, EggTable::TableType t) { switch (t) { case EggTable::TT_invalid: return out << "invalid table"; diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 85327cb915..eb2cfa7342 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -18,6 +18,9 @@ #include "indent.h" #include "string_utils.h" +using std::ostream; +using std::string; + TypeHandle EggTexture::_type_handle; diff --git a/panda/src/egg/eggTextureCollection.cxx b/panda/src/egg/eggTextureCollection.cxx index 38ee134048..0c1b46eea7 100644 --- a/panda/src/egg/eggTextureCollection.cxx +++ b/panda/src/egg/eggTextureCollection.cxx @@ -271,7 +271,7 @@ collapse_equivalent_textures(int eq, EggTextureCollection::TextureReplacement &r ++oti) { EggTexture *tex = (*oti); - pair result = collapser.insert(tex); + std::pair result = collapser.insert(tex); if (!result.second) { // This texture is non-unique; another one was already there. EggTexture *first = *(result.first); @@ -453,7 +453,7 @@ create_unique_texture(const EggTexture ©, int eq) { * matches. */ EggTexture *EggTextureCollection:: -find_tref(const string &tref_name) const { +find_tref(const std::string &tref_name) const { // This requires a complete linear traversal, not terribly efficient. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); diff --git a/panda/src/egg/eggTransform.cxx b/panda/src/egg/eggTransform.cxx index 67ce77e1bc..65ba63c3e7 100644 --- a/panda/src/egg/eggTransform.cxx +++ b/panda/src/egg/eggTransform.cxx @@ -186,7 +186,7 @@ add_uniform_scale(double scale) { * Writes the transform to the indicated stream in Egg format. */ void EggTransform:: -write(ostream &out, int indent_level, const string &label) const { +write(std::ostream &out, int indent_level, const std::string &label) const { indent(out, indent_level) << label << " {\n"; int num_components = get_num_components(); diff --git a/panda/src/egg/eggTriangleFan.cxx b/panda/src/egg/eggTriangleFan.cxx index 6ad3b4f5ae..5287d1c8e9 100644 --- a/panda/src/egg/eggTriangleFan.cxx +++ b/panda/src/egg/eggTriangleFan.cxx @@ -38,7 +38,7 @@ make_copy() const { * Writes the triangle fan to the indicated output stream in Egg format. */ void EggTriangleFan:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggTriangleStrip.cxx b/panda/src/egg/eggTriangleStrip.cxx index 5882471c9e..a0aa83b144 100644 --- a/panda/src/egg/eggTriangleStrip.cxx +++ b/panda/src/egg/eggTriangleStrip.cxx @@ -38,7 +38,7 @@ make_copy() const { * Writes the triangle strip to the indicated output stream in Egg format. */ void EggTriangleStrip:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 5272a9f034..cebf9608e7 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -26,6 +26,9 @@ #include #include +using std::ostream; +using std::string; + TypeHandle EggVertex::_type_handle; diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index 6b12ee538b..b421c527f6 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexAux::_type_handle; * */ EggVertexAux:: -EggVertexAux(const string &name, const LVecBase4d &aux) : +EggVertexAux(const std::string &name, const LVecBase4d &aux) : EggNamedObject(name), _aux(aux) { @@ -72,8 +72,8 @@ make_average(const EggVertexAux *first, const EggVertexAux *second) { * */ void EggVertexAux:: -write(ostream &out, int indent_level) const { - string inline_name = get_name(); +write(std::ostream &out, int indent_level) const { + std::string inline_name = get_name(); if (!inline_name.empty()) { inline_name += ' '; } diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index e3b3cad248..8fa3b5e637 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -20,6 +20,8 @@ #include +using std::string; + TypeHandle EggVertexPool::_type_handle; /** @@ -176,7 +178,7 @@ get_num_dimensions() const { IndexVertices::const_iterator ivi; for (ivi = _index_vertices.begin(); ivi != _index_vertices.end(); ++ivi) { EggVertex *vertex = (*ivi).second; - num_dimensions = max(num_dimensions, vertex->get_num_dimensions()); + num_dimensions = std::max(num_dimensions, vertex->get_num_dimensions()); } return num_dimensions; @@ -438,7 +440,7 @@ add_vertex(EggVertex *vertex, int index) { !vertex->is_forward_reference()) { (*orig_vertex) = (*vertex); orig_vertex->_forward_reference = false; - _highest_index = max(_highest_index, index); + _highest_index = std::max(_highest_index, index); return orig_vertex; } @@ -450,7 +452,7 @@ add_vertex(EggVertex *vertex, int index) { _index_vertices[index] = vertex; if (!vertex->is_forward_reference()) { - _highest_index = max(_highest_index, index); + _highest_index = std::max(_highest_index, index); } vertex->_pool = this; @@ -761,7 +763,7 @@ sort_by_external_index() { * Writes the vertex pool to the indicated output stream in Egg format. */ void EggVertexPool:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); iterator i; diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index 4ba501d4c3..49a3c39ace 100644 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexUV::_type_handle; * */ EggVertexUV:: -EggVertexUV(const string &name, const LTexCoordd &uv) : +EggVertexUV(const std::string &name, const LTexCoordd &uv) : EggNamedObject(name), _flags(0), _uvw(uv[0], uv[1], 0.0) @@ -36,7 +36,7 @@ EggVertexUV(const string &name, const LTexCoordd &uv) : * */ EggVertexUV:: -EggVertexUV(const string &name, const LTexCoord3d &uvw) : +EggVertexUV(const std::string &name, const LTexCoord3d &uvw) : EggNamedObject(name), _flags(F_has_w), _uvw(uvw) @@ -124,8 +124,8 @@ transform(const LMatrix4d &mat) { * */ void EggVertexUV:: -write(ostream &out, int indent_level) const { - string inline_name = get_name(); +write(std::ostream &out, int indent_level) const { + std::string inline_name = get_name(); if (!inline_name.empty()) { inline_name += ' '; } diff --git a/panda/src/egg/eggXfmAnimData.cxx b/panda/src/egg/eggXfmAnimData.cxx index 62ed89f1c3..73a7128036 100644 --- a/panda/src/egg/eggXfmAnimData.cxx +++ b/panda/src/egg/eggXfmAnimData.cxx @@ -164,7 +164,7 @@ is_anim_matrix() const { * Writes the data to the indicated output stream in Egg format. */ void EggXfmAnimData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_fps()) { diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index c28d8c6c4e..43a784b33f 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -23,6 +23,8 @@ #include +using std::string; + TypeHandle EggXfmSAnim::_type_handle; const string EggXfmSAnim::_standard_order = "srpht"; @@ -138,7 +140,7 @@ is_anim_matrix() const { * Writes the data to the indicated output stream in Egg format. */ void EggXfmSAnim:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); write_header(out, indent_level, ""); @@ -271,7 +273,7 @@ get_num_rows() const { min_rows = sanim->get_num_rows(); } else { - min_rows = min(min_rows, sanim->get_num_rows()); + min_rows = std::min(min_rows, sanim->get_num_rows()); } } } diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index ef8160d2c2..9e412bce1f 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -963,6 +963,10 @@ char *eggyytext; #include +using std::istream; +using std::ostream; +using std::string; + extern "C" int eggyywrap(void); // declared below. static int yyinput(void); // declared by flex. @@ -1072,7 +1076,7 @@ eggyyerror(const string &msg) { } void -eggyyerror(ostringstream &strm) { +eggyyerror(std::ostringstream &strm) { string s = strm.str(); eggyyerror(s); } @@ -1098,8 +1102,8 @@ eggyywarning(const string &msg) { } void -eggyywarning(ostringstream &strm) { - string s = strm.str(); +eggyywarning(std::ostringstream &strm) { + std::string s = strm.str(); eggyywarning(s); } @@ -1117,7 +1121,7 @@ input_chars(char *buffer, int &result, int max_size) { // from the stream, copy it into the current_line array. This // is because the \n.* rule below, which fills current_line // normally, doesn't catch the first line. - int length = min(max_error_width, result); + int length = std::min(max_error_width, result); strncpy(current_line, buffer, length); current_line[length] = '\0'; line_number++; @@ -1141,7 +1145,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -1212,7 +1216,7 @@ eat_c_comment() { c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" << std::ends; diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 468a393418..e88e5a388f 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -18,6 +18,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + extern "C" int eggyywrap(void); // declared below. static int yyinput(void); // declared by flex. @@ -127,7 +131,7 @@ eggyyerror(const string &msg) { } void -eggyyerror(ostringstream &strm) { +eggyyerror(std::ostringstream &strm) { string s = strm.str(); eggyyerror(s); } @@ -153,7 +157,7 @@ eggyywarning(const string &msg) { } void -eggyywarning(ostringstream &strm) { +eggyywarning(std::ostringstream &strm) { string s = strm.str(); eggyywarning(s); } @@ -172,7 +176,7 @@ input_chars(char *buffer, int &result, int max_size) { // from the stream, copy it into the current_line array. This // is because the \n.* rule below, which fills current_line // normally, doesn't catch the first line. - int length = min(max_error_width, result); + int length = std::min(max_error_width, result); strncpy(current_line, buffer, length); current_line[length] = '\0'; line_number++; @@ -196,7 +200,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -267,7 +271,7 @@ eat_c_comment() { c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" << std::ends; diff --git a/panda/src/egg/parser.cxx.prebuilt b/panda/src/egg/parser.cxx.prebuilt index b25f0abf32..f9a81a30a5 100644 --- a/panda/src/egg/parser.cxx.prebuilt +++ b/panda/src/egg/parser.cxx.prebuilt @@ -129,6 +129,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + // We need a stack of EggObject pointers. Each time we encounter a // nested EggObject of some kind, we'll allocate a new one of these // and push it onto the stack. At any given time, the top of the diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 8bdd6ee39d..1ffaa3a078 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -57,6 +57,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + // We need a stack of EggObject pointers. Each time we encounter a // nested EggObject of some kind, we'll allocate a new one of these // and push it onto the stack. At any given time, the top of the diff --git a/panda/src/egg/test_egg.cxx b/panda/src/egg/test_egg.cxx index ae91d3548d..8023145331 100644 --- a/panda/src/egg/test_egg.cxx +++ b/panda/src/egg/test_egg.cxx @@ -28,7 +28,7 @@ main(int argc, char *argv[]) { if (data.read(egg_filename)) { data.load_externals(DSearchPath(Filename(""))); - data.write_egg(cout); + data.write_egg(std::cout); } else { nout << "Errors.\n"; } diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index b32f6d79a5..ea5ac4285f 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -25,6 +25,8 @@ #include "animChannelMatrixXfmTable.h" #include "animChannelScalarTable.h" +using std::min; + /** * */ @@ -212,7 +214,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { * structure. */ AnimChannelScalarTable *AnimBundleMaker:: -create_s_channel(EggSAnimData *egg_anim, const string &name, +create_s_channel(EggSAnimData *egg_anim, const std::string &name, AnimGroup *parent) { AnimChannelScalarTable *table = new AnimChannelScalarTable(parent, name); @@ -236,7 +238,7 @@ create_s_channel(EggSAnimData *egg_anim, const string &name, * structure, if possible. */ AnimChannelMatrixXfmTable *AnimBundleMaker:: -create_xfm_channel(EggNode *egg_node, const string &name, +create_xfm_channel(EggNode *egg_node, const std::string &name, AnimGroup *parent) { if (egg_node->is_of_type(EggXfmAnimData::get_class_type())) { EggXfmAnimData *egg_anim = DCAST(EggXfmAnimData, egg_node); @@ -260,7 +262,7 @@ create_xfm_channel(EggNode *egg_node, const string &name, * structure. */ AnimChannelMatrixXfmTable *AnimBundleMaker:: -create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, +create_xfm_channel(EggXfmSAnim *egg_anim, const std::string &name, AnimGroup *parent) { // Ensure that the anim table is optimal and that it is standard order. egg_anim->optimize_to_standard_order(); diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 11c3a4e9b4..f087ebf88e 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -34,6 +34,8 @@ #include "eggAnimPreload.h" #include "animPreloadTable.h" +using std::string; + diff --git a/panda/src/egg2pg/eggBinner.cxx b/panda/src/egg2pg/eggBinner.cxx index 66471661f8..9d24341f91 100644 --- a/panda/src/egg2pg/eggBinner.cxx +++ b/panda/src/egg2pg/eggBinner.cxx @@ -76,13 +76,13 @@ get_bin_number(const EggNode *node) { * May be overridden in derived classes to define a name for each new bin, * based on its bin number, and a sample child. */ -string EggBinner:: +std::string EggBinner:: get_bin_name(int bin_number, const EggNode *child) { if (bin_number == BN_polyset || bin_number == BN_patches) { return DCAST(EggPrimitive, child)->get_sort_name(); } - return string(); + return std::string(); } /** diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index ae2c30a8c3..e26a4120b9 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -100,6 +100,10 @@ #include #include +using std::max; +using std::min; +using std::string; + // This class is used in make_node(EggBin *) to sort LOD instances in order by // switching distance. class LODInstance { @@ -2584,7 +2588,7 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, // Insert the primitive into the set, but if we already have a primitive of // that type, reset the pointer to that one instead. PrimitiveUnifier pu(primitive); - pair result = + std::pair result = unique_primitives.insert(UniquePrimitives::value_type(pu, primitive)); if (result.second) { diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index 5612826ec0..4c5baf6e3a 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -59,7 +59,7 @@ fill_state(EggPrimitive *egg_prim) { bool has_depth_offset = false; int depth_offset = 0; bool has_bin = false; - string bin; + std::string bin; EggRenderMode *render_mode; render_mode = egg_prim->determine_alpha_mode(); @@ -151,7 +151,7 @@ fill_state(EggPrimitive *egg_prim) { // of textures that share this same set of UV's per each unique texture // matrix. Whew!) CPT(InternalName) uv_name; - if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != string("default")) { + if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != std::string("default")) { uv_name = InternalName::get_texcoord_name(egg_tex->get_uv_name()); } else { uv_name = InternalName::get_texcoord(); diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index af70617e36..fb6bb3a59b 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -75,6 +75,9 @@ #include "eggTable.h" #include "dcast.h" +using std::pair; +using std::string; + /** * */ @@ -191,7 +194,7 @@ convert_lod_node(LODNode *node, const WorkingNodePath &node_path, int num_children = node->get_num_children(); int num_switches = node->get_num_switches(); - num_children = min(num_children, num_switches); + num_children = std::min(num_children, num_switches); for (int i = 0; i < num_children; i++) { PandaNode *child = node->get_child(i); @@ -1148,7 +1151,7 @@ apply_state_properties(EggRenderMode *egg_render_mode, const RenderState *state) */ bool EggSaver:: apply_tags(EggGroup *egg_group, PandaNode *node) { - ostringstream strm; + std::ostringstream strm; char delimiter = '\n'; string delimiter_str(1, delimiter); node->list_tags(strm, delimiter_str); diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index bee738af4b..f6f3fa8f8b 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -94,7 +94,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, loader._data->set_egg_timestamp(vfile->get_timestamp()); bool okflag; - istream *istr = vfile->open_read_file(true); + std::istream *istr = vfile->open_read_file(true); if (istr == nullptr) { egg2pg_cat.error() << "Couldn't read " << egg_filename << "\n"; diff --git a/panda/src/egg2pg/loaderFileTypeEgg.cxx b/panda/src/egg2pg/loaderFileTypeEgg.cxx index a5bbd96210..281e2ca51f 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.cxx +++ b/panda/src/egg2pg/loaderFileTypeEgg.cxx @@ -29,7 +29,7 @@ LoaderFileTypeEgg() { /** * */ -string LoaderFileTypeEgg:: +std::string LoaderFileTypeEgg:: get_name() const { return "Egg"; } @@ -37,7 +37,7 @@ get_name() const { /** * */ -string LoaderFileTypeEgg:: +std::string LoaderFileTypeEgg:: get_extension() const { return "egg"; } diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index 9f9bf13770..f76b1b9d1f 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -63,7 +63,7 @@ init_libegldisplay() { /** * Returns the given EGL error as string. */ -const string get_egl_error_string(int error) { +const std::string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; case 0x3001: return "EGL_NOT_INITIALIZED"; break; diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index 07057818ab..a0cf71f1fa 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -26,7 +26,7 @@ TypeHandle eglGraphicsBuffer::_type_handle; */ eglGraphicsBuffer:: eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index 93ddb7f92c..17594f799e 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -25,7 +25,7 @@ TypeHandle eglGraphicsPipe::_type_handle; * */ eglGraphicsPipe:: -eglGraphicsPipe(const string &display) : x11GraphicsPipe(display) { +eglGraphicsPipe(const std::string &display) : x11GraphicsPipe(display) { _egl_display = eglGetDisplay((NativeDisplayType) _display); if (!eglInitialize(_egl_display, nullptr, nullptr)) { egldisplay_cat.error() @@ -59,7 +59,7 @@ eglGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string eglGraphicsPipe:: +std::string eglGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } @@ -77,7 +77,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) eglGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index ec34b460a3..5933416f5c 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -27,7 +27,7 @@ TypeHandle eglGraphicsPixmap::_type_handle; */ eglGraphicsPixmap:: eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 0d9a70e910..31c1069d46 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -258,8 +258,8 @@ reset() { // If "Mesa" is present, assume software. However, if "Mesa DRI" is found, // it's actually a Mesa-based OpenGL layer running over a hardware driver. if (_gl_renderer == "Software Rasterizer" || - (_gl_renderer.find("Mesa") != string::npos && - _gl_renderer.find("Mesa DRI") == string::npos)) { + (_gl_renderer.find("Mesa") != std::string::npos && + _gl_renderer.find("Mesa DRI") == std::string::npos)) { // It's Mesa, therefore probably a software context. _fbprops.set_force_software(1); _fbprops.set_force_hardware(0); diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index 094d4ae547..efb550c728 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -34,7 +34,7 @@ TypeHandle eglGraphicsWindow::_type_handle; */ eglGraphicsWindow:: eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -84,7 +84,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); diff --git a/panda/src/event/asyncFuture.cxx b/panda/src/event/asyncFuture.cxx index d97173d54d..16540954ed 100644 --- a/panda/src/event/asyncFuture.cxx +++ b/panda/src/event/asyncFuture.cxx @@ -55,7 +55,7 @@ cancel() { * */ void AsyncFuture:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); FutureState state = (FutureState)AtomicAdjust::get(_future_state); switch (state) { @@ -159,7 +159,7 @@ notify_done(bool clean_exit) { if (clean_exit && !_done_event.empty()) { PT_Event event = new Event(_done_event); event->add_parameter(EventParameter(this)); - throw_event(move(event)); + throw_event(std::move(event)); } } @@ -308,7 +308,7 @@ wake_task(AsyncTask *task) { */ AsyncGatheringFuture:: AsyncGatheringFuture(AsyncFuture::Futures futures) : - _futures(move(futures)), + _futures(std::move(futures)), _num_pending(0) { bool any_pending = false; diff --git a/panda/src/event/asyncFuture_ext.cxx b/panda/src/event/asyncFuture_ext.cxx index 3150c09d7d..00ee3516b1 100644 --- a/panda/src/event/asyncFuture_ext.cxx +++ b/panda/src/event/asyncFuture_ext.cxx @@ -306,7 +306,7 @@ gather(PyObject *args) { return Dtool_Raise_ArgTypeError(item, i, "gather", "coroutine, task or future"); } - AsyncFuture *future = AsyncFuture::gather(move(futures)); + AsyncFuture *future = AsyncFuture::gather(std::move(futures)); if (future != nullptr) { future->ref(); return DTool_CreatePyInstanceTyped((void *)future, Dtool_AsyncFuture, true, false, future->get_type_index()); diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index f5a796643c..806d8e87af 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -18,6 +18,8 @@ #include "throw_event.h" #include "eventParameter.h" +using std::string; + AtomicAdjust::Integer AsyncTask::_next_task_id; PStatCollector AsyncTask::_show_code_pcollector("App:Show code"); TypeHandle AsyncTask::_type_handle; @@ -187,7 +189,7 @@ set_name(const string &name) { size_t end = name.size(); size_t colon = name.find(':'); if (colon != string::npos) { - end = min(end, colon); + end = std::min(end, colon); } // If the name ends with a hyphen followed by a string of digits, we strip @@ -364,7 +366,7 @@ set_priority(int priority) { * */ void AsyncTask:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (has_name()) { out << " " << get_name(); @@ -427,7 +429,7 @@ unlock_and_do_task() { _manager->_lock.lock(); _dt = end - start; - _max_dt = max(_dt, _max_dt); + _max_dt = std::max(_dt, _max_dt); _total_dt += _dt; _chain->_time_in_frame += _dt; diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index eb00a5b08d..34e458691e 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -23,6 +23,11 @@ #include #include // For sprintf/snprintf +using std::max; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle AsyncTaskChain::_type_handle; PStatCollector AsyncTaskChain::_task_pcollector("Task"); diff --git a/panda/src/event/asyncTaskCollection.cxx b/panda/src/event/asyncTaskCollection.cxx index af5b1bc2f5..b6fd56fece 100644 --- a/panda/src/event/asyncTaskCollection.cxx +++ b/panda/src/event/asyncTaskCollection.cxx @@ -174,7 +174,7 @@ clear() { * if no task has that name. */ AsyncTask *AsyncTaskCollection:: -find_task(const string &name) const { +find_task(const std::string &name) const { size_t num_tasks = get_num_tasks(); for (size_t i = 0; i < num_tasks; ++i) { AsyncTask *task = get_task(i); @@ -246,7 +246,7 @@ size() const { * indicated output stream. */ void AsyncTaskCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_tasks() == 1) { out << "1 AsyncTask"; } else { @@ -259,7 +259,7 @@ output(ostream &out) const { * indicated output stream. */ void AsyncTaskCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < get_num_tasks(); i++) { indent(out, indent_level) << *get_task(i) << "\n"; } diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index a9bab44898..b80908ddc5 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -22,6 +22,8 @@ #include "config_event.h" #include +using std::string; + AsyncTaskManager *AsyncTaskManager::_global_ptr = nullptr; TypeHandle AsyncTaskManager::_type_handle; @@ -508,7 +510,7 @@ get_next_wake_time() const { got_any = true; next_wake_time = time; } else { - next_wake_time = min(time, next_wake_time); + next_wake_time = std::min(time, next_wake_time); } } } @@ -520,7 +522,7 @@ get_next_wake_time() const { * */ void AsyncTaskManager:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); do_output(out); } @@ -529,7 +531,7 @@ output(ostream &out) const { * */ void AsyncTaskManager:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { MutexHolder holder(_lock); indent(out, indent_level) << get_type() << " " << get_name() << "\n"; @@ -629,7 +631,7 @@ do_has_task(AsyncTask *task) const { * */ void AsyncTaskManager:: -do_output(ostream &out) const { +do_output(std::ostream &out) const { out << get_type() << " " << get_name() << "; " << _num_tasks << " tasks"; } diff --git a/panda/src/event/asyncTaskSequence.cxx b/panda/src/event/asyncTaskSequence.cxx index b84a968386..82541ec8da 100644 --- a/panda/src/event/asyncTaskSequence.cxx +++ b/panda/src/event/asyncTaskSequence.cxx @@ -20,7 +20,7 @@ TypeHandle AsyncTaskSequence::_type_handle; * */ AsyncTaskSequence:: -AsyncTaskSequence(const string &name) : +AsyncTaskSequence(const std::string &name) : AsyncTask(name), _repeat_count(0), _task_index(0) diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index 38dbbffb6a..170812958b 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/panda/src/event/buttonEvent.cxx @@ -21,7 +21,7 @@ * */ void ButtonEvent:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_type) { case T_down: out << "button " << _button << " down"; diff --git a/panda/src/event/buttonEventList.cxx b/panda/src/event/buttonEventList.cxx index 633329a5a1..21c9d45981 100644 --- a/panda/src/event/buttonEventList.cxx +++ b/panda/src/event/buttonEventList.cxx @@ -45,7 +45,7 @@ update_mods(ModifierButtons &mods) const { * */ void ButtonEventList:: -output(ostream &out) const { +output(std::ostream &out) const { if (_events.empty()) { out << "(no buttons)"; } else { @@ -65,7 +65,7 @@ output(ostream &out) const { * */ void ButtonEventList:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; Events::const_iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index 4453b890f3..8a46d2586f 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -20,7 +20,7 @@ TypeHandle Event::_type_handle; * */ Event:: -Event(const string &event_name, EventReceiver *receiver) : +Event(const std::string &event_name, EventReceiver *receiver) : _name(event_name) { _receiver = receiver; @@ -117,7 +117,7 @@ clear_receiver() { * */ void Event:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name(); out << "("; diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index 998946e92b..f74bd8c519 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -15,6 +15,8 @@ #include "eventQueue.h" #include "config_event.h" +using std::string; + TypeHandle EventHandler::_type_handle; EventHandler *EventHandler::_global_event_handler = nullptr; @@ -82,7 +84,7 @@ dispatch_event(const Event *event) { event_cat->spam() << "calling callback 0x" << (void*)(*fi) << " for event '" << event->get_name() << "'" - << endl; + << std::endl; } (*fi)(event); } @@ -120,7 +122,7 @@ dispatch_event(const Event *event) { * */ void EventHandler:: -write(ostream &out) const { +write(std::ostream &out) const { Hooks::const_iterator hi; hi = _hooks.begin(); @@ -165,7 +167,7 @@ add_hook(const string &event_name, EventFunction *function) { if (event_cat.is_debug()) { event_cat.debug() << "adding hook for event '" << event_name - << "' with function 0x" << (void*)function << endl; + << "' with function 0x" << (void*)function << std::endl; } assert(!event_name.empty()); assert(function); @@ -357,7 +359,7 @@ make_global_event_handler() { * */ void EventHandler:: -write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { +write_hook(std::ostream &out, const EventHandler::Hooks::value_type &hook) const { if (!hook.second.empty()) { out << hook.first << " has " << hook.second.size() << " functions.\n"; } @@ -367,7 +369,7 @@ write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { * */ void EventHandler:: -write_cbhook(ostream &out, const EventHandler::CallbackHooks::value_type &hook) const { +write_cbhook(std::ostream &out, const EventHandler::CallbackHooks::value_type &hook) const { if (!hook.second.empty()) { out << hook.first << " has " << hook.second.size() << " callback functions.\n"; } diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index 40122908cd..37f6690dae 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -21,7 +21,7 @@ template class ParamValue; * */ void EventParameter:: -output(ostream &out) const { +output(std::ostream &out) const { if (_ptr == nullptr) { out << "(empty)"; diff --git a/panda/src/event/genericAsyncTask.cxx b/panda/src/event/genericAsyncTask.cxx index c0d68fa3ff..f78fddecc3 100644 --- a/panda/src/event/genericAsyncTask.cxx +++ b/panda/src/event/genericAsyncTask.cxx @@ -20,7 +20,7 @@ TypeHandle GenericAsyncTask::_type_handle; * */ GenericAsyncTask:: -GenericAsyncTask(const string &name) : +GenericAsyncTask(const std::string &name) : AsyncTask(name) { _function = nullptr; @@ -33,7 +33,7 @@ GenericAsyncTask(const string &name) : * */ GenericAsyncTask:: -GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void *user_data) : +GenericAsyncTask(const std::string &name, GenericAsyncTask::TaskFunc *function, void *user_data) : AsyncTask(name), _function(function), _user_data(user_data) diff --git a/panda/src/event/pointerEvent.cxx b/panda/src/event/pointerEvent.cxx index 8e64a3c58b..7ee7d3621c 100644 --- a/panda/src/event/pointerEvent.cxx +++ b/panda/src/event/pointerEvent.cxx @@ -19,7 +19,7 @@ * */ void PointerEvent:: -output(ostream &out) const { +output(std::ostream &out) const { out << (_in_window ? "In@" : "Out@") << _xpos << "," << _ypos << " "; } diff --git a/panda/src/event/pointerEventList.cxx b/panda/src/event/pointerEventList.cxx index fc376bc886..4c9d8472c2 100644 --- a/panda/src/event/pointerEventList.cxx +++ b/panda/src/event/pointerEventList.cxx @@ -48,7 +48,7 @@ INLINE double normalize_angle(double angle) { * */ void PointerEventList:: -output(ostream &out) const { +output(std::ostream &out) const { if (_events.empty()) { out << "(no pointers)"; } else { @@ -68,7 +68,7 @@ output(ostream &out) const { * */ void PointerEventList:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; Events::const_iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { @@ -172,7 +172,7 @@ total_turns(double sec) const { * to be in order to be considered significant. */ double PointerEventList:: -match_pattern(const string &ascpat, double rot, double seglen) { +match_pattern(const std::string &ascpat, double rot, double seglen) { // Convert the pattern from ascii to a more usable form. vector_double pattern; parse_pattern(ascpat, pattern); @@ -189,7 +189,7 @@ match_pattern(const string &ascpat, double rot, double seglen) { * Parses a pattern as used by match_pattern. */ void PointerEventList:: -parse_pattern(const string &ascpat, vector_double &pattern) { +parse_pattern(const std::string &ascpat, vector_double &pattern) { int chars = 0; double dir = 180.0; for (size_t i=0; i= 3 PyObject *str = PyObject_ASCII(result); if (str == nullptr) { @@ -742,7 +742,7 @@ do_python_task() { #endif Py_DECREF(str); Py_DECREF(result); - string message = strm.str(); + std::string message = strm.str(); nassert_raise(message); return DS_interrupt; diff --git a/panda/src/event/test_task.cxx b/panda/src/event/test_task.cxx index 958742f747..e8cc5cb5ef 100644 --- a/panda/src/event/test_task.cxx +++ b/panda/src/event/test_task.cxx @@ -16,9 +16,11 @@ #include "asyncTaskManager.h" #include "perlinNoise2.h" +using std::cerr; + class MyTask : public AsyncTask { public: - MyTask(const string &name, double length, int repeat_count) : + MyTask(const std::string &name, double length, int repeat_count) : AsyncTask(name), _length(length), _repeat_count(repeat_count) @@ -62,12 +64,12 @@ main(int argc, char *argv[]) { cerr << "Making tasks.\n"; for (int yi = 0; yi < grid_size; ++yi) { for (int xi = 0; xi < grid_size; ++xi) { - ostringstream namestrm; + std::ostringstream namestrm; namestrm << "task_" << xi << "_" << yi; - double length = max(length_noise.noise(xi, yi) + 1.0, 0.0); - double delay = max(delay_noise.noise(xi, yi), 0.0) * 3.0; - int repeat_count = (int)floor(max(repeat_count_noise.noise(xi, yi) + 1.0, 0.0) * 1.5); + double length = std::max(length_noise.noise(xi, yi) + 1.0, 0.0); + double delay = std::max(delay_noise.noise(xi, yi), 0.0) * 3.0; + int repeat_count = (int)floor(std::max(repeat_count_noise.noise(xi, yi) + 1.0, 0.0) * 1.5); int sort = (int)floor(sort_noise.noise(xi, yi) * 2.0); int priority = (int)floor(priority_noise.noise(xi, yi) * 5.0); diff --git a/panda/src/express/checksumHashGenerator.I b/panda/src/express/checksumHashGenerator.I index ade42717b0..640b02e415 100644 --- a/panda/src/express/checksumHashGenerator.I +++ b/panda/src/express/checksumHashGenerator.I @@ -13,7 +13,9 @@ #ifdef _WIN32 // Needed for PtrToLong, below +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif diff --git a/panda/src/express/checksumHashGenerator.cxx b/panda/src/express/checksumHashGenerator.cxx index fbcf1b7563..0de99789fd 100644 --- a/panda/src/express/checksumHashGenerator.cxx +++ b/panda/src/express/checksumHashGenerator.cxx @@ -17,9 +17,9 @@ * Adds a string to the hash, by breaking it down into a sequence of integers. */ void ChecksumHashGenerator:: -add_string(const string &str) { +add_string(const std::string &str) { add_int(str.length()); - string::const_iterator si; + std::string::const_iterator si; for (si = str.begin(); si != str.end(); ++si) { add_int(*si); } diff --git a/panda/src/express/compress_string.cxx b/panda/src/express/compress_string.cxx index 4d1069e34c..d4c08ddb39 100644 --- a/panda/src/express/compress_string.cxx +++ b/panda/src/express/compress_string.cxx @@ -18,6 +18,12 @@ #include "virtualFileSystem.h" #include "config_express.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Compress the indicated source string at the given compression level (1 * through 9). Returns the compressed string. diff --git a/panda/src/express/copy_stream.cxx b/panda/src/express/copy_stream.cxx index 77d0e78364..e04e681772 100644 --- a/panda/src/express/copy_stream.cxx +++ b/panda/src/express/copy_stream.cxx @@ -19,7 +19,7 @@ * true on success, false on failure. */ bool -copy_stream(istream &source, ostream &dest) { +copy_stream(std::istream &source, std::ostream &dest) { static const size_t buffer_size = 4096; char buffer[buffer_size]; diff --git a/panda/src/express/datagram.cxx b/panda/src/express/datagram.cxx index 826a261f93..de7d4089dc 100644 --- a/panda/src/express/datagram.cxx +++ b/panda/src/express/datagram.cxx @@ -41,7 +41,7 @@ clear() { * hex (and ASCII) values. */ void Datagram:: -dump_hex(ostream &out, unsigned int indent) const { +dump_hex(std::ostream &out, unsigned int indent) const { const char *message = (const char *)get_data(); size_t num_bytes = get_length(); for (size_t line = 0; line < num_bytes; line += 16) { @@ -80,13 +80,13 @@ dump_hex(ostream &out, unsigned int indent) const { * Adds a variable-length wstring to the datagram. */ void Datagram:: -add_wstring(const wstring &str) { +add_wstring(const std::wstring &str) { // By convention, wstrings are marked with 32-bit lengths. add_uint32((uint32_t)str.length()); // Now append each character in the string. We store each code little- // endian, for no real good reason. - wstring::const_iterator ci; + std::wstring::const_iterator ci; for (ci = str.begin(); ci != str.end(); ++ci) { add_uint16((uint16_t)*ci); } @@ -168,7 +168,7 @@ assign(const void *data, size_t size) { * Write a string representation of this instance to . */ void Datagram:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"Datagram"; #endif //] NDEBUG @@ -178,7 +178,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void Datagram:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"Datagram:\n"; diff --git a/panda/src/express/datagramGenerator.cxx b/panda/src/express/datagramGenerator.cxx index 08d792bd70..275a050e88 100644 --- a/panda/src/express/datagramGenerator.cxx +++ b/panda/src/express/datagramGenerator.cxx @@ -86,7 +86,7 @@ get_vfile() { * pointing to the first byte following the datagram returned after a call to * get_datagram(). */ -streampos DatagramGenerator:: +std::streampos DatagramGenerator:: get_file_pos() { return 0; } diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 4006ec1eea..680ead3a66 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -14,6 +14,9 @@ #include "datagramIterator.h" #include "pnotify.h" +using std::string; +using std::wstring; + TypeHandle DatagramIterator::_type_handle; /** @@ -156,7 +159,7 @@ extract_bytes(unsigned char *into, size_t size) { * Write a string representation of this instance to . */ void DatagramIterator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"DatagramIterator"; #endif //] NDEBUG @@ -166,7 +169,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DatagramIterator:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"DatagramIterator:\n"; out.width(indent+2); out<<""<<"_current_index "<<_current_index; diff --git a/panda/src/express/datagramSink.cxx b/panda/src/express/datagramSink.cxx index 5b451d3bb2..bdf2be596c 100644 --- a/panda/src/express/datagramSink.cxx +++ b/panda/src/express/datagramSink.cxx @@ -80,7 +80,7 @@ get_file() { * pointing to the first byte following the datagram returned after a call to * put_datagram(). */ -streampos DatagramSink:: +std::streampos DatagramSink:: get_file_pos() { return 0; } diff --git a/panda/src/express/encrypt_string.cxx b/panda/src/express/encrypt_string.cxx index be2100cee8..6c400d77f7 100644 --- a/panda/src/express/encrypt_string.cxx +++ b/panda/src/express/encrypt_string.cxx @@ -18,6 +18,12 @@ #include "virtualFileSystem.h" #include "config_express.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Encrypts the indicated source string using the given password, and the * algorithm specified by encryption-algorithm. Returns the encrypted string. diff --git a/panda/src/express/error_utils.cxx b/panda/src/express/error_utils.cxx index 8a1ec79331..8509856f18 100644 --- a/panda/src/express/error_utils.cxx +++ b/panda/src/express/error_utils.cxx @@ -21,6 +21,8 @@ #include #endif +using std::string; + /** * */ @@ -229,7 +231,7 @@ string handle_socket_error() { errmsg = strerror(errno); default: if (express_cat.is_debug()) - express_cat.debug() << "handle_socket_error - unknown error: " << err << endl; + express_cat.debug() << "handle_socket_error - unknown error: " << err << std::endl; errmsg = "Unknown WSA error"; } @@ -282,12 +284,12 @@ get_network_error() { if (express_cat.is_debug()) express_cat.debug() << "get_network_error() - WSA error = 0 - error : " - << strerror(errno) << endl; + << strerror(errno) << std::endl; return EU_error_abort; default: if (express_cat.is_debug()) express_cat.debug() - << "get_network_error() - unknown error: " << err << endl; + << "get_network_error() - unknown error: " << err << std::endl; return EU_error_abort; } #endif diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index 797ead2ed2..3d2e6f42f5 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -20,6 +20,12 @@ #include "openssl/md5.h" #endif // HAVE_OPENSSL +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Outputs the HashVal as a 32-digit hexadecimal number. @@ -53,7 +59,7 @@ input_hex(istream &in) { } if (i != 32) { - in.clear(ios::failbit|in.rdstate()); + in.clear(std::ios::failbit|in.rdstate()); return; } @@ -203,7 +209,7 @@ hash_stream(istream &stream) { char buffer[buffer_size]; // Seek the stream to the beginning in case it wasn't there already. - stream.seekg(0, ios::beg); + stream.seekg(0, std::ios::beg); stream.read(buffer, buffer_size); size_t count = stream.gcount(); diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index a619a0a9f1..0773bb88ec 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -15,6 +15,10 @@ #include "openSSLWrapper.h" #include +using std::cerr; +using std::stringstream; +using std::string; + static const char *source_filename = "ca-bundle.crt"; static const char *target_filename = "ca_bundle_data_src.c"; @@ -45,7 +49,7 @@ main(int argc, char *argv[]) { << " entries.\n"; // Now convert the certificates to DER form. - stringstream der_stream; + std::stringstream der_stream; int cert_count = 0; int num_entries = sk_X509_INFO_num(inf); @@ -78,7 +82,7 @@ main(int argc, char *argv[]) { } der_stream.seekg(0); - istream &in = der_stream; + std::istream &in = der_stream; string table_type = "const unsigned char "; string length_type = "const int "; @@ -99,7 +103,7 @@ main(int argc, char *argv[]) { << " * in DER form, for compiling into OpenSSLWrapper.\n" << " */\n\n" << static_keyword << table_type << table_name << "[] = {"; - out << hex << setfill('0'); + out << std::hex << std::setfill('0'); int count = 0; int col = 0; unsigned int ch; @@ -113,14 +117,14 @@ main(int argc, char *argv[]) { } else { out << ", "; } - out << "0x" << setw(2) << ch; + out << "0x" << std::setw(2) << ch; col++; count++; ch = in.get(); } out << "\n};\n\n" << static_keyword << length_type << table_name << "_len = " - << dec << count << ";\n\n"; + << std::dec << count << ";\n\n"; cerr << "Wrote " << cert_count << " certificates to " << target_filename << "\n"; diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index d38ac0c77e..b76ae0ed3e 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -27,6 +27,8 @@ #include #include +using std::pair; + MemoryUsage *MemoryUsage::_global_ptr; // This flag is used to protect the operator newdelete handlers against @@ -79,7 +81,7 @@ show() const { #ifdef DO_MEMORY_USAGE // First, copy the relevant information to a vector so we can sort by // counts. Don't use a pvector. - typedef vector CountSorter; + typedef std::vector CountSorter; CountSorter count_sorter; Counts::const_iterator ci; for (ci = _counts.begin(); ci != _counts.end(); ++ci) { diff --git a/panda/src/express/memoryUsagePointerCounts.cxx b/panda/src/express/memoryUsagePointerCounts.cxx index b91be61bcc..8ce69872d6 100644 --- a/panda/src/express/memoryUsagePointerCounts.cxx +++ b/panda/src/express/memoryUsagePointerCounts.cxx @@ -34,7 +34,7 @@ add_info(MemoryInfo *info) { * */ void MemoryUsagePointerCounts:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef DO_MEMORY_USAGE out << _count << " pointers"; if (_unknown_size_count < _count) { @@ -56,7 +56,7 @@ output(ostream &out) const { * units. */ void MemoryUsagePointerCounts:: -output_bytes(ostream &out, size_t size) { +output_bytes(std::ostream &out, size_t size) { #ifdef DO_MEMORY_USAGE if (size < 4 * 1024) { out << size << " bytes"; diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index dd412958da..065519bc0c 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -111,7 +111,7 @@ get_type(size_t n) const { /** * Returns the type name of the nth pointer, if it is known. */ -string MemoryUsagePointers:: +std::string MemoryUsagePointers:: get_type_name(size_t n) const { #ifdef DO_MEMORY_USAGE nassertr(n < get_num_pointers(), ""); @@ -150,7 +150,7 @@ clear() { * */ void MemoryUsagePointers:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef DO_MEMORY_USAGE out << _entries.size() << " pointers."; #endif diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 064262747a..e625861f87 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -28,6 +28,19 @@ #include "openSSLWrapper.h" +using std::ios; +using std::iostream; +using std::istream; +using std::max; +using std::min; +using std::ostream; +using std::ostringstream; +using std::streamoff; +using std::streampos; +using std::streamsize; +using std::stringstream; +using std::string; + // This sequence of bytes begins each Multifile to identify it as a Multifile. const char Multifile::_header[] = "pmf\0\n\r"; const size_t Multifile::_header_size = 6; @@ -1997,7 +2010,7 @@ add_new_subfile(Subfile *subfile, int compression_level) { _needs_repack = true; } - pair insert_result = _subfiles.insert(subfile); + std::pair insert_result = _subfiles.insert(subfile); if (!insert_result.second) { // Hmm, unable to insert. There must already be a subfile by that name. // Remove the old one. diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index 97fe936d21..d71818e130 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -63,7 +63,7 @@ OpenSSLWrapper() { int num_certs = ssl_certificates.get_num_unique_values(); for (int ci = 0; ci < num_certs; ci++) { - string cert_file = ssl_certificates.get_unique_value(ci); + std::string cert_file = ssl_certificates.get_unique_value(ci); Filename filename = Filename::expand_from(cert_file); load_certificates(filename); } @@ -108,7 +108,7 @@ load_certificates(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); // First, read the complete file into memory. - string data; + std::string data; if (!vfs->read_file(filename, data, true)) { // Could not find or read file. express_cat.info() diff --git a/panda/src/express/password_hash.cxx b/panda/src/express/password_hash.cxx index a3385013df..b061904965 100644 --- a/panda/src/express/password_hash.cxx +++ b/panda/src/express/password_hash.cxx @@ -21,6 +21,8 @@ #include "openssl/evp.h" #include "memoryHook.h" +using std::string; + /** * Generates a non-reversible hash of a particular length based on an * arbitrary password and a random salt. This is much stronger than the diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 9c0ebc9481..a527d78a02 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -35,6 +35,14 @@ istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR +using std::endl; +using std::ios; +using std::istream; +using std::min; +using std::ostream; +using std::streampos; +using std::string; + // this actually slows things down... #define // USE_MD5_FOR_HASHTABLE_INDEX_VALUES @@ -1103,7 +1111,7 @@ compute_mf_patches(ostream &write_stream, index_orig, index_new)) { return false; } - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_index_end(), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_index_end(), false); } // Now walk through each subfile in the new multifile. If a particular @@ -1112,7 +1120,7 @@ compute_mf_patches(ostream &write_stream, // removed, we simply don't add it (we'll never even notice this case). int new_num_subfiles = mf_new.get_num_subfiles(); for (int ni = 0; ni < new_num_subfiles; ++ni) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_subfile_internal_start(ni), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_subfile_internal_start(ni), false); string name = mf_new.get_subfile_name(ni); int oi = mf_orig.find_subfile(name); @@ -1509,7 +1517,7 @@ patch_subfile(ostream &write_stream, const Filename &filename, IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end, IStreamWrapper &stream_new, streampos new_start, streampos new_end) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + new_start, false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)new_start, false); size_t new_size = new_end - new_start; size_t orig_size = orig_end - orig_start; diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index e0f8c85046..8c7aa38a4e 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -39,6 +39,41 @@ PointerTo(PointerTo &&from) noexcept : { } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(Y *ptr) noexcept : + PointerToBase(ptr) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(const PointerTo &r) noexcept : + PointerToBase(r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(PointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} +#endif // !CPPPARSER + /** * */ @@ -49,6 +84,30 @@ operator = (PointerTo &&from) noexcept { return *this; } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE PointerTo &PointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo &PointerTo:: +operator = (PointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} +#endif // !CPPPARSER + /** * */ @@ -172,6 +231,63 @@ ConstPointerTo(ConstPointerTo &&from) noexcept : { } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const Y *ptr) noexcept : + PointerToBase((Y *)ptr) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const PointerTo &r) noexcept : + PointerToBase(r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const ConstPointerTo &r) noexcept : + PointerToBase((Y *)r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(PointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(ConstPointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} +#endif // !CPPPARSER + /** * */ @@ -192,6 +308,52 @@ operator = (ConstPointerTo &&from) noexcept { return *this; } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (const ConstPointerTo &r) noexcept { + this->reassign((Y *)r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (PointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (ConstPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} +#endif // !CPPPARSER + /** * */ diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 1f9704c3f3..cb790ebd81 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -77,8 +77,21 @@ PUBLISHED: public: INLINE PointerTo(PointerTo &&from) noexcept; + + template + ALWAYS_INLINE explicit PointerTo(Y *ptr) noexcept; + template + ALWAYS_INLINE PointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE PointerTo(PointerTo &&r) noexcept; + INLINE PointerTo &operator = (PointerTo &&from) noexcept; + template + ALWAYS_INLINE PointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE PointerTo &operator = (PointerTo &&r) noexcept; + constexpr To &operator *() const noexcept; constexpr To *operator -> () const noexcept; // MSVC.NET 2005 insists that we use T *, and not To *, here. @@ -141,9 +154,30 @@ PUBLISHED: public: INLINE ConstPointerTo(PointerTo &&from) noexcept; INLINE ConstPointerTo(ConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE explicit ConstPointerTo(const Y *ptr) noexcept; + template + ALWAYS_INLINE ConstPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(PointerTo &&r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(ConstPointerTo &&r) noexcept; + INLINE ConstPointerTo &operator = (PointerTo &&from) noexcept; INLINE ConstPointerTo &operator = (ConstPointerTo &&from) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (PointerTo &&r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (ConstPointerTo &&r) noexcept; + constexpr const To &operator *() const noexcept; constexpr const To *operator -> () const noexcept; constexpr operator const T *() const noexcept; @@ -181,6 +215,26 @@ void swap(ConstPointerTo &one, ConstPointerTo &two) noexcept { } +// Define owner_less specializations, for completeness' sake. +namespace std { + template + struct owner_less > { + bool operator () (const PointerTo &lhs, + const PointerTo &rhs) const noexcept { + return lhs < rhs; + } + }; + + template + struct owner_less > { + bool operator () (const ConstPointerTo &lhs, + const ConstPointerTo &rhs) const noexcept { + return lhs < rhs; + } + }; +} + + // Finally, we'll define a couple of handy abbreviations to save on all that // wasted typing time. diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index e6e749f1f4..819e16efec 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -44,11 +44,24 @@ PointerToBase(const PointerToBase ©) { */ template INLINE PointerToBase:: -~PointerToBase() { - if (_void_ptr != nullptr) { - unref_delete((To *)_void_ptr); - _void_ptr = nullptr; - } +PointerToBase(PointerToBase &&from) noexcept { + _void_ptr = from._void_ptr; + from._void_ptr = nullptr; +} + +/** + * + */ +template +template +INLINE PointerToBase:: +PointerToBase(PointerToBase &&r) noexcept { + // If this next line gives an error, you are trying to convert a PointerTo + // from an incompatible type of another PointerTo. + To *ptr = (Y *)r._void_ptr; + + this->_void_ptr = ptr; + r._void_ptr = nullptr; } /** @@ -56,9 +69,11 @@ INLINE PointerToBase:: */ template INLINE PointerToBase:: -PointerToBase(PointerToBase &&from) noexcept { - _void_ptr = from._void_ptr; - from._void_ptr = nullptr; +~PointerToBase() { + if (_void_ptr != nullptr) { + unref_delete((To *)_void_ptr); + _void_ptr = nullptr; + } } /** @@ -84,6 +99,31 @@ reassign(PointerToBase &&from) noexcept { } } +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void PointerToBase:: +reassign(PointerToBase &&from) noexcept { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + To *old_ptr = (To *)this->_void_ptr; + + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)from._void_ptr; + + this->_void_ptr = new_ptr; + from._void_ptr = nullptr; + + // Now delete the old pointer. + if (old_ptr != nullptr) { + unref_delete(old_ptr); + } + } +} + /** * This is the main work of the PointerTo family. When the pointer is * reassigned, decrement the old reference count and increment the new one. diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 057a465454..832717e14e 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -35,17 +35,26 @@ protected: INLINE PointerToBase(To *ptr); INLINE PointerToBase(const PointerToBase ©); INLINE PointerToBase(PointerToBase &&from) noexcept; + template + INLINE PointerToBase(PointerToBase &&r) noexcept; + INLINE ~PointerToBase(); INLINE void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(PointerToBase &&from) noexcept; + template + INLINE void reassign(PointerToBase &&from) noexcept; INLINE void update_type(To *ptr); // No assignment or retrieval functions are declared in PointerToBase, // because we will have to specialize on const vs. non-const later. + // This is needed to be able to access the privates of other instantiations. + template friend class PointerToBase; + template friend class WeakPointerToBase; + PUBLISHED: ALWAYS_INLINE void clear(); diff --git a/panda/src/express/pointerToVoid.I b/panda/src/express/pointerToVoid.I index c6f981a7fb..8704ce4ce6 100644 --- a/panda/src/express/pointerToVoid.I +++ b/panda/src/express/pointerToVoid.I @@ -11,13 +11,6 @@ * @date 2004-09-27 */ -/** - * - */ -constexpr PointerToVoid:: -PointerToVoid() noexcept : _void_ptr(nullptr) { -} - /** * */ diff --git a/panda/src/express/pointerToVoid.h b/panda/src/express/pointerToVoid.h index 1f5fadd492..e185911eab 100644 --- a/panda/src/express/pointerToVoid.h +++ b/panda/src/express/pointerToVoid.h @@ -32,7 +32,7 @@ */ class EXPCL_PANDA_EXPRESS PointerToVoid : public MemoryBase { protected: - constexpr PointerToVoid() noexcept; + constexpr PointerToVoid() noexcept = default; //INLINE ~PointerToVoid(); private: @@ -63,7 +63,7 @@ protected: // a PointerTo any class that inherits virtually from ReferenceCount. (You // can't downcast past a virtual inheritance level, but you can always // cross-cast from a void pointer.) - AtomicAdjust::Pointer _void_ptr; + AtomicAdjust::Pointer _void_ptr = nullptr; }; #include "pointerToVoid.I" diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index 78df0afbd4..dfad4b03b4 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -13,6 +13,9 @@ #include "pmap.h" +using std::ostream; +using std::string; + // See ProfileTimer.h for documentation. @@ -127,7 +130,7 @@ consolidateTo(ostream &out) const { << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; - out << endl; + out << std::endl; } void ProfileTimer:: @@ -156,7 +159,7 @@ printTo(ostream &out) const { << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; - out << endl; + out << std::endl; } ProfileTimer::AutoTimer::AutoTimer(ProfileTimer& profile, const char* tag) : diff --git a/panda/src/express/ramfile.cxx b/panda/src/express/ramfile.cxx index cc12e239c7..c1994df34c 100644 --- a/panda/src/express/ramfile.cxx +++ b/panda/src/express/ramfile.cxx @@ -21,10 +21,10 @@ * The interface here is intentionally designed to be similar to that for * Python's file.read() function. */ -string Ramfile:: +std::string Ramfile:: read(size_t length) { size_t orig_pos = _pos; - _pos = min(_pos + length, _data.length()); + _pos = std::min(_pos + length, _data.length()); return _data.substr(orig_pos, length); } @@ -36,7 +36,7 @@ read(size_t length) { * The interface here is intentionally designed to be similar to that for * Python's file.readline() function. */ -string Ramfile:: +std::string Ramfile:: readline() { size_t start = _pos; while (_pos < _data.length() && _data[_pos] != '\n') { diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx index c52641abca..fc1047487c 100644 --- a/panda/src/express/ramfile_ext.cxx +++ b/panda/src/express/ramfile_ext.cxx @@ -23,8 +23,8 @@ PyObject *Extension:: read(size_t length) { size_t data_length = _this->get_data_size(); const char *data = _this->_data.data() + _this->_pos; - length = min(length, data_length - _this->_pos); - _this->_pos = min(_this->_pos + length, data_length); + length = std::min(length, data_length - _this->_pos); + _this->_pos = std::min(_this->_pos + length, data_length); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize((char *)data, length); @@ -43,7 +43,7 @@ read(size_t length) { */ PyObject *Extension:: readline() { - string line = _this->readline(); + std::string line = _this->readline(); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize(line.data(), line.size()); #else @@ -62,7 +62,7 @@ readlines() { return nullptr; } - string line = _this->readline(); + std::string line = _this->readline(); while (!line.empty()) { #if PY_MAJOR_VERSION >= 3 PyObject *py_line = PyBytes_FromStringAndSize(line.data(), line.size()); diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 0a3f44da9e..4d773e359f 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -15,6 +15,11 @@ #include "pnotify.h" #include "memoryHook.h" +using std::ios; +using std::streamoff; +using std::streampos; +using std::streamsize; + static const size_t substream_buffer_size = 4096; /** diff --git a/panda/src/express/subfileInfo.cxx b/panda/src/express/subfileInfo.cxx index 07ab4fc7f8..55631b25af 100644 --- a/panda/src/express/subfileInfo.cxx +++ b/panda/src/express/subfileInfo.cxx @@ -17,6 +17,6 @@ * */ void SubfileInfo:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SubfileInfo(" << get_filename() << ", " << _start << ", " << _size << ")"; } diff --git a/panda/src/express/test_ordered_vector.cxx b/panda/src/express/test_ordered_vector.cxx index 1ed3ba9c96..18c0ab6d1d 100644 --- a/panda/src/express/test_ordered_vector.cxx +++ b/panda/src/express/test_ordered_vector.cxx @@ -13,11 +13,13 @@ #include "ordered_vector.h" +using std::cerr; + typedef ov_multiset myvec; void search(myvec &v, int element) { - pair result; + std::pair result; result = v.equal_range(element); size_t count = v.count(element); diff --git a/panda/src/express/test_types.cxx b/panda/src/express/test_types.cxx index 7cc5cf6e61..1bc9bfefd7 100644 --- a/panda/src/express/test_types.cxx +++ b/panda/src/express/test_types.cxx @@ -19,6 +19,9 @@ #include "pnotify.h" +using std::cerr; +using std::string; + class ThatThingie : public TypedObject, public ReferenceCount { public: ThatThingie(const string &name) : _name(name) { diff --git a/panda/src/express/test_zstream.cxx b/panda/src/express/test_zstream.cxx index 34212eb2df..6040aa3ca7 100644 --- a/panda/src/express/test_zstream.cxx +++ b/panda/src/express/test_zstream.cxx @@ -17,6 +17,10 @@ #include +using std::cerr; +using std::cout; +using std::istream; + void stream_decompress(istream &source) { IDecompressStream zstream(&source, false); @@ -42,7 +46,7 @@ stream_compress(istream &source) { void zlib_decompress(istream &source) { // First, read the entire contents into a buffer. - string data; + std::string data; int ch = source.get(); while (!source.eof() && !source.fail()) { @@ -82,7 +86,7 @@ zlib_decompress(istream &source) { void zlib_compress(istream &source) { // First, read the entire contents into a buffer. - string data; + std::string data; int ch = source.get(); while (!source.eof() && !source.fail()) { diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index ea60c5bb1e..f60ddc22dc 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -17,6 +17,9 @@ #include // for fabs() +using std::max; +using std::min; + TrueClock *TrueClock::_global_ptr = nullptr; #if defined(WIN32_VC) || defined(WIN64_VC) @@ -169,7 +172,7 @@ TrueClock() { if (_has_high_res) { if (int_frequency <= 0) { clock_cat.error() - << "TrueClock::get_real_time() - frequency is negative!" << endl; + << "TrueClock::get_real_time() - frequency is negative!" << std::endl; _has_high_res = false; } else { @@ -198,7 +201,7 @@ TrueClock() { if (!_has_high_res) { clock_cat.warning() - << "No high resolution clock available." << endl; + << "No high resolution clock available." << std::endl; } } diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 37068adcab..e388d7c704 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -18,6 +18,11 @@ #include "pvector.h" #include +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFile::_type_handle; /** @@ -284,7 +289,7 @@ close_read_write_file(iostream *stream) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFile:: +std::streamsize VirtualFile:: get_file_size(istream *stream) const { return get_file_size(); } @@ -293,7 +298,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFile:: +std::streamsize VirtualFile:: get_file_size() const { return 0; } @@ -412,14 +417,14 @@ simple_read_file(istream *in, vector_uchar &result, size_t max_bytes) { static const size_t buffer_size = 4096; char buffer[buffer_size]; - in->read(buffer, min(buffer_size, max_bytes)); + in->read(buffer, std::min(buffer_size, max_bytes)); size_t count = in->gcount(); while (count != 0) { thread_consider_yield(); nassertr(count <= max_bytes, false); result.insert(result.end(), buffer, buffer + count); max_bytes -= count; - in->read(buffer, min(buffer_size, max_bytes)); + in->read(buffer, std::min(buffer_size, max_bytes)); count = in->gcount(); } diff --git a/panda/src/express/virtualFileComposite.cxx b/panda/src/express/virtualFileComposite.cxx index 30a5cbb0d9..63c4f8d569 100644 --- a/panda/src/express/virtualFileComposite.cxx +++ b/panda/src/express/virtualFileComposite.cxx @@ -57,7 +57,7 @@ is_directory() const { */ bool VirtualFileComposite:: scan_local_directory(VirtualFileList *file_list, - const ov_set &mount_points) const { + const ov_set &mount_points) const { bool any_ok = false; Components::const_iterator ci; for (ci = _components.begin(); ci != _components.end(); ++ci) { diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 6f8a46afda..0bfc9fc3e3 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -16,6 +16,11 @@ #include "virtualFileSystem.h" #include "zStream.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileMount::_type_handle; @@ -53,7 +58,7 @@ make_virtual_file(const Filename &local_filename, make_directory(local); } - return file.p(); + return file; } /** @@ -134,7 +139,7 @@ read_file(const Filename &file, bool do_uncompress, return false; } - streamsize file_size = get_file_size(file, in); + std::streamsize file_size = get_file_size(file, in); if (file_size > 0) { result.reserve((size_t)file_size); } diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index fa5fccece3..c9074fe97a 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -20,6 +20,10 @@ #include #endif +using std::streamoff; +using std::streampos; +using std::streamsize; + TypeHandle VirtualFileMountAndroidAsset::_type_handle; /** @@ -140,7 +144,7 @@ read_file(const Filename &file, bool do_uncompress, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountAndroidAsset:: +std::istream *VirtualFileMountAndroidAsset:: open_read_file(const Filename &file) const { AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); @@ -149,7 +153,7 @@ open_read_file(const Filename &file) const { } AssetStream *stream = new AssetStream(asset); - return (istream *) stream; + return (std::istream *) stream; } /** @@ -158,7 +162,7 @@ open_read_file(const Filename &file) const { * implementations may require this stream to determine the size. */ streamsize VirtualFileMountAndroidAsset:: -get_file_size(const Filename &file, istream *in) const { +get_file_size(const Filename &file, std::istream *in) const { // If it's already open, get the AAsset pointer from the streambuf. const AssetStreamBuf *buf = (const AssetStreamBuf *) in->rdbuf(); off_t length = AAsset_getLength(buf->_asset); diff --git a/panda/src/express/virtualFileMountMultifile.cxx b/panda/src/express/virtualFileMountMultifile.cxx index 1ecd5b7b5e..1c9a0782ba 100644 --- a/panda/src/express/virtualFileMountMultifile.cxx +++ b/panda/src/express/virtualFileMountMultifile.cxx @@ -85,7 +85,7 @@ read_file(const Filename &file, bool do_uncompress, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountMultifile:: +std::istream *VirtualFileMountMultifile:: open_read_file(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { @@ -104,8 +104,8 @@ open_read_file(const Filename &file) const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountMultifile:: -get_file_size(const Filename &file, istream *) const { +std::streamsize VirtualFileMountMultifile:: +get_file_size(const Filename &file, std::istream *) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { return 0; @@ -117,7 +117,7 @@ get_file_size(const Filename &file, istream *) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountMultifile:: +std::streamsize VirtualFileMountMultifile:: get_file_size(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { @@ -167,7 +167,7 @@ get_system_info(const Filename &file, SubfileInfo &info) { return false; } - streampos start = _multifile->get_subfile_internal_start(subfile_index); + std::streampos start = _multifile->get_subfile_internal_start(subfile_index); size_t length = _multifile->get_subfile_internal_length(subfile_index); info = SubfileInfo(multifile_name, start, length); @@ -189,6 +189,6 @@ scan_directory(vector_string &contents, const Filename &dir) const { * */ void VirtualFileMountMultifile:: -output(ostream &out) const { +output(std::ostream &out) const { out << _multifile->get_multifile_name(); } diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 2f1f481b3d..feda85d1f6 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -15,6 +15,11 @@ #include "subStream.h" #include "dcast.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileMountRamdisk::_type_handle; TypeHandle VirtualFileMountRamdisk::FileBase::_type_handle; TypeHandle VirtualFileMountRamdisk::File::_type_handle; @@ -241,7 +246,7 @@ open_write_file(const Filename &file, bool truncate) { // second, since the timer only has a one second precision. The proper // solution to fix this would be to switch to a higher precision // timer everywhere. - f->_timestamp = max(f->_timestamp + 1, time(nullptr)); + f->_timestamp = std::max(f->_timestamp + 1, time(nullptr)); } return new OSubStream(&f->_wrapper, 0, 0); @@ -283,7 +288,7 @@ open_read_write_file(const Filename &file, bool truncate) { f->_data.str(string()); // See open_write_file - f->_timestamp = max(f->_timestamp + 1, time(nullptr)); + f->_timestamp = std::max(f->_timestamp + 1, time(nullptr)); } return new SubStream(&f->_wrapper, 0, 0); @@ -312,7 +317,7 @@ open_read_append_file(const Filename &file) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountRamdisk:: +std::streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file, istream *stream) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); @@ -329,7 +334,7 @@ get_file_size(const Filename &file, istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountRamdisk:: +std::streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index 4ef0d32ab1..ebf5fa6645 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -14,6 +14,13 @@ #include "virtualFileMountSystem.h" #include "virtualFileSystem.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::streampos; +using std::streamsize; +using std::string; + TypeHandle VirtualFileMountSystem::_type_handle; @@ -297,7 +304,7 @@ get_file_size(const Filename &file, istream *stream) const { streampos orig = stream->tellg(); // Seek to the end and get the stream position there. - stream->seekg(0, ios::end); + stream->seekg(0, std::ios::end); if (stream->fail()) { // Seeking not supported. stream->clear(); @@ -306,7 +313,7 @@ get_file_size(const Filename &file, istream *stream) const { streampos size = stream->tellg(); // Then return to the original point. - stream->seekg(orig, ios::beg); + stream->seekg(orig, std::ios::beg); // Make sure there are no error flags set as a result of the seek. stream->clear(); diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index c5810934f9..11ee94cce9 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -16,6 +16,11 @@ #include "virtualFileList.h" #include "dcast.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileSimple::_type_handle; @@ -308,7 +313,7 @@ close_read_write_file(iostream *stream) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileSimple:: +std::streamsize VirtualFileSimple:: get_file_size(istream *stream) const { return _mount->get_file_size(_local_filename, stream); } @@ -317,7 +322,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileSimple:: +std::streamsize VirtualFileSimple:: get_file_size() const { return _mount->get_file_size(_local_filename); } diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 0262392216..eb915b566c 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -25,6 +25,11 @@ #include "executionEnvironment.h" #include "pset.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + VirtualFileSystem *VirtualFileSystem::_global_ptr = nullptr; diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index c6e570979f..8d60057c31 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -39,6 +39,49 @@ WeakPointerTo(const WeakPointerTo ©) : { } +/** + * + */ +template +INLINE WeakPointerTo:: +WeakPointerTo(WeakPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(const WeakPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(const PointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(WeakPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + /** * */ @@ -82,23 +125,9 @@ operator T * () const { template INLINE PointerTo WeakPointerTo:: lock() const { - WeakReferenceList *weak_ref = this->_weak_ref; - if (weak_ref != nullptr) { - PointerTo ptr; - weak_ref->_lock.lock(); - if (!weak_ref->was_deleted()) { - // We also need to check that the reference count is not zero (which can - // happen if the object is currently being destructed), since that could - // cause double deletion. - To *plain_ptr = (To *)WeakPointerToBase::_void_ptr; - if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { - ptr.cheat() = plain_ptr; - } - } - weak_ref->_lock.unlock(); - return ptr; - } - return nullptr; + PointerTo ptr; + this->lock_into(ptr); + return ptr; } /** @@ -152,6 +181,49 @@ operator = (const WeakPointerTo ©) { return *this; } +/** + * + */ +template +INLINE WeakPointerTo &WeakPointerTo:: +operator = (WeakPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (const WeakPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (WeakPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + /** * */ @@ -202,6 +274,92 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : { } +/** + * + */ +template +INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakConstPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const WeakPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const WeakConstPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const PointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const ConstPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakConstPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + /** * */ @@ -243,23 +401,9 @@ operator const T * () const { template INLINE ConstPointerTo WeakConstPointerTo:: lock() const { - WeakReferenceList *weak_ref = this->_weak_ref; - if (weak_ref != nullptr) { - ConstPointerTo ptr; - weak_ref->_lock.lock(); - if (!weak_ref->was_deleted()) { - // We also need to check that the reference count is not zero (which can - // happen if the object is currently being destructed), since that could - // cause double deletion. - const To *plain_ptr = (const To *)WeakPointerToBase::_void_ptr; - if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { - ptr.cheat() = plain_ptr; - } - } - weak_ref->_lock.unlock(); - return ptr; - } - return nullptr; + ConstPointerTo ptr; + this->lock_into(ptr); + return ptr; } /** @@ -332,3 +476,89 @@ operator = (const WeakConstPointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } + +/** + * + */ +template +INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakConstPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const WeakPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const WeakConstPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const ConstPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakConstPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 5834113b7a..bd302e0ec9 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -30,15 +30,25 @@ class WeakPointerTo : public WeakPointerToBase { public: typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakPointerTo(To *ptr = nullptr); + constexpr WeakPointerTo() noexcept = default; + INLINE WeakPointerTo(To *ptr); INLINE WeakPointerTo(const PointerTo ©); INLINE WeakPointerTo(const WeakPointerTo ©); public: + INLINE WeakPointerTo(WeakPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakPointerTo(const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo(WeakPointerTo &&r) noexcept; + INLINE To &operator *() const; INLINE To *operator -> () const; // MSVC.NET 2005 insists that we use T *, and not To *, here. - INLINE operator T *() const; + INLINE explicit operator T *() const; PUBLISHED: INLINE PointerTo lock() const; @@ -49,6 +59,17 @@ PUBLISHED: INLINE WeakPointerTo &operator = (const PointerTo ©); INLINE WeakPointerTo &operator = (const WeakPointerTo ©); +public: + INLINE WeakPointerTo &operator = (WeakPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakPointerTo &operator = (const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo &operator = (WeakPointerTo &&r) noexcept; + +PUBLISHED: // This function normally wouldn't need to be redefined here, but we do so // anyway just to help out interrogate (which doesn't seem to want to // automatically export the WeakPointerToBase class). When this works again @@ -66,16 +87,33 @@ class WeakConstPointerTo : public WeakPointerToBase { public: typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakConstPointerTo(const To *ptr = nullptr); + constexpr WeakConstPointerTo() noexcept = default; + INLINE WeakConstPointerTo(const To *ptr); INLINE WeakConstPointerTo(const PointerTo ©); INLINE WeakConstPointerTo(const ConstPointerTo ©); INLINE WeakConstPointerTo(const WeakPointerTo ©); INLINE WeakConstPointerTo(const WeakConstPointerTo ©); public: + INLINE WeakConstPointerTo(WeakPointerTo &&from) noexcept; + INLINE WeakConstPointerTo(WeakConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakConstPointerTo(const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const WeakConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(WeakPointerTo &&r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(WeakConstPointerTo &&r) noexcept; + INLINE const To &operator *() const; INLINE const To *operator -> () const; - INLINE operator const T *() const; + INLINE explicit operator const T *() const; PUBLISHED: INLINE ConstPointerTo lock() const; @@ -88,6 +126,24 @@ PUBLISHED: INLINE WeakConstPointerTo &operator = (const WeakPointerTo ©); INLINE WeakConstPointerTo &operator = (const WeakConstPointerTo ©); +public: + INLINE WeakConstPointerTo &operator = (WeakPointerTo &&from) noexcept; + INLINE WeakConstPointerTo &operator = (WeakConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const WeakConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (WeakPointerTo &&r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (WeakConstPointerTo &&r) noexcept; + +PUBLISHED: // These functions normally wouldn't need to be redefined here, but we do so // anyway just to help out interrogate (which doesn't seem to want to // automatically export the WeakPointerToBase class). When this works again @@ -96,6 +152,25 @@ PUBLISHED: INLINE void clear() { WeakPointerToBase::clear(); } }; +// Provide specializations of std::owner_less, for using a WPT as a map key. +namespace std { + template + struct owner_less > { + bool operator () (const WeakPointerTo &lhs, + const WeakPointerTo &rhs) const noexcept { + return lhs.owner_before(rhs); + } + }; + + template + struct owner_less > { + bool operator () (const WeakConstPointerTo &lhs, + const WeakConstPointerTo &rhs) const noexcept { + return lhs.owner_before(rhs); + } + }; +} + #define WPT(type) WeakPointerTo< type > #define WCPT(type) WeakConstPointerTo< type > diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 30690458be..5673114764 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -12,7 +12,8 @@ */ /** - * + * Constructs a weak pointer from a plain pointer (or nullptr). It is the + * caller's responsibility to ensure that it points to a valid object. */ template INLINE WeakPointerToBase:: @@ -27,7 +28,7 @@ WeakPointerToBase(To *ptr) { } /** - * + * Constructs a weak pointer from a reference-counting pointer. */ template INLINE WeakPointerToBase:: @@ -42,44 +43,72 @@ WeakPointerToBase(const PointerToBase ©) { } /** - * + * Copies a weak pointer. This is always safe, even for expired pointers. */ template INLINE WeakPointerToBase:: WeakPointerToBase(const WeakPointerToBase ©) { _void_ptr = copy._void_ptr; - // Don't bother increasing the weak reference count if the object was - // already deleted. + // While it is tempting to stop maintaining the control block pointer after + // the object has been deleted, we still need it in order to define a + // consistent ordering in owner_before. WeakReferenceList *weak_ref = copy._weak_ref; - if (weak_ref != nullptr && !weak_ref->was_deleted()) { + if (weak_ref != nullptr/* && !weak_ref->was_deleted()*/) { _weak_ref = copy._weak_ref; _weak_ref->ref(); } } /** - * + * Moves a weak pointer. This is always safe, even for expired pointers. */ template INLINE WeakPointerToBase:: WeakPointerToBase(WeakPointerToBase &&from) noexcept { - // Protect against self-move-assignment. - if (from._void_ptr != this->_void_ptr) { - WeakReferenceList *old_ref = (To *)this->_weak_ref; + this->_void_ptr = from._void_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; +} - this->_void_ptr = from._void_ptr; - this->_weak_ref = from._weak_ref; - from._void_ptr = nullptr; - from._weak_ref = nullptr; +/** + * Copies a weak pointer from a cast-convertible weak pointer type. + */ +template +template +INLINE WeakPointerToBase:: +WeakPointerToBase(const WeakPointerToBase &r) { + // If this next line gives an error, you are trying to convert a WeakPointerTo + // from an incompatible type of another WeakPointerTo. + To *ptr = (Y *)r._void_ptr; - // Now delete the old pointer. - if (old_ref != nullptr && !old_ref->unref()) { - delete old_ref; - } + this->_void_ptr = ptr; + + WeakReferenceList *weak_ref = r._weak_ref; + if (weak_ref != nullptr) { + _weak_ref = weak_ref; + weak_ref->ref(); } } +/** + * Moves a weak pointer from a cast-convertible weak pointer type. + */ +template +template +INLINE WeakPointerToBase:: +WeakPointerToBase(WeakPointerToBase &&r) noexcept { + // If this next line gives an error, you are trying to convert a WeakPointerTo + // from an incompatible type of another WeakPointerTo. + To *ptr = (Y *)r._void_ptr; + + this->_void_ptr = ptr; + this->_weak_ref = r._weak_ref; + r._void_ptr = nullptr; + r._weak_ref = nullptr; +} + /** * */ @@ -141,10 +170,11 @@ reassign(const WeakPointerToBase ©) { WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; _void_ptr = new_ptr; - // Don't bother increasing the weak reference count if the object was - // already deleted. + // While it is tempting to stop maintaining the control block pointer + // after the object has been deleted, we still need it in order to define + // a consistent ordering in owner_before. WeakReferenceList *weak_ref = copy._weak_ref; - if (weak_ref != nullptr && !weak_ref->was_deleted()) { + if (weak_ref != nullptr/* && !weak_ref->was_deleted()*/) { weak_ref->ref(); _weak_ref = weak_ref; } else { @@ -180,6 +210,61 @@ reassign(WeakPointerToBase &&from) noexcept { } } +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void WeakPointerToBase:: +reassign(const WeakPointerToBase ©) { + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)copy._void_ptr; + + if (new_ptr != (To *)_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; + WeakReferenceList *new_ref = copy._weak_ref; + _void_ptr = new_ptr; + _weak_ref = new_ref; + + if (new_ref != nullptr) { + new_ref->ref(); + } + + // Now remove the old reference. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void WeakPointerToBase:: +reassign(WeakPointerToBase &&from) noexcept { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)this->_weak_ref; + + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)from._void_ptr; + + this->_void_ptr = new_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; + + // Now delete the old pointer. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + /** * Ensures that the MemoryUsage record for the pointer has the right type of * object, if we know the type ourselves. @@ -201,8 +286,35 @@ update_type(To *ptr) { #endif // DO_MEMORY_USAGE } +/** + * A thread-safe way to access the underlying pointer; will only write to the + * given pointer if the underlying pointer has not yet been deleted and is not + * null. Note that it may leave the pointer unassigned even if was_deleted() + * still returns true, which can occur if the object has reached reference + * count 0 and is about to be destroyed. + */ +template +INLINE void WeakPointerToBase:: +lock_into(PointerToBase &locked) const { + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + weak_ref->_lock.lock(); + if (!weak_ref->was_deleted()) { + // We also need to check that the reference count is not zero (which can + // happen if the object is currently being destructed), since that could + // cause double deletion. + To *plain_ptr = (To *)WeakPointerToBase::_void_ptr; + if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { + // It is valid and we successfully grabbed a reference. Assign it, + // noting we have already incremented the reference count. + locked._void_ptr = plain_ptr; + } + } + weak_ref->_lock.unlock(); + } +} + #ifndef CPPPARSER -#ifndef WIN32_VC /** * */ @@ -338,7 +450,11 @@ operator >= (std::nullptr_t) const { } /** - * + * Returns true if both pointers have the same raw pointer value. For this to + * be meaningful, neither pointer may have expired, since if one has expired + * while the other was allocated at the expired pointer's memory address, this + * comparison will be true even though they didn't refer to the same object. + * @see owner_before */ template INLINE bool WeakPointerToBase:: @@ -347,7 +463,7 @@ operator == (const WeakPointerToBase &other) const { } /** - * + * @see operator == */ template INLINE bool WeakPointerToBase:: @@ -356,7 +472,8 @@ operator != (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -365,7 +482,8 @@ operator > (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -374,7 +492,8 @@ operator <= (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -383,7 +502,7 @@ operator >= (const WeakPointerToBase &other) const { } /** - * + * Returns true if both pointers point to the same object. */ template INLINE bool WeakPointerToBase:: @@ -392,7 +511,7 @@ operator == (const PointerToBase &other) const { } /** - * + * Returns false if both pointers point to the same object. */ template INLINE bool WeakPointerToBase:: @@ -426,7 +545,6 @@ INLINE bool WeakPointerToBase:: operator >= (const PointerToBase &other) const { return (To *)_void_ptr >= (To *)((WeakPointerToBase *)&other)->_void_ptr; } -#endif // WIN32_VC /** * @@ -447,7 +565,8 @@ operator < (std::nullptr_t) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -466,6 +585,35 @@ operator < (const PointerToBase &other) const { #endif // CPPPARSER +/** + * Defines an ordering that is guaranteed to remain consistent even after the + * weak pointers have expired. This may result in two pointers with the same + * get_orig() value comparing unequal if one of them is a new object that was + * allocated at the same memory address as the older, expired pointer. + */ +template +template +INLINE bool WeakPointerToBase:: +owner_before(const WeakPointerToBase &other) const noexcept { + return _weak_ref < other._weak_ref; +} + +/** + * Defines an ordering that is guaranteed to remain consistent even after this + * weak pointer has expired. This may result in two pointers with the same + * get_orig() value comparing unequal if one of them is a new object that was + * allocated at the same memory address as the older, expired pointer. + */ +template +template +INLINE bool WeakPointerToBase:: +owner_before(const PointerToBase &other) const noexcept { + // Unfortunately, this may needlessly cause a control block to be allocated, + // but I do not see a more efficient solution. + return (other._void_ptr != nullptr) && + (_void_ptr == nullptr || _weak_ref < ((const Y *)other._void_ptr)->get_weak_list()); +} + /** * A convenient way to set the PointerTo object to NULL. (Assignment to a NULL * pointer also works, of course.) @@ -507,9 +655,17 @@ template INLINE void WeakPointerToBase:: output(std::ostream &out) const { out << _void_ptr; - if (was_deleted()) { - out << ":deleted"; - } else if (_void_ptr != nullptr) { - out << ":" << ((To *)_void_ptr)->get_ref_count(); + + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + weak_ref->_lock.lock(); + if (!weak_ref->was_deleted()) { + out << ":" << ((To *)_void_ptr)->get_ref_count(); + } else { + out << ":deleted"; + } + weak_ref->_lock.unlock(); + } else { + out << ":invalid"; } } diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index b1267c448a..291cd587e4 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -28,19 +28,31 @@ public: typedef T To; protected: - INLINE WeakPointerToBase(To *ptr); + constexpr WeakPointerToBase() noexcept = default; + INLINE explicit WeakPointerToBase(To *ptr); INLINE WeakPointerToBase(const PointerToBase ©); INLINE WeakPointerToBase(const WeakPointerToBase ©); INLINE WeakPointerToBase(WeakPointerToBase &&from) noexcept; + template + INLINE WeakPointerToBase(const WeakPointerToBase &r); + template + INLINE WeakPointerToBase(WeakPointerToBase &&r) noexcept; + INLINE ~WeakPointerToBase(); void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(const WeakPointerToBase ©); INLINE void reassign(WeakPointerToBase &&from) noexcept; + template + INLINE void reassign(const WeakPointerToBase ©); + template + INLINE void reassign(WeakPointerToBase &&from) noexcept; INLINE void update_type(To *ptr); + INLINE void lock_into(PointerToBase &locked) const; + // No assignment or retrieval functions are declared in WeakPointerToBase, // because we will have to specialize on const vs. non-const later. @@ -48,7 +60,6 @@ public: // These comparison functions are common to all things PointerTo, so they're // defined up here. #ifndef CPPPARSER -#ifndef WIN32_VC INLINE bool operator == (const To *other) const; INLINE bool operator != (const To *other) const; INLINE bool operator > (const To *other) const; @@ -77,13 +88,21 @@ public: INLINE bool operator > (const PointerToBase &other) const; INLINE bool operator <= (const PointerToBase &other) const; INLINE bool operator >= (const PointerToBase &other) const; -#endif // WIN32_VC + INLINE bool operator < (const To *other) const; INLINE bool operator < (std::nullptr_t) const; INLINE bool operator < (const WeakPointerToBase &other) const; INLINE bool operator < (const PointerToBase &other) const; #endif // CPPPARSER + template + INLINE bool owner_before(const WeakPointerToBase &other) const noexcept; + template + INLINE bool owner_before(const PointerToBase &other) const noexcept; + + // This is needed to be able to access the privates of other instantiations. + template friend class WeakPointerToBase; + PUBLISHED: INLINE void clear(); INLINE void refresh() const; diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index 120836510d..83253c7921 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -11,13 +11,6 @@ * @date 2004-09-27 */ -/** - * - */ -INLINE WeakPointerToVoid:: -WeakPointerToVoid() : _weak_ref(nullptr) { -} - /** * Sets a callback that will be made when the pointer is deleted. Does * nothing if this is a null pointer. @@ -47,7 +40,11 @@ remove_callback(WeakPointerCallback *callback) const { /** * Returns true if the object we are pointing to has been deleted, false - * otherwise. + * otherwise. If this returns true, it means that the pointer can not yet be + * reused, but it does not guarantee that it can be safely accessed. See the + * lock() method for a safe way to access the underlying pointer. + * + * This will always return true for a null pointer, unlike is_valid_pointer(). */ INLINE bool WeakPointerToVoid:: was_deleted() const { @@ -56,7 +53,7 @@ was_deleted() const { /** * Returns true if the pointer is not null and the object has not been - * deleted. + * deleted. See was_deleted() for caveats. */ INLINE bool WeakPointerToVoid:: is_valid_pointer() const { diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index 56ace2dcb2..3eadfffc4d 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_EXPRESS WeakPointerToVoid : public PointerToVoid { protected: - INLINE WeakPointerToVoid(); + constexpr WeakPointerToVoid() noexcept = default; public: INLINE void add_callback(WeakPointerCallback *callback) const; @@ -36,7 +36,7 @@ PUBLISHED: INLINE bool is_valid_pointer() const; protected: - mutable WeakReferenceList *_weak_ref; + mutable WeakReferenceList *_weak_ref = nullptr; }; #include "weakPointerToVoid.I" diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index 29255a5e74..b96091c299 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -21,6 +21,8 @@ #endif #include +using std::string; + /** * Sets the registry key to the indicated value as a string. The supplied * string value is automatically converted from whatever encoding is set by @@ -32,7 +34,7 @@ set_string_value(const string &key, const string &name, const string &value, WindowsRegistry::RegLevel rl) { TextEncoder encoder; - wstring wvalue = encoder.decode_text(value); + std::wstring wvalue = encoder.decode_text(value); // Now convert the string to Windows' idea of the correct wide-char // encoding, so we can store it in the registry. This might well be the @@ -152,7 +154,7 @@ get_string_value(const string &key, const string &name, data.data(), data.length(), wide_result, wide_result_len); - wstring wdata(wide_result, wide_result_len); + std::wstring wdata(wide_result, wide_result_len); TextEncoder encoder; string result = encoder.encode_wtext(wdata); diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index c037252895..877254918d 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -18,6 +18,10 @@ #include "pnotify.h" #include "config_express.h" +using std::ios; +using std::streamoff; +using std::streampos; + #if !defined(USE_MEMORY_NOWRAPPERS) && !defined(CPPPARSER) // Define functions that hook zlib into panda's memory allocation system. static void * @@ -69,7 +73,7 @@ ZStreamBuf:: * */ void ZStreamBuf:: -open_read(istream *source, bool owns_source) { +open_read(std::istream *source, bool owns_source) { _source = source; _owns_source = owns_source; @@ -120,7 +124,7 @@ close_read() { * */ void ZStreamBuf:: -open_write(ostream *dest, bool owns_dest, int compression_level) { +open_write(std::ostream *dest, bool owns_dest, int compression_level) { _dest = dest; _owns_dest = owns_dest; @@ -392,7 +396,7 @@ write_chars(const char *start, size_t length, int flush) { */ void ZStreamBuf:: show_zlib_error(const char *function, int error_code, z_stream &z) { - stringstream error_line; + std::stringstream error_line; error_line << "zlib error in " << function << ": "; diff --git a/panda/src/express/zStreamBuf.h b/panda/src/express/zStreamBuf.h index 35446090db..3dadd1543d 100644 --- a/panda/src/express/zStreamBuf.h +++ b/panda/src/express/zStreamBuf.h @@ -24,7 +24,7 @@ /** * The streambuf object that implements IDecompressStream and OCompressStream. */ -class EXPCL_PANDA_DOWNLOADER ZStreamBuf : public std::streambuf { +class EXPCL_PANDA_EXPRESS ZStreamBuf : public std::streambuf { public: ZStreamBuf(); virtual ~ZStreamBuf(); diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index dd5d49cc59..621de7fe8a 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -307,7 +307,7 @@ reload_buffer() { // First, let's fill the codec's input buffer with as many packets as it'll // take: - int ret; + int ret = 0; while (_packet->data != nullptr) { ret = avcodec_send_packet(_audio_ctx, _packet); diff --git a/panda/src/ffmpeg/ffmpegVideo.cxx b/panda/src/ffmpeg/ffmpegVideo.cxx index c12892fe47..3cc7105fdd 100644 --- a/panda/src/ffmpeg/ffmpegVideo.cxx +++ b/panda/src/ffmpeg/ffmpegVideo.cxx @@ -60,7 +60,7 @@ open() { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; return nullptr; } else { - return result.p(); + return result; } } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index b7b67a8ecf..f8c2163b73 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -112,13 +112,25 @@ init_from(FfmpegVideo *source) { // Check if we got an alpha format. Please note that some video codecs // (eg. libvpx) change the pix_fmt after decoding the first frame, which is // why we didn't do this earlier. - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); - if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { - _num_components = 4; - _pixel_format = (int)AV_PIX_FMT_BGRA; - } else { - _num_components = 3; - _pixel_format = (int)AV_PIX_FMT_BGR24; + switch (_video_ctx->pix_fmt) { + case AV_PIX_FMT_GRAY8: + _num_components = 1; + _pixel_format = (int)AV_PIX_FMT_GRAY8; + break; + case AV_PIX_FMT_Y400A: // aka AV_PIX_FMT_YA8 + _num_components = 2; + _pixel_format = (int)AV_PIX_FMT_Y400A; + break; + default: + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); + if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { + _num_components = 4; + _pixel_format = (int)AV_PIX_FMT_BGRA; + } else { + _num_components = 3; + _pixel_format = (int)AV_PIX_FMT_BGR24; + } + break; } #ifdef HAVE_SWSCALE @@ -247,7 +259,7 @@ start_thread() { if (_thread_status == TS_stopped && _max_readahead_frames > 0) { // Get a unique name for the thread's sync name. - ostringstream strm; + std::ostringstream strm; strm << (void *)this; _sync_name = strm.str(); @@ -325,7 +337,7 @@ set_time(double timestamp, int loop_count) { } // No point in trying to position before the first frame. - frame = max(frame, _initial_dts); + frame = std::max(frame, _initial_dts); if (ffmpeg_cat.is_spam() && frame != _current_frame) { ffmpeg_cat.spam() @@ -434,7 +446,7 @@ fetch_buffer() { << " at frame " << _current_frame << ", returning NULL\n"; } } - return frame.p(); + return frame; } /** @@ -443,7 +455,7 @@ fetch_buffer() { PT(MovieVideoCursor::Buffer) FfmpegVideoCursor:: make_new_buffer() { PT(FfmpegBuffer) frame = new FfmpegBuffer(size_x() * size_y() * get_num_components(), _video_timebase); - return frame.p(); + return frame; } /** diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 6acf6debcd..3fd88f640f 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -17,6 +17,9 @@ #include "ffmpegVirtualFile.h" #include "virtualFileSystem.h" +using std::streampos; +using std::streamsize; + extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" @@ -202,7 +205,7 @@ int FfmpegVirtualFile:: read_packet(void *opaque, uint8_t *buf, int size) { streampos ssize = (streampos)size; FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; - istream *in = self->_in; + std::istream *in = self->_in; // Since we may be simulating a subset of the opened stream, don't allow it // to read past the "end". @@ -228,21 +231,21 @@ read_packet(void *opaque, uint8_t *buf, int size) { int64_t FfmpegVirtualFile:: seek(void *opaque, int64_t pos, int whence) { FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; - istream *in = self->_in; + std::istream *in = self->_in; switch (whence) { case SEEK_SET: - in->seekg(self->_start + (streampos)pos, ios::beg); + in->seekg(self->_start + (streampos)pos, std::ios::beg); break; case SEEK_CUR: - in->seekg(pos, ios::cur); + in->seekg(pos, std::ios::cur); break; case SEEK_END: // For seeks relative to the end, we actually compute the end based on // _start + _size, and then use ios::beg. - in->seekg(self->_start + (streampos)self->_size + (streampos)pos, ios::beg); + in->seekg(self->_start + (streampos)self->_size + (streampos)pos, std::ios::beg); break; case AVSEEK_SIZE: diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 9179aa02f4..706ff4995d 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -37,6 +37,8 @@ #endif #endif +using std::string; + LoaderOptions PandaFramework::_loader_options; /** @@ -80,7 +82,7 @@ PandaFramework:: * control parameters. */ void PandaFramework:: -open_framework(int &argc, char **&argv) { +open_framework() { if (_is_open) { return; } @@ -160,6 +162,14 @@ open_framework(int &argc, char **&argv) { _event_handler.add_hook("window-event", event_window_event, this); } +/** + * @deprecated See the version of open_framework() without arguments. + */ +void PandaFramework:: +open_framework(int &argc, char **&argv) { + open_framework(); +} + /** * Should be called at the end of an application to close Panda. This is * optional, as the destructor will do the same thing. @@ -535,7 +545,7 @@ get_models() { * Reports the currently measured average frame rate to the indicated ostream. */ void PandaFramework:: -report_frame_rate(ostream &out) const { +report_frame_rate(std::ostream &out) const { double now = ClockObject::get_global_clock()->get_frame_time(); double delta = now - _start_time; @@ -1175,10 +1185,10 @@ event_arrow_right(const Event *, void *data) { void PandaFramework:: event_S(const Event *, void *) { #ifdef DO_PSTATS - nout << "Connecting to stats host" << endl; + nout << "Connecting to stats host" << std::endl; PStatClient::connect(); #else - nout << "Stats host not supported." << endl; + nout << "Stats host not supported." << std::endl; #endif } @@ -1219,7 +1229,7 @@ event_f9(const Event *event, void *data) { self->_screenshot_text.set_scale(0.06); self->_screenshot_text.set_pos(0.0, 0.0, -0.7); self->_screenshot_text.reparent_to(wf->get_aspect_2d()); - cout << "Screenshot saved: " + output_text + "\n"; + std::cout << "Screenshot saved: " + output_text + "\n"; // Set a do-later to remove the text in 3 seconds. self->_task_mgr.remove(self->_task_mgr.find_tasks("clear_text")); @@ -1273,7 +1283,7 @@ event_question(const Event *event, void *data) { } else { // Build up a string to display. - ostringstream help; + std::ostringstream help; KeyDefinitions::const_iterator ki; for (ki = self->_key_definitions.begin(); ki != self->_key_definitions.end(); @@ -1294,7 +1304,7 @@ event_question(const Event *event, void *data) { LVecBase4 frame = text_node->get_frame_actual(); PN_stdfloat height = frame[3] - frame[2]; - PN_stdfloat scale = min(0.06, 1.8 / height); + PN_stdfloat scale = std::min(0.06, 1.8 / height); self->_help_text.set_scale(scale); PN_stdfloat pos_scale = scale / -2.0; diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index ef570a6c96..3c901d8e27 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -40,6 +40,7 @@ public: PandaFramework(); virtual ~PandaFramework(); + void open_framework(); void open_framework(int &argc, char **&argv); void close_framework(); diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 3b1cb1807c..db49ee97e8 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -62,6 +62,10 @@ // shuttle_controls.bam_src.c. #include "shuttle_controls.bam_src.c" +using std::istringstream; +using std::ostringstream; +using std::string; + // This number is chosen arbitrarily to override any settings in model files. static const int override_priority = 100; @@ -514,15 +518,15 @@ center_trackball(const NodePath &object) { if (lens != nullptr) { LVecBase2 fov = lens->get_fov(); - distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f)); + distance = radius / ctan(deg_2_rad(std::min(fov[0], fov[1]) / 2.0f)); // Ensure the far plane is far enough back to see the entire object. PN_stdfloat ideal_far_plane = distance + radius * 1.5; - lens->set_far(max(lens->get_default_far(), ideal_far_plane)); + lens->set_far(std::max(lens->get_default_far(), ideal_far_plane)); // And that the near plane is far enough forward. PN_stdfloat ideal_near_plane = distance - radius; - lens->set_near(min(lens->get_default_near(), ideal_near_plane)); + lens->set_near(std::min(lens->get_default_near(), ideal_near_plane)); } _trackball->set_origin(center); @@ -1330,7 +1334,7 @@ load_image_as_model(const Filename &filename) { card_node->add_geom(geom); - return card_node.p(); + return card_node; } /** diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index d70b2a4a1a..3a9b2fea6a 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -508,7 +508,7 @@ issue_parameters(int altered) { if (GLCAT.is_spam()) { GLCAT.spam() << "Setting uniforms for " << _shader->get_filename() - << " (altered 0x" << hex << altered << dec << ")\n"; + << " (altered 0x" << std::hex << altered << std::dec << ")\n"; } // We have no way to track modifications to PTAs, so we assume that they are @@ -525,7 +525,7 @@ issue_parameters(int altered) { } // Check if the size of the shader input and ptr_data match - int input_size = spec._dim[0] * spec._dim[1] * spec._dim[2]; + size_t input_size = spec._dim[0] * spec._dim[1] * spec._dim[2]; // dimension is negative only if the parameter had the (deprecated)k_ // prefix. @@ -648,6 +648,7 @@ issue_parameters(int altered) { continue; case Shader::SPT_int: + case Shader::SPT_uint: switch (spec._info._class) { case Shader::SAC_scalar: cgSetParameter1iv(p, (int*)ptr_data->_ptr); @@ -737,7 +738,7 @@ update_transform_table(const TransformTable *table) { int i = 0; if (table != nullptr) { - int num_transforms = min(_transform_table_size, (long)table->get_num_transforms()); + int num_transforms = std::min(_transform_table_size, (long)table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE LMatrix4 matrix; @@ -765,7 +766,7 @@ update_slider_table(const SliderTable *table) { memset(sliders, 0, _slider_table_size * 4); if (table != nullptr) { - int num_sliders = min(_slider_table_size, (long)table->get_num_sliders()); + int num_sliders = std::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(); } @@ -880,21 +881,25 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // limited in the options we can set. GLenum type = _glgsg->get_numeric_type(numeric_type); if (p >= 0) { - max_p = max(max_p, (GLuint)p + 1); + max_p = std::max(max_p, (GLuint)p + 1); _glgsg->enable_vertex_attrib_array(p); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(p, num_values, type, - stride, client_pointer); - } else if (numeric_type == GeomEnums::NT_packed_dabc) { + 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 { + } else if (bind._numeric_type == Shader::SPT_float || + numeric_type == GeomEnums::NT_float32) { _glgsg->_glVertexAttribPointer(p, num_values, type, normalized, stride, client_pointer); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(p, num_values, type, + stride, client_pointer); + } else { + _glgsg->_glVertexAttribIPointer(p, num_values, type, + stride, client_pointer); } if (divisor > 0) { @@ -951,10 +956,12 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // So, we work around this by just binding something silly to 0. // This breaks flat colors, but it's better than invisible objects? _glgsg->enable_vertex_attrib_array(0); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0); - } else { + if (bind._numeric_type == Shader::SPT_float) { _glgsg->_glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(0, 4, GL_DOUBLE, 0, 0); + } else { + _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0); } } else if (p >= 0) { diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index fae758f2c8..923b8e5b76 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -104,7 +104,7 @@ munge_format_impl(const GeomVertexFormat *orig, } // Convert packed formats that OpenGL may not understand. - for (int i = 0; i < orig->get_num_columns(); ++i) { + for (size_t i = 0; i < orig->get_num_columns(); ++i) { const GeomVertexColumn *column = orig->get_column(i); int array = orig->get_array_with(column->get_name()); @@ -182,7 +182,7 @@ munge_format_impl(const GeomVertexFormat *orig, if ((_flags & F_parallel_arrays) != 0) { // Split out the interleaved array into n parallel arrays. new_format = new GeomVertexFormat; - for (int i = 0; i < format->get_num_columns(); ++i) { + for (size_t i = 0; i < format->get_num_columns(); ++i) { const GeomVertexColumn *column = format->get_column(i); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column(column->get_name(), column->get_num_components(), @@ -290,7 +290,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } // Convert packed formats that OpenGL may not understand. - for (int i = 0; i < orig->get_num_columns(); ++i) { + for (size_t i = 0; i < orig->get_num_columns(); ++i) { const GeomVertexColumn *column = orig->get_column(i); int array = orig->get_array_with(column->get_name()); @@ -317,7 +317,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { if ((_flags & F_parallel_arrays) != 0) { // Split out the interleaved array into n parallel arrays. new_format = new GeomVertexFormat; - for (int i = 0; i < format->get_num_columns(); ++i) { + for (size_t i = 0; i < format->get_num_columns(); ++i) { const GeomVertexColumn *column = format->get_column(i); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column(column->get_name(), column->get_num_components(), @@ -396,7 +396,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { // Now go through the remaining arrays and make sure they are tightly // packed (with the column alignment restrictions). If not, repack them. - for (int i = 0; i < new_format->get_num_arrays(); ++i) { + for (size_t i = 0; i < new_format->get_num_arrays(); ++i) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat; @@ -426,11 +426,17 @@ premunge_format_impl(const GeomVertexFormat *orig) { int CLP(GeomMunger):: compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; - if (_texture != om->_texture) { - return _texture < om->_texture ? -1 : 1; + if (_texture.owner_before(om->_texture)) { + return -1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (om->_texture.owner_before(_texture)) { + return 1; + } + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } if (_flags != om->_flags) { return _flags < om->_flags ? -1 : 1; @@ -447,11 +453,17 @@ compare_to_impl(const GeomMunger *other) const { int CLP(GeomMunger):: geom_compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; - if (_texture != om->_texture) { - return _texture < om->_texture ? -1 : 1; + if (_texture.owner_before(om->_texture)) { + return -1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (om->_texture.owner_before(_texture)) { + return 1; + } + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } if (_flags != om->_flags) { return _flags < om->_flags ? -1 : 1; diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 8d77e56086..66a9e6d407 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -13,6 +13,9 @@ #include "depthWriteAttrib.h" +using std::max; +using std::min; + TypeHandle CLP(GraphicsBuffer)::_type_handle; /** @@ -20,7 +23,7 @@ TypeHandle CLP(GraphicsBuffer)::_type_handle; */ CLP(GraphicsBuffer):: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -67,7 +70,7 @@ CLP(GraphicsBuffer):: // unshare all buffers that are sharing this object's depth buffer { CLP(GraphicsBuffer) *graphics_buffer; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; graphics_buffer_iterator = _shared_depth_buffer_list.begin(); while (graphics_buffer_iterator != _shared_depth_buffer_list.end()) { @@ -386,7 +389,7 @@ rebuild_bitplanes() { _rb_size_z = 1; _rb_data_size_bytes = 0; - int num_fbos = 1; + size_t num_fbos = 1; // These variables indicate what should be bound to each bitplane. Texture *attach[RTP_COUNT]; @@ -455,7 +458,7 @@ rebuild_bitplanes() { } if (tex->get_z_size() > 1) { - num_fbos = max(num_fbos, tex->get_z_size()); + num_fbos = max(num_fbos, (size_t)tex->get_z_size()); } // Assign the texture to this slot. @@ -495,7 +498,7 @@ rebuild_bitplanes() { } else if (attach[RTP_depth_stencil] != nullptr && attach[RTP_depth] == nullptr) { // 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]); + std::swap(attach[RTP_depth], attach[RTP_depth_stencil]); } // Knowing this, we can already be a tiny bit more accurate about the @@ -520,13 +523,13 @@ rebuild_bitplanes() { if (num_fbos > _fbo.size()) { // Generate more FBO handles. - int start = _fbo.size(); + size_t start = _fbo.size(); GLuint zero = 0; _fbo.resize(num_fbos, zero); glgsg->_glGenFramebuffers(num_fbos - start, &_fbo[start]); } - for (int layer = 0; layer < num_fbos; ++layer) { + for (int layer = 0; layer < (int)num_fbos; ++layer) { // Bind the FBO if (_fbo[layer] == 0) { report_my_gl_errors(); @@ -537,9 +540,9 @@ rebuild_bitplanes() { if (glgsg->_use_object_labels) { // Assign a label for OpenGL to use when displaying debug messages. if (num_fbos > 1) { - ostringstream strm; + std::ostringstream strm; strm << _name << '[' << layer << ']'; - string name = strm.str(); + std::string name = strm.str(); glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], name.size(), name.data()); } else { glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data()); @@ -861,14 +864,22 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, case RTP_depth_stencil: if (_fb_properties.get_depth_bits() > 24 || _fb_properties.get_float_depth()) { - gl_format = GL_DEPTH32F_STENCIL8; + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH32F_STENCIL8; + } else { + gl_format = GL_DEPTH32F_STENCIL8_NV; + } } else { gl_format = GL_DEPTH24_STENCIL8; } break; case RTP_depth: if (_fb_properties.get_float_depth()) { - gl_format = GL_DEPTH_COMPONENT32F; + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH_COMPONENT32F; + } else { + gl_format = GL_DEPTH_COMPONENT32F_NV; + } } else if (_fb_properties.get_depth_bits() > 24) { gl_format = GL_DEPTH_COMPONENT32; } else if (_fb_properties.get_depth_bits() > 16) { @@ -978,6 +989,23 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, GLint depth_size = 0; 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); + +#ifndef OPENGLES + // Are we getting only 24 bits of depth when we requested 32? It may be + // because GL_DEPTH_COMPONENT32 is not a required format, while 32F is. + if (gl_format == GL_DEPTH_COMPONENT32 && depth_size < 32) { + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH_COMPONENT32F; + } else { + gl_format = GL_DEPTH_COMPONENT32F_NV; + } + 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_float_depth(true); + } +#endif + _fb_properties.set_depth_bits(depth_size); _rb_data_size_bytes += _rb_size_x * _rb_size_y * (depth_size / 8); @@ -1294,7 +1322,7 @@ set_size(int x, int y) { */ void CLP(GraphicsBuffer):: select_target_tex_page(int page) { - nassertv(page >= 0 && page < _fbo.size()); + nassertv(page >= 0 && (size_t)page < _fbo.size()); CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); @@ -1571,10 +1599,10 @@ close_buffer() { report_my_gl_errors(); // Delete the FBO itself. - for (int i = 0; i < _fbo.size(); ++i) { - glgsg->_glDeleteFramebuffers(1, &_fbo[i]); + if (!_fbo.empty()) { + glgsg->_glDeleteFramebuffers(_fbo.size(), _fbo.data()); + _fbo.clear(); } - _fbo.clear(); report_my_gl_errors(); @@ -1775,7 +1803,7 @@ resolve_multisamples() { if (_shared_depth_buffer) { CLP(GraphicsBuffer) *graphics_buffer = nullptr; //CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; int max_sort_order = 0; for (graphics_buffer_iterator = _shared_depth_buffer_list.begin(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 1e4c2bb530..fb22fdb644 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -73,6 +73,13 @@ #include +using std::dec; +using std::endl; +using std::hex; +using std::max; +using std::min; +using std::string; + TypeHandle CLP(GraphicsStateGuardian)::_type_handle; PStatCollector CLP(GraphicsStateGuardian)::_load_display_list_pcollector("Draw:Transfer data:Display lists"); @@ -85,10 +92,6 @@ 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"); -#ifndef OPENGLES_1 -PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = nullptr; -#endif - // The following noop functions are assigned to the corresponding glext // function pointers in the class, in case the functions are not defined by // the GL, just so it will always be safe to call the extension functions. @@ -181,6 +184,48 @@ static const string default_vshader = " color = p3d_Color * p3d_ColorScale;\n" "}\n"; +#ifndef OPENGLES +// This version of the shader is used if vertices-float64 is enabled. +static const string default_vshader_fp64 = +#ifdef __APPLE__ + "#version 150\n" +#else + "#version 130\n" +#endif + "#extension GL_ARB_vertex_attrib_64bit : require\n" + "#extension GL_ARB_gpu_shader_fp64 : require\n" + "in dvec3 p3d_Vertex;\n" + "in vec4 p3d_Color;\n" + "in dvec2 p3d_MultiTexCoord0;\n" + "out vec2 texcoord;\n" + "out vec4 color;\n" + "uniform mat4 p3d_ModelViewMatrix;\n" + "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform vec4 p3d_ColorScale;\n" + "void main(void) {\n" // Apply proj & modelview in two steps, more precise + " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" + " texcoord = vec2(p3d_MultiTexCoord0);\n" + " color = p3d_Color * p3d_ColorScale;\n" + "}\n"; + +// Same as above, but for OpenGL 4.1. +static const string default_vshader_fp64_gl41 = + "#version 410\n" + "in dvec3 p3d_Vertex;\n" + "in vec4 p3d_Color;\n" + "in dvec2 p3d_MultiTexCoord0;\n" + "out vec2 texcoord;\n" + "out vec4 color;\n" + "uniform mat4 p3d_ModelViewMatrix;\n" + "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform vec4 p3d_ColorScale;\n" + "void main(void) {\n" // Apply proj & modelview in two steps, more precise + " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" + " texcoord = vec2(p3d_MultiTexCoord0);\n" + " color = p3d_Color * p3d_ColorScale;\n" + "}\n"; +#endif + static const string default_fshader = #ifndef OPENGLES #ifdef __APPLE__ // Apple's GL 3.2 contexts require at least GLSL 1.50. @@ -606,6 +651,8 @@ reset() { get_extension_func("glDebugMessageControlARB"); _supports_debug = true; #endif + } else { + _supports_debug = false; } if (_supports_debug) { @@ -1690,6 +1737,14 @@ reset() { get_extension_func("glUniform3iv"); _glUniform4iv = (PFNGLUNIFORM4IVPROC) get_extension_func("glUniform4iv"); + _glUniform1uiv = (PFNGLUNIFORM1UIVPROC) + get_extension_func("glUniform1uiv"); + _glUniform2uiv = (PFNGLUNIFORM2UIVPROC) + get_extension_func("glUniform2uiv"); + _glUniform3uiv = (PFNGLUNIFORM3UIVPROC) + get_extension_func("glUniform3uiv"); + _glUniform4uiv = (PFNGLUNIFORM4UIVPROC) + get_extension_func("glUniform4uiv"); _glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) get_extension_func("glUniformMatrix3fv"); _glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) @@ -1768,6 +1823,10 @@ reset() { _glUniform2fv = glUniform2fv; _glUniform3fv = glUniform3fv; _glUniform4fv = glUniform4fv; + _glUniform1iv = glUniform1iv; + _glUniform2iv = glUniform2iv; + _glUniform3iv = glUniform3iv; + _glUniform4iv = glUniform4iv; _glUniformMatrix3fv = glUniformMatrix3fv; _glUniformMatrix4fv = glUniformMatrix4fv; _glValidateProgram = glValidateProgram; @@ -1818,7 +1877,17 @@ reset() { // shader just outputs a red color, indicating that something went wrong. #ifndef OPENGLES_1 if (_default_shader == nullptr && !has_fixed_function_pipeline()) { - _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); +#ifndef OPENGLES + bool use_float64 = vertices_float64; + if (use_float64 && is_at_least_gl_version(4, 1)) { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader_fp64_gl41, default_fshader); + } else if (use_float64 && has_extension("GL_ARB_vertex_attrib_64bit")) { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader_fp64, default_fshader); + } else +#endif + { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); + } } #endif @@ -2217,8 +2286,10 @@ reset() { if (is_at_least_gl_version(4, 5) || has_extension("GL_ARB_direct_state_access")) { _glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) get_extension_func("glGenerateTextureMipmap"); + + _supports_dsa = true; } else { - _glGenerateTextureMipmap = nullptr; + _supports_dsa = false; } #endif @@ -2761,7 +2832,9 @@ reset() { // Check availability of anisotropic texture filtering. _supports_anisotropy = false; _max_anisotropy = 1.0; - if (has_extension("GL_EXT_texture_filter_anisotropic")) { + if (is_at_least_gl_version(4, 6) || + has_extension("GL_EXT_texture_filter_anisotropic") || + has_extension("GL_ARB_texture_filter_anisotropic")) { GLfloat max_anisotropy; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); _max_anisotropy = (PN_stdfloat)max_anisotropy; @@ -2988,6 +3061,50 @@ reset() { } #endif + // Set depth range from zero to one if requested. +#ifndef OPENGLES + _use_depth_zero_to_one = false; + _use_remapped_depth_range = false; + + if (gl_depth_zero_to_one) { + if (is_at_least_gl_version(4, 5) || has_extension("GL_ARB_clip_control")) { + PFNGLCLIPCONTROLPROC pglClipControl = + (PFNGLCLIPCONTROLPROC)get_extension_func("glClipControl"); + + if (pglClipControl != nullptr) { + pglClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); + _use_depth_zero_to_one = true; + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Set zero-to-one depth using glClipControl\n"; + } + } + }/* else if (has_extension("GL_NV_depth_buffer_float")) { + // Alternatively, all GeForce 8+ and even some AMD drivers support this + // extension, which (unlike the core glDepthRange, which clamps its + // input parameters) can compensate for the built-in depth remapping. + _glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)get_extension_func("glDepthRangedNV"); + + if (_glDepthRangedNV != nullptr) { + _glDepthRangedNV(-1.0, 1.0); + _use_depth_zero_to_one = true; + _use_remapped_depth_range = true; + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Set zero-to-one depth using glDepthRangedNV\n"; + } + } + }*/ + + if (!_use_depth_zero_to_one) { + GLCAT.warning() + << "Zero-to-one depth was requested, but driver does not support it.\n"; + } + } +#endif + // Set up all the enableddisabled flags to GL's known initial values: // everything off. _multisample_mode = 0; @@ -3124,7 +3241,7 @@ reset() { if (GLCAT.is_debug()) { if (_supports_get_program_binary) { GLCAT.debug() - << "Supported shader binary formats:\n"; + << "Supported program binary formats:\n"; GLCAT.debug() << " "; pset::const_iterator it; @@ -3136,7 +3253,7 @@ reset() { } GLCAT.debug(false) << "\n"; } else { - GLCAT.debug() << "No shader binary formats supported.\n"; + GLCAT.debug() << "No program binary formats supported.\n"; } } #endif @@ -3637,6 +3754,19 @@ calc_projection_mat(const Lens *lens) { lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); +#ifndef OPENGLES + if (_use_depth_zero_to_one) { + // If we requested that the OpenGL NDC Z goes from zero to one like in + // Direct3D, we need to scale the projection matrix, which assumes -1..1. + static const LMatrix4 rescale_mat + (1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 0.5, 0, + 0, 0, 0.5, 1); + result *= rescale_mat; + } +#endif + if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the projection // matrix. @@ -4367,9 +4497,9 @@ unbind_buffers() { if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) { _glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr); } else { - for (int i = 0; i < _current_vertex_buffers.size(); ++i) { + for (size_t i = 0; i < _current_vertex_buffers.size(); ++i) { if (_current_vertex_buffers[i] != 0) { - _glBindVertexBuffer(i, 0, 0, 0); + _glBindVertexBuffer((GLuint)i, 0, 0, 0); } } } @@ -6323,10 +6453,11 @@ prepare_shader_buffer(ShaderBuffer *data) { if (_use_object_labels) { string name = data->get_name(); - _glObjectLabel(GL_SHADER_STORAGE_BUFFER, gbc->_index, name.size(), name.data()); + _glObjectLabel(GL_BUFFER, gbc->_index, name.size(), name.data()); } - uint64_t num_bytes = data->get_data_size_bytes(); + // Some drivers require the buffer to be padded to 16 byte boundary. + uint64_t num_bytes = (data->get_data_size_bytes() + 15u) & ~15u; if (_supports_buffer_storage) { _glBufferStorage(GL_SHADER_STORAGE_BUFFER, num_bytes, data->get_initial_data(), 0); } else { @@ -7443,7 +7574,13 @@ do_issue_depth_offset() { glDepthRangef((GLclampf)min_value, (GLclampf)max_value); #else // Mainline OpenGL uses a double-precision call. - glDepthRange((GLclampd)min_value, (GLclampd)max_value); + if (!_use_remapped_depth_range) { + glDepthRange((GLclampd)min_value, (GLclampd)max_value); + } else { + // If we have a remapped depth range, we should adjust the values to range + // from -1 to 1. We need to use an NV extension to pass unclamped values. + _glDepthRangedNV(min_value * 2.0 - 1.0, max_value * 2.0 - 1.0); + } #endif // OPENGLES report_my_gl_errors(); @@ -7500,7 +7637,6 @@ do_issue_material() { } else if (material->has_ambient()) { // The material specifies an ambient, but not a diffuse component. The // diffuse component comes from the object's color. - call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_DIFFUSE, _material_force_color); @@ -7510,11 +7646,11 @@ do_issue_material() { #endif // OPENGLES glEnable(GL_COLOR_MATERIAL); } + call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); } else if (material->has_diffuse()) { // The material specifies a diffuse, but not an ambient component. The // ambient component comes from the object's color. - call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_AMBIENT, _material_force_color); @@ -7524,6 +7660,7 @@ do_issue_material() { #endif // OPENGLES glEnable(GL_COLOR_MATERIAL); } + call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); } else { // The material specifies neither a diffuse nor an ambient component. @@ -7836,7 +7973,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // State:Light:Bind:Directional"); PStatGPUTimer timer(this, // _draw_set_state_light_bind_directional_pcollector); - pair lookup = _dlights.insert(DirectionalLights::value_type(light, DirectionalLightFrameData())); + std::pair lookup = _dlights.insert(DirectionalLights::value_type(light, DirectionalLightFrameData())); DirectionalLightFrameData &fdata = (*lookup.first).second; if (lookup.second) { // The light was not computed yet this frame. Compute it now. @@ -8100,7 +8237,7 @@ get_error_string(GLenum error_code) { } // Other error, somehow? Just display the error code then. - ostringstream strm; + std::ostringstream strm; strm << "GL error " << (int)error_code; return strm.str(); @@ -8307,7 +8444,7 @@ get_extra_extensions() { void CLP(GraphicsStateGuardian):: report_extensions() const { if (GLCAT.is_debug()) { - ostream &out = GLCAT.debug(); + std::ostream &out = GLCAT.debug(); out << "GL Extensions:\n"; pset::const_iterator ei; @@ -11603,17 +11740,18 @@ do_issue_tex_gen() { // effectively define an identity matrix that maps the spatial coordinates // one-for-one to UV's. If you want a mapping other than identity, use a // TexMatrixAttrib (or a TexProjectorEffect). +#ifndef OPENGLES static const PN_stdfloat s_data[4] = { 1, 0, 0, 0 }; static const PN_stdfloat t_data[4] = { 0, 1, 0, 0 }; static const PN_stdfloat r_data[4] = { 0, 0, 1, 0 }; static const PN_stdfloat q_data[4] = { 0, 0, 0, 1 }; +#endif _tex_gen_modifies_mat = false; bool got_point_sprites = false; for (int i = 0; i < _num_active_texture_stages; i++) { - TextureStage *stage = _target_texture->get_on_ff_stage(i); set_active_texture_stage(i); if (_supports_point_sprite) { #ifdef OPENGLES @@ -11629,6 +11767,7 @@ do_issue_tex_gen() { glDisable(GL_TEXTURE_GEN_R); glDisable(GL_TEXTURE_GEN_Q); + TextureStage *stage = _target_texture->get_on_ff_stage(i); TexGenAttrib::Mode mode = _target_tex_gen->get_mode(stage); switch (mode) { case TexGenAttrib::M_off: @@ -12769,7 +12908,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, int width = tex->get_expected_mipmap_x_size(n); int height = tex->get_expected_mipmap_y_size(n); +#ifndef OPENGLES_1 int depth = tex->get_expected_mipmap_z_size(n); +#endif #ifdef DO_PSTATS _data_transferred_pcollector.add_level(view_size); @@ -12949,7 +13090,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, int width = tex->get_expected_mipmap_x_size(n); int height = tex->get_expected_mipmap_y_size(n); +#ifndef OPENGLES_1 int depth = tex->get_expected_mipmap_z_size(n); +#endif #ifdef DO_PSTATS _data_transferred_pcollector.add_level(view_size); @@ -13054,7 +13197,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, void CLP(GraphicsStateGuardian):: generate_mipmaps(CLP(TextureContext) *gtc) { #ifndef OPENGLES - if (_glGenerateTextureMipmap != nullptr) { + if (_supports_dsa) { // OpenGL 4.5 offers an easy way to do this without binding. _glGenerateTextureMipmap(gtc->_index); return; @@ -13300,9 +13443,18 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { << "glBindTexture(0x" << hex << target << dec << ", " << gtc->_index << "): " << *tex << "\n"; } +#ifndef OPENGLES + if (target == GL_TEXTURE_BUFFER) { + _glBindBuffer(GL_TEXTURE_BUFFER, gtc->_buffer); + } +#endif + GLint wrap_u, wrap_v, wrap_w; GLint minfilter, magfilter; + +#ifndef OPENGLES GLfloat border_color[4]; +#endif #ifdef OPENGLES if (true) { @@ -13355,7 +13507,14 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { GLint internal_format = GL_RGBA; #ifndef OPENGLES - glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); + if (target != GL_TEXTURE_BUFFER) { + glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); + } else { + // Some drivers give the wrong result for the above call. No problem; we + // already know the internal format of a buffer texture since glTexBuffer + // required passing the exact sized format. + internal_format = gtc->_internal_format; + } #endif // OPENGLES // Make sure we were able to query those parameters properly. @@ -13796,11 +13955,13 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { tex->set_wrap_u(get_panda_wrap_mode(wrap_u)); tex->set_wrap_v(get_panda_wrap_mode(wrap_v)); tex->set_wrap_w(get_panda_wrap_mode(wrap_w)); - tex->set_border_color(LColor(border_color[0], border_color[1], - border_color[2], border_color[3])); - tex->set_minfilter(get_panda_filter_type(minfilter)); //tex->set_magfilter(get_panda_filter_type(magfilter)); + +#ifndef OPENGLES + tex->set_border_color(LColor(border_color[0], border_color[1], + border_color[2], border_color[3])); +#endif } PTA_uchar image; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index c0f75a21d5..99c8296336 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -175,6 +175,10 @@ typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, con typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); @@ -670,7 +674,7 @@ protected: PT(Shader) _texture_binding_shader; ShaderContext *_texture_binding_shader_context; - static PT(Shader) _default_shader; + PT(Shader) _default_shader; #ifndef OPENGLES bool _shader_point_size; @@ -743,6 +747,12 @@ protected: #endif public: +#ifndef OPENGLES + bool _use_depth_zero_to_one; + bool _use_remapped_depth_range; + PFNGLDEPTHRANGEDNVPROC _glDepthRangedNV; +#endif + bool _supports_point_parameters; PFNGLPOINTPARAMETERFVPROC _glPointParameterfv; bool _supports_point_sprite; @@ -899,6 +909,7 @@ public: PFNGLBINDPROGRAMARBPROC _glBindProgram; #ifndef OPENGLES + bool _supports_dsa; PFNGLGENERATETEXTUREMIPMAPPROC _glGenerateTextureMipmap; #endif @@ -978,6 +989,10 @@ public: PFNGLUNIFORM2IVPROC _glUniform2iv; PFNGLUNIFORM3IVPROC _glUniform3iv; PFNGLUNIFORM4IVPROC _glUniform4iv; + PFNGLUNIFORM1UIVPROC _glUniform1uiv; + PFNGLUNIFORM2UIVPROC _glUniform2uiv; + PFNGLUNIFORM3UIVPROC _glUniform3uiv; + PFNGLUNIFORM4UIVPROC _glUniform4uiv; PFNGLUNIFORMMATRIX3FVPROC _glUniformMatrix3fv; PFNGLUNIFORMMATRIX4FVPROC _glUniformMatrix4fv; PFNGLVALIDATEPROGRAMPROC _glValidateProgram; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 203cccb727..a96a07a2e8 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -27,6 +27,12 @@ #include "clipPlaneAttrib.h" #include "bamCache.h" +using std::dec; +using std::hex; +using std::max; +using std::min; +using std::string; + TypeHandle CLP(ShaderContext)::_type_handle; /** @@ -346,7 +352,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext StorageBlock block; block._name = InternalName::make(block_name_cstr); block._binding_index = values[0]; - block._min_size = values[1]; + block._min_size = (GLuint)values[1]; _storage_blocks.push_back(block); } } @@ -420,18 +426,34 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { 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 || - param_type == GL_UNSIGNED_INT_VEC2 || - param_type == GL_UNSIGNED_INT_VEC3 || - param_type == GL_UNSIGNED_INT_VEC4 || - param_type == GL_UNSIGNED_INT); + switch (param_type) { + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + bind._numeric_type = Shader::SPT_int; + 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: + bind._numeric_type = Shader::SPT_uint; + break; +#ifndef OPENGLES + case GL_DOUBLE: + case GL_DOUBLE_VEC2: + case GL_DOUBLE_VEC3: + case GL_DOUBLE_VEC4: + bind._numeric_type = Shader::SPT_double; + break; +#endif + default: + bind._numeric_type = Shader::SPT_float; + } // Check if it has a p3d_ prefix - if so, assign special meaning. if (strncmp(name_buffer, "p3d_", 4) == 0) { @@ -675,6 +697,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b break; } + (void)numeric_type; + (void)contents; + (void)num_components; // GeomVertexColumn column(InternalName::make(name_buffer), // num_components, numeric_type, contents, offsets[ui], 4, param_size, // astrides[ui]); block_format.add_column(column); @@ -1492,21 +1517,29 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: - case GL_INT_VEC4: { + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: { Shader::ShaderPtrSpec bind; bind._id = arg_id; switch (param_type) { case GL_BOOL: case GL_INT: + case GL_UNSIGNED_INT: case GL_FLOAT: bind._dim[1] = 1; break; case GL_BOOL_VEC2: case GL_INT_VEC2: + case GL_UNSIGNED_INT_VEC2: case GL_FLOAT_VEC2: bind._dim[1] = 2; break; case GL_BOOL_VEC3: case GL_INT_VEC3: + case GL_UNSIGNED_INT_VEC3: case GL_FLOAT_VEC3: bind._dim[1] = 3; break; case GL_BOOL_VEC4: case GL_INT_VEC4: + case GL_UNSIGNED_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; @@ -1516,6 +1549,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { 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: + bind._type = Shader::SPT_uint; + break; case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: @@ -1595,6 +1634,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_INT_VEC2: case GL_INT_VEC3: case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: case GL_FLOAT: case GL_FLOAT_VEC2: case GL_FLOAT_VEC3: @@ -1624,6 +1667,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { 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: + bind._type = Shader::SPT_uint; + break; case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: @@ -1904,12 +1953,14 @@ set_state_and_transform(const RenderState *target_rs, // Reset all of the state. altered |= Shader::SSD_general; _state_rs = target_rs; + target_rs->get_attrib_def(_color_attrib); } else if (state_rs != target_rs) { // The state has changed since last time. if (state_rs->get_attrib(ColorAttrib::get_class_slot()) != target_rs->get_attrib(ColorAttrib::get_class_slot())) { altered |= Shader::SSD_color; + target_rs->get_attrib_def(_color_attrib); } if (state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != target_rs->get_attrib(ColorScaleAttrib::get_class_slot())) { @@ -1978,7 +2029,7 @@ issue_parameters(int altered) { if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) { // If we have an osg_FrameNumber input, set it now. - if ((altered | Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { + if ((altered & Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { _glgsg->_glUniform1i(_frame_number_loc, _frame_number); } @@ -1992,6 +2043,8 @@ issue_parameters(int altered) { return; } + nassertd(spec._dim[1] > 0) continue; + GLint p = spec._id._seqno; int array_size = min(spec._dim[0], (int)ptr_data->_size / spec._dim[1]); switch (spec._type) { @@ -2008,6 +2061,14 @@ issue_parameters(int altered) { } break; + case Shader::SPT_uint: + // Convert unsigned int data to float data. + data = (float*) alloca(sizeof(float) * array_size * spec._dim[1]); + for (int i = 0; i < (array_size * spec._dim[1]); ++i) { + data[i] = (float)(((unsigned int*)ptr_data->_ptr)[i]); + } + break; + case Shader::SPT_double: // Downgrade double data to float data. data = (float*) alloca(sizeof(float) * array_size * spec._dim[1]); @@ -2037,7 +2098,8 @@ issue_parameters(int altered) { break; case Shader::SPT_int: - if (ptr_data->_type != Shader::SPT_int) { + if (ptr_data->_type != Shader::SPT_int && + ptr_data->_type != Shader::SPT_uint) { GLCAT.error() << "Cannot pass floating-point data to integer shader input '" << spec._id._name << "'\n"; @@ -2057,6 +2119,28 @@ issue_parameters(int altered) { } break; + case Shader::SPT_uint: + if (ptr_data->_type != Shader::SPT_uint && + ptr_data->_type != Shader::SPT_int) { + GLCAT.error() + << "Cannot pass floating-point data to integer shader input '" << spec._id._name << "'\n"; + + // Deactivate it to make sure the user doesn't get flooded with this + // error. + spec._dep[0] = 0; + spec._dep[1] = 0; + + } else { + switch (spec._dim[1]) { + case 1: _glgsg->_glUniform1uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 2: _glgsg->_glUniform2uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 3: _glgsg->_glUniform3uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 4: _glgsg->_glUniform4uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + } + nassertd(false) continue; + } + break; + case Shader::SPT_double: GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n"; @@ -2161,7 +2245,7 @@ update_transform_table(const TransformTable *table) { #endif } } - for (; i < _transform_table_size; ++i) { + for (; i < (size_t)_transform_table_size; ++i) { matrices[i] = LMatrix4f::ident_mat(); } @@ -2196,7 +2280,7 @@ disable_shader_vertex_arrays() { return; } - for (int i=0; i<(int)_shader->_var_spec.size(); i++) { + for (size_t i = 0; i < _shader->_var_spec.size(); ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; GLint p = bind._id._seqno; @@ -2221,8 +2305,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Get the active ColorAttrib. We'll need it to determine how to apply // vertex colors. - const ColorAttrib *color_attrib; - _state_rs->get_attrib_def(color_attrib); + const ColorAttrib *color_attrib = _color_attrib.p(); const GeomVertexArrayDataHandle *array_reader; @@ -2230,7 +2313,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Use experimental new separated formatbinding state. const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader; - for (int ai = 0; ai < data_reader->get_num_arrays(); ++ai) { + for (size_t ai = 0; ai < data_reader->get_num_arrays(); ++ai) { array_reader = data_reader->get_array_reader(ai); // Make sure the vertex buffer is up-to-date. @@ -2287,7 +2370,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { int start, stride, num_values; size_t nvarying = _shader->_var_spec.size(); - GLuint max_p = 0; + GLint max_p = 0; for (size_t i = 0; i < nvarying; ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; @@ -2305,7 +2388,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } } - GLuint p = bind._id._seqno; + GLint p = bind._id._seqno; max_p = max(max_p, p + 1); // Don't apply vertex colors if they are disabled with a ColorAttrib. @@ -2322,21 +2405,25 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } client_pointer += start; + GLenum type = _glgsg->get_numeric_type(numeric_type); for (int i = 0; i < num_elements; ++i) { _glgsg->enable_vertex_attrib_array(p); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(p, num_values, _glgsg->get_numeric_type(numeric_type), - stride, client_pointer); - } else if (numeric_type == GeomEnums::NT_packed_dabc) { + 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, - _glgsg->get_numeric_type(numeric_type), + } else if (bind._numeric_type == Shader::SPT_float || + numeric_type == GeomEnums::NT_float32) { + _glgsg->_glVertexAttribPointer(p, num_values, type, normalized, stride, client_pointer); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(p, num_values, type, + stride, client_pointer); + } else { + _glgsg->_glVertexAttribIPointer(p, num_values, type, + stride, client_pointer); } if (divisor > 0) { @@ -2394,7 +2481,7 @@ disable_shader_texture_bindings() { DO_PSTATS_STUFF(_glgsg->_texture_state_pcollector.add_level(1)); - for (int i = 0; i < _shader->_tex_spec.size(); ++i) { + for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { #ifndef OPENGLES // Check if bindless was used, if so, there's nothing to unbind. if (_glgsg->_supports_bindless_texture) { @@ -2602,8 +2689,8 @@ update_shader_texture_bindings(ShaderContext *prev) { } size_t num_textures = _shader->_tex_spec.size(); - GLuint *textures; - GLuint *samplers; + GLuint *textures = nullptr; + GLuint *samplers = nullptr; #ifdef OPENGLES static const bool multi_bind = false; #else @@ -2799,7 +2886,7 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { // Parse the errors so that we can substitute in actual file locations // instead of source indices. - istringstream log(info_log); + std::istringstream log(info_log); string line; while (std::getline(log, line)) { int fileno, lineno, colno; @@ -3114,7 +3201,7 @@ glsl_compile_and_link() { sprintf(filename, "glsl_program%d.dump", gl_dump_count++); pofstream s; - s.open(filename, ios::out | ios::binary | ios::trunc); + s.open(filename, std::ios::out | std::ios::binary | std::ios::trunc); s.write(binary, num_bytes); s.close(); diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 79ceeb713d..91130e9224 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -75,6 +75,7 @@ private: CPT(TransformState) _modelview_transform; CPT(TransformState) _camera_transform; CPT(TransformState) _projection_transform; + CPT(ColorAttrib) _color_attrib; /* * struct ParamContext { CPT(InternalName) _name; GLint _location; GLsizei @@ -98,7 +99,7 @@ private: struct StorageBlock { CPT(InternalName) _name; GLuint _binding_index; - GLint _min_size; + GLuint _min_size; }; typedef pvector StorageBlocks; StorageBlocks _storage_blocks; diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index fd2bcf7aee..08e200a4a0 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -313,6 +313,13 @@ ConfigVariableEnum gl_coordinate_system "creating a shader-only application, it may be easier and " "more efficient to set this to default.")); +ConfigVariableBool gl_depth_zero_to_one + ("gl-depth-zero-to-one", false, + PRC_DESC("Normally, OpenGL uses an NDC coordinate space wherein the Z " + "ranges from -1 to 1. This setting can be used to instead use a " + "range from 0 to 1, matching other graphics APIs. This setting " + "requires OpenGL 4.5, or NVIDIA GeForce 8+ hardware.")); + extern ConfigVariableBool gl_parallel_arrays; void CLP(init_classes)() { diff --git a/panda/src/glstuff/panda_glext.h b/panda/src/glstuff/panda_glext.h index 3be88b13c5..decfc9fcf4 100644 --- a/panda/src/glstuff/panda_glext.h +++ b/panda/src/glstuff/panda_glext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2015 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,9 +31,7 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 31717 $ on $Date: 2015-07-20 05:42:11 -0400 (Mon, 20 Jul 2015) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -53,7 +51,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20150720 +#define GL_GLEXT_VERSION 20180525 /* Generated C header for: * API: gl @@ -355,15 +353,17 @@ GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); @@ -2654,7 +2654,7 @@ typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint fram typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +//typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); @@ -2777,7 +2777,7 @@ GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLs GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +//GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); @@ -2867,6 +2867,42 @@ GLAPI void APIENTRY glTextureBarrier (void); #endif #endif /* GL_VERSION_4_5 */ +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ @@ -2875,6 +2911,17 @@ GLAPI void APIENTRY glTextureBarrier (void); #define GL_ARB_ES3_1_compatibility 1 #endif /* GL_ARB_ES3_1_compatibility */ +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #endif /* GL_ARB_ES3_compatibility */ @@ -3288,6 +3335,10 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #endif /* GL_ARB_fragment_shader */ +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #endif /* GL_ARB_framebuffer_no_attachments */ @@ -3340,6 +3391,16 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_get_texture_sub_image 1 #endif /* GL_ARB_get_texture_sub_image */ +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #endif /* GL_ARB_gpu_shader5 */ @@ -3348,6 +3409,91 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_gpu_shader_fp64 1 #endif /* GL_ARB_gpu_shader_fp64 */ +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 typedef unsigned short GLhalfARB; @@ -3360,8 +3506,6 @@ typedef unsigned short GLhalfARB; #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -3498,11 +3642,11 @@ GLAPI void APIENTRY glResetMinmax (GLenum target); #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ @@ -3727,6 +3871,16 @@ GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *par #define GL_ARB_occlusion_query2 1 #endif /* GL_ARB_occlusion_query2 */ +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + #ifndef GL_ARB_pipeline_statistics_query #define GL_ARB_pipeline_statistics_query 1 #define GL_VERTICES_SUBMITTED_ARB 0x82EE @@ -3769,6 +3923,14 @@ GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #define GL_COORD_REPLACE_ARB 0x8862 #endif /* GL_ARB_point_sprite */ +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #endif /* GL_ARB_program_interface_query */ @@ -3842,6 +4004,26 @@ GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum form #define GL_ARB_robustness_isolation 1 #endif /* GL_ARB_robustness_isolation */ +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 @@ -3868,14 +4050,26 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #define GL_ARB_separate_shader_objects 1 #endif /* GL_ARB_separate_shader_objects */ +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #endif /* GL_ARB_shader_draw_parameters */ @@ -4040,6 +4234,10 @@ GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GL #define GL_ARB_shader_texture_lod 1 #endif /* GL_ARB_shader_texture_lod */ +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C @@ -4119,6 +4317,18 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #endif #endif /* GL_ARB_sparse_texture */ +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ @@ -4271,6 +4481,16 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #define GL_DOT3_RGBA_ARB 0x86AF #endif /* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 @@ -4493,6 +4713,9 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 +#include +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 @@ -4528,9 +4751,9 @@ typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); @@ -4540,9 +4763,9 @@ GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); @@ -4768,6 +4991,16 @@ GLAPI void APIENTRY glBlendBarrierKHR (void); #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ @@ -4813,6 +5046,10 @@ GLAPI void APIENTRY glBlendBarrierKHR (void); #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); @@ -5204,10 +5441,49 @@ GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRG #endif #endif /* GL_AMD_draw_buffers_blend */ +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + #ifndef GL_AMD_gcn_shader #define GL_AMD_gcn_shader 1 #endif /* GL_AMD_gcn_shader */ +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 typedef int64_t GLint64EXT; @@ -5235,10 +5511,6 @@ typedef int64_t GLint64EXT; #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); @@ -5411,7 +5683,6 @@ GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); @@ -5426,6 +5697,22 @@ GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLf #define GL_AMD_shader_atomic_counter_ops 1 #endif /* GL_AMD_shader_atomic_counter_ops */ +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ @@ -5465,6 +5752,10 @@ GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif #endif /* GL_AMD_stencil_operation_extended */ +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #endif /* GL_AMD_texture_texture4 */ @@ -6165,6 +6456,17 @@ GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #define GL_422_REV_AVERAGE_EXT 0x80CF #endif /* GL_EXT_422_pixels */ +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 @@ -7016,6 +7318,17 @@ GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint en #endif #endif /* GL_EXT_draw_range_elements */ +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 @@ -7359,6 +7672,89 @@ GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_light_texture */ +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #endif /* GL_EXT_misc_attribute */ @@ -7600,6 +7996,55 @@ GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei #endif #endif /* GL_EXT_secondary_color */ +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D @@ -7620,6 +8065,19 @@ GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *strin #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #endif /* GL_EXT_separate_specular_color */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #endif /* GL_EXT_shader_image_load_formatted */ @@ -7920,6 +8378,8 @@ GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_integer @@ -8466,6 +8926,30 @@ GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei s #endif #endif /* GL_EXT_vertex_weighting */ +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 @@ -8643,10 +9127,28 @@ GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRG #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + #ifndef GL_INTEL_map_texture #define GL_INTEL_map_texture 1 #define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF @@ -8711,7 +9213,7 @@ typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES @@ -8722,7 +9224,7 @@ GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif @@ -8743,6 +9245,11 @@ GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLen #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); @@ -8751,6 +9258,17 @@ GLAPI void APIENTRY glResizeBuffersMESA (void); #endif #endif /* GL_MESA_resize_buffers */ +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); @@ -8812,6 +9330,10 @@ GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); #define GL_YCBCR_MESA 0x8757 #endif /* GL_MESA_ycbcr_texture */ +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + #ifndef GL_NVX_conditional_render #define GL_NVX_conditional_render 1 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); @@ -8831,6 +9353,32 @@ GLAPI void APIENTRY glEndConditionalRenderNVX (void); #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #endif /* GL_NVX_gpu_memory_info */ +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + #ifndef GL_NV_bindless_multi_draw_indirect #define GL_NV_bindless_multi_draw_indirect 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); @@ -8947,10 +9495,25 @@ GLAPI void APIENTRY glBlendBarrierNV (void); #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + #ifndef GL_NV_command_list #define GL_NV_command_list 1 #define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 @@ -9053,6 +9616,26 @@ GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat valu #endif #endif /* GL_NV_conservative_raster_dilate */ +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E @@ -9102,6 +9685,23 @@ GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, #endif #endif /* GL_NV_draw_texture */ +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 @@ -9336,6 +9936,41 @@ GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachmen #define GL_NV_geometry_shader_passthrough 1 #endif /* GL_NV_geometry_shader_passthrough */ +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 @@ -9953,6 +10588,32 @@ GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); #endif #endif /* GL_NV_primitive_restart */ +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 @@ -10045,6 +10706,11 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #endif #endif /* GL_NV_register_combiners2 */ +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D @@ -10077,6 +10743,10 @@ GLAPI void APIENTRY glResolveDepthValuesNV (void); #define GL_NV_shader_atomic_float 1 #endif /* GL_NV_shader_atomic_float */ +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ @@ -10140,6 +10810,10 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 @@ -10216,6 +10890,10 @@ GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenu #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #endif /* GL_NV_texture_rectangle */ +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C @@ -10879,7 +11557,7 @@ GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint #define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B #define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); @@ -10892,7 +11570,7 @@ typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_ typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptr offset); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); @@ -10910,6 +11588,26 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_NV_viewport_array2 1 #endif /* GL_NV_viewport_array2 */ +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 @@ -10937,6 +11635,7 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 #define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index 835adeed97..d777f7a239 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -27,7 +27,7 @@ TypeHandle glxGraphicsBuffer::_type_handle; */ glxGraphicsBuffer:: glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsPipe.cxx b/panda/src/glxdisplay/glxGraphicsPipe.cxx index 06266e6e96..e4ec8380fb 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.cxx +++ b/panda/src/glxdisplay/glxGraphicsPipe.cxx @@ -20,6 +20,8 @@ #include "config_glxdisplay.h" #include "frameBufferProperties.h" +using std::string; + TypeHandle glxGraphicsPipe::_type_handle; /** diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 8c9c317b2c..7f551b8d4f 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -28,7 +28,7 @@ TypeHandle glxGraphicsPixmap::_type_handle; */ glxGraphicsPixmap:: glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 2b877b2168..76c66d817e 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -18,6 +18,8 @@ #include +using std::string; + TypeHandle glxGraphicsStateGuardian::_type_handle; diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 28f4652266..a7a2472a84 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -36,7 +36,7 @@ TypeHandle glxGraphicsWindow::_type_handle; */ glxGraphicsWindow:: glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 85bb3ab36c..54ed81a3c8 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -16,6 +16,9 @@ #include "clockObject.h" #include "indent.h" +using std::cerr; +using std::ostream; + static const int HIGH_PRIORITY_SCALE = 4; static const int LOW_PRIORITY_RANGE = 25; @@ -23,7 +26,7 @@ static const int LOW_PRIORITY_RANGE = 25; * */ AdaptiveLru:: -AdaptiveLru(const string &name, size_t max_size) : +AdaptiveLru(const std::string &name, size_t max_size) : Namable(name) { _total_size = 0; @@ -156,7 +159,7 @@ update_page(AdaptiveLruPage *page) { } if (target_priority != page->_priority) { - page->_priority = min(max(target_priority, 0), LPP_TotalPriorities - 1); + page->_priority = std::min(std::max(target_priority, 0), LPP_TotalPriorities - 1); ((AdaptiveLruPageDynamicList *)page)->remove_from_list(); ((AdaptiveLruPageDynamicList *)page)->insert_before(&_page_array[page->_priority]); } diff --git a/panda/src/gobj/bufferContextChain.cxx b/panda/src/gobj/bufferContextChain.cxx index 9a94ff2919..4f27c90c88 100644 --- a/panda/src/gobj/bufferContextChain.cxx +++ b/panda/src/gobj/bufferContextChain.cxx @@ -54,7 +54,7 @@ take_from(BufferContextChain &other) { * */ void BufferContextChain:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _count << " objects, consuming " << _total_size << " bytes:\n"; diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index abb51610e6..9ac4fef735 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -22,7 +22,7 @@ PStatCollector BufferResidencyTracker::_gmem_collector("Graphics memory"); * */ BufferResidencyTracker:: -BufferResidencyTracker(const string &pgo_name, const string &type_name) : +BufferResidencyTracker(const std::string &pgo_name, const std::string &type_name) : _pgo_collector(_gmem_collector, pgo_name), _active_resident_collector(PStatCollector(_pgo_collector, "Active"), type_name), _active_nonresident_collector(PStatCollector(_pgo_collector, "Thrashing"), type_name), @@ -90,7 +90,7 @@ set_levels() { * */ void BufferResidencyTracker:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_chains[S_inactive_nonresident].get_count() != 0) { indent(out, indent_level) << "Inactive nonresident:\n"; _chains[S_inactive_nonresident].write(out, indent_level + 2); diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index b7d0e02eb5..7da3b1d31e 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -260,18 +260,6 @@ ConfigVariableBool cache_generated_shaders 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 " - "constructed, the corresponding Material, Texture, or Light " - "is 'attrib locked.' The attrib lock prevents qualitative " - "changes to the object. This makes it possible to hardwire " - "information about material, light, and texture properties " - "into generated shaders. This config variable can disable " - "the attrib lock. Disabling the lock will break the shader " - "generator, but doing so may be necessary for backward " - "compatibility with old code.")); - ConfigVariableBool vertices_float64 ("vertices-float64", false, PRC_DESC("When this is true, the default float format for vertices " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index d3b651d3d4..7e769c0f45 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -51,7 +51,6 @@ 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; extern EXPCL_PANDA_GOBJ ConfigVariableBool vertex_animation_align_16; diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 0c627d6e5b..565f8c47b4 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -25,6 +25,9 @@ #include "lightMutexHolder.h" #include "config_mathutil.h" +using std::max; +using std::min; + UpdateSeq Geom::_next_modified; PStatCollector Geom::_draw_primitive_setup_pcollector("Draw:Primitive:Setup"); @@ -192,6 +195,9 @@ offset_vertices(const GeomVertexData *data, int offset) { cdata->_data = (GeomVertexData *)data; #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(data, current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -200,7 +206,7 @@ offset_vertices(const GeomVertexData *data, int offset) { prim->offset_vertices(offset); #ifndef NDEBUG - if (!prim->check_valid(data)) { + if (!prim->check_valid(&data_reader)) { gobj_cat.warning() << *prim << " is invalid for " << *data << ":\n"; prim->write(gobj_cat.warning(false), 4); @@ -420,6 +426,9 @@ decompose_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -428,7 +437,7 @@ decompose_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -454,6 +463,9 @@ doubleside_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -462,7 +474,7 @@ doubleside_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -488,6 +500,9 @@ reverse_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -496,7 +511,7 @@ reverse_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -522,6 +537,9 @@ rotate_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -530,7 +548,7 @@ rotate_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -625,7 +643,7 @@ unify_in_place(int max_indices, bool preserve_order) { } else { // We have already encountered another primitive of this type. Combine // them. - combine_primitives((*npi).second, move(primitive), current_thread); + combine_primitives((*npi).second, std::move(primitive), current_thread); } } @@ -637,6 +655,9 @@ unify_in_place(int max_indices, bool preserve_order) { // primitives.) nassertv(false); } + + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); #endif // Finally, iterate through the remaining primitives, and copy them to the @@ -646,7 +667,7 @@ unify_in_place(int max_indices, bool preserve_order) { for (npi = new_prims.begin(); npi != new_prims.end(); ++npi) { GeomPrimitive *prim = (*npi).second; - nassertv(prim->check_valid(cdata->_data.get_read_pointer(current_thread))); + nassertv(prim->check_valid(&data_reader)); // Each new primitive, naturally, inherits the Geom's overall shade model. prim->set_shade_model(cdata->_shade_model); @@ -745,6 +766,9 @@ make_lines_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -753,7 +777,7 @@ make_lines_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -779,6 +803,9 @@ make_points_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -787,7 +814,7 @@ make_points_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -813,6 +840,9 @@ make_patches_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -821,7 +851,7 @@ make_patches_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -847,6 +877,9 @@ make_adjacency_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -856,7 +889,7 @@ make_adjacency_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -1060,7 +1093,7 @@ get_nested_vertices(Thread *current_thread) const { * */ void Geom:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); // Get a list of the primitive types contained within this object. @@ -1087,7 +1120,7 @@ output(ostream &out) const { * */ void Geom:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); // Get a list of the primitive types contained within this object. @@ -1462,13 +1495,20 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { */ bool Geom:: check_will_be_valid(const GeomVertexData *vertex_data) const { - CDReader cdata(_cycler); + Thread *current_thread = Thread::get_current_thread(); + + CDReader cdata(_cycler, current_thread); + + GeomVertexDataPipelineReader data_reader(vertex_data, current_thread); + data_reader.check_array_readers(); Primitives::const_iterator pi; for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) { - if (!(*pi).get_read_pointer()->check_valid(vertex_data)) { + GeomPrimitivePipelineReader reader((*pi).get_read_pointer(), current_thread); + reader.check_minmax(); + if (!reader.check_valid(&data_reader)) { return false; } } @@ -1552,9 +1592,9 @@ combine_primitives(GeomPrimitive *a_prim, CPT(GeomPrimitive) b_prim, } PT(GeomVertexArrayDataHandle) a_handle = - new GeomVertexArrayDataHandle(move(a_vertices), current_thread); + new GeomVertexArrayDataHandle(std::move(a_vertices), current_thread); CPT(GeomVertexArrayDataHandle) b_handle = - new GeomVertexArrayDataHandle(move(b_vertices), current_thread); + new GeomVertexArrayDataHandle(std::move(b_vertices), current_thread); size_t orig_a_vertices = a_handle->get_num_rows(); @@ -1672,7 +1712,7 @@ evict_callback() { * */ void Geom::CacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "geom " << (void *)_source << ", " << (const void *)_key._modifier; } diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index 608ebbdac4..8ddb12b042 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -133,6 +133,6 @@ evict_callback() { * */ void GeomCacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ unknown ]"; } diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index 7fef373373..4eb06a25b4 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -13,7 +13,9 @@ #include "geomCacheManager.h" #include "geomCacheEntry.h" +#include "geomMunger.h" #include "lightMutexHolder.h" +#include "lightReMutexHolder.h" #include "clockObject.h" GeomCacheManager *GeomCacheManager::_global_ptr = nullptr; @@ -53,6 +55,9 @@ GeomCacheManager:: */ void GeomCacheManager:: flush() { + // Prevent deadlock + LightReMutexHolder registry_holder(GeomMunger::get_registry()->_registry_lock); + LightMutexHolder holder(_lock); evict_old_entries(0, false); } diff --git a/panda/src/gobj/geomEnums.cxx b/panda/src/gobj/geomEnums.cxx index e63260a144..0899fd3679 100644 --- a/panda/src/gobj/geomEnums.cxx +++ b/panda/src/gobj/geomEnums.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_gobj.h" +using std::istream; +using std::ostream; +using std::string; + /** * diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index dee3c89ccf..d9b460b14a 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -20,6 +20,8 @@ #include "geomVertexWriter.h" #include "geomLinesAdjacency.h" +using std::map; + TypeHandle GeomLines::_type_handle; /** @@ -125,8 +127,8 @@ make_adjacency() const { nassertr(to.is_at_end(), nullptr); } - adj->set_vertices(move(new_vertices)); - return adj.p(); + adj->set_vertices(std::move(new_vertices)); + return adj; } /** diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 0b54de3410..8e85ac870a 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -20,6 +20,8 @@ #include "graphicsStateGuardianBase.h" #include "geomLinestripsAdjacency.h" +using std::map; + TypeHandle GeomLinestrips::_type_handle; /** @@ -143,7 +145,7 @@ make_adjacency() const { // Add the actual vertices in the strip. adj->add_vertex(v0); - int v1; + int v1 = v0; while (vi < end) { v1 = from.get_vertex(vi++); adj->add_vertex(v1); @@ -162,7 +164,7 @@ make_adjacency() const { } nassertr(vi == num_vertices, nullptr); - return adj.p(); + return adj; } /** @@ -218,7 +220,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 1 <= end, lines.p()); + nassertr(vi + 1 <= end, lines); int v0 = get_vertex(vi); ++vi; while (vi < end) { @@ -233,7 +235,7 @@ decompose_impl() const { } nassertr(vi == get_num_vertices(), nullptr); - return lines.p(); + return lines; } /** diff --git a/panda/src/gobj/geomLinestripsAdjacency.cxx b/panda/src/gobj/geomLinestripsAdjacency.cxx index 11d14ab319..c9d4ba6891 100644 --- a/panda/src/gobj/geomLinestripsAdjacency.cxx +++ b/panda/src/gobj/geomLinestripsAdjacency.cxx @@ -142,7 +142,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 3 <= end, lines.p()); + nassertr(vi + 3 <= end, lines); int v0 = from.get_vertex(vi++); int v1 = from.get_vertex(vi++); int v2 = from.get_vertex(vi++); @@ -160,7 +160,7 @@ decompose_impl() const { } nassertr(vi == num_vertices, nullptr); - return lines.p(); + return lines; } /** diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index 83d57467c1..40a183edfa 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -148,7 +148,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. - entry = new Geom::CacheEntry(orig_geom, move(key)); + entry = new Geom::CacheEntry(orig_geom, std::move(key)); { LightMutexHolder holder(orig_geom->_cache_lock); @@ -378,7 +378,7 @@ do_unregister() { * */ void GeomMunger::CacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "munger " << _munger; } diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index 00105108bf..e8aa67bd61 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -149,6 +149,8 @@ private: static PStatCollector _munge_pcollector; + friend class GeomCacheManager; + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index 0984dbecb3..f314c81090 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -223,11 +223,19 @@ get_modified() const { INLINE bool GeomPrimitive:: check_valid(const GeomVertexData *vertex_data) const { Thread *current_thread = Thread::get_current_thread(); - GeomPrimitivePipelineReader reader(this, current_thread); - reader.check_minmax(); GeomVertexDataPipelineReader data_reader(vertex_data, current_thread); data_reader.check_array_readers(); - return reader.check_valid(&data_reader); + return check_valid(&data_reader); +} + +/** + * + */ +INLINE bool GeomPrimitive:: +check_valid(const GeomVertexDataPipelineReader *data_reader) const { + GeomPrimitivePipelineReader reader(this, data_reader->get_current_thread()); + reader.check_minmax(); + return reader.check_valid(data_reader); } /** diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index db939d3bef..da3c10dffd 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -31,6 +31,9 @@ #include "indent.h" #include "pStatTimer.h" +using std::max; +using std::min; + TypeHandle GeomPrimitive::_type_handle; TypeHandle GeomPrimitive::CData::_type_handle; TypeHandle GeomPrimitivePipelineReader::_type_handle; @@ -52,7 +55,7 @@ GeomPrimitive() { */ PT(CopyOnWriteObject) GeomPrimitive:: make_cow_copy() { - return make_copy().p(); + return make_copy(); } /** @@ -581,7 +584,7 @@ pack_vertices(GeomVertexData *dest, const GeomVertexData *source) { // Try to add the relation { v : size() }. If that succeeds, great; if // it doesn't, look up whatever we previously added for v. - pair result = + std::pair result = copied_indices.insert(CopiedIndices::value_type(v, (int)copied_indices.size())); int v2 = (*result.first).second + dest_start; index.add_data1i(v2); @@ -1079,7 +1082,7 @@ request_resident(Thread *current_thread) const { * */ void GeomPrimitive:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ", " << get_num_primitives() << ", " << get_num_vertices(); } @@ -1088,7 +1091,7 @@ output(ostream &out) const { * */ void GeomPrimitive:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type(); if (is_indexed()) { diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index b8012507b8..392fffe1cf 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -146,6 +146,7 @@ PUBLISHED: bool request_resident(Thread *current_thread = Thread::get_current_thread()) const; INLINE bool check_valid(const GeomVertexData *vertex_data) const; + INLINE bool check_valid(const GeomVertexDataPipelineReader *data_reader) const; virtual void output(std::ostream &out) const; virtual void write(std::ostream &out, int indent_level) const; diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 494f59be74..5171ec6b5f 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -19,6 +19,8 @@ #include "graphicsStateGuardianBase.h" #include "geomTrianglesAdjacency.h" +using std::map; + TypeHandle GeomTriangles::_type_handle; /** @@ -85,7 +87,7 @@ make_adjacency() const { new_vertices->set_num_rows(num_vertices * 2); // First, build a map of each triangle's halfedges to its opposing vertices. - map, int> edge_map; + map, int> edge_map; for (int i = 0; i < num_vertices; i += 3) { int v0 = from.get_vertex(i); int v1 = from.get_vertex(i + 1); @@ -135,8 +137,8 @@ make_adjacency() const { nassertr(to.is_at_end(), nullptr); } - adj->set_vertices(move(new_vertices)); - return adj.p(); + adj->set_vertices(std::move(new_vertices)); + return adj; } /** @@ -197,7 +199,7 @@ doubleside_impl() const { reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate()); } - return reversed.p(); + return reversed; } /** @@ -230,7 +232,7 @@ reverse_impl() const { break; } - return reversed.p(); + return reversed; } /** diff --git a/panda/src/gobj/geomTrianglesAdjacency.cxx b/panda/src/gobj/geomTrianglesAdjacency.cxx index 0dffa74329..5278d69bbb 100644 --- a/panda/src/gobj/geomTrianglesAdjacency.cxx +++ b/panda/src/gobj/geomTrianglesAdjacency.cxx @@ -133,7 +133,7 @@ doubleside_impl() const { reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); } - return reversed.p(); + return reversed; } /** @@ -166,7 +166,7 @@ reverse_impl() const { break; } - return reversed.p(); + return reversed; } /** diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index 0c5d87f53a..a99481e92e 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -110,7 +110,7 @@ decompose_impl() const { int li = 0; while (li < (int)ends.size()) { int end = ends[li]; - nassertr(vi + 2 <= end, triangles.p()); + nassertr(vi + 2 <= end, triangles); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -129,7 +129,7 @@ decompose_impl() const { nassertr(vi == num_vertices, nullptr); - return triangles.p(); + return triangles; } /** diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index 7c8eff61f9..15b46c409a 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -20,6 +20,8 @@ #include "graphicsStateGuardianBase.h" #include "geomTristripsAdjacency.h" +using std::map; + TypeHandle GeomTristrips::_type_handle; /** @@ -98,7 +100,7 @@ make_adjacency() const { const int num_unused = 2; // First, build a map of each triangle's halfedges to its opposing vertices. - map, int> edge_map; + map, int> edge_map; int vi = -num_unused; int li = 0; @@ -217,7 +219,7 @@ make_adjacency() const { } nassertr(vi == num_vertices, nullptr); - return adj.p(); + return adj; } /** @@ -356,7 +358,7 @@ decompose_impl() const { nassertr(vi == num_vertices, nullptr); } - return triangles.p(); + return triangles; } /** diff --git a/panda/src/gobj/geomVertexAnimationSpec.cxx b/panda/src/gobj/geomVertexAnimationSpec.cxx index be4dc6903a..f4560b7980 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.cxx +++ b/panda/src/gobj/geomVertexAnimationSpec.cxx @@ -19,7 +19,7 @@ * */ void GeomVertexAnimationSpec:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_animation_type) { case AT_none: out << "none"; diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index d573489ba6..cfe12f9013 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -518,10 +518,11 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, * a string. This is primarily for the benefit of high-level languages such * as Python. */ -INLINE std::string GeomVertexArrayDataHandle:: +INLINE vector_uchar GeomVertexArrayDataHandle:: get_data() const { mark_used(); - return std::string((const char *)_cdata->_buffer.get_read_pointer(true), _cdata->_buffer.get_size()); + const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true); + return vector_uchar(ptr, ptr + _cdata->_buffer.get_size()); } /** @@ -529,12 +530,13 @@ get_data() const { * formatted as a string. This is primarily for the benefit of high-level * languages such as Python. */ -INLINE std::string GeomVertexArrayDataHandle:: +INLINE vector_uchar GeomVertexArrayDataHandle:: get_subdata(size_t start, size_t size) const { mark_used(); start = std::min(start, _cdata->_buffer.get_size()); size = std::min(size, _cdata->_buffer.get_size() - start); - return std::string((const char *)_cdata->_buffer.get_read_pointer(true) + start, size); + const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true) + start; + return vector_uchar(ptr, ptr + size); } /** diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 9b4803d3bf..998ca1ad14 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -25,6 +25,9 @@ #include "vertexDataBuffer.h" #include "texture.h" +using std::max; +using std::min; + ConfigVariableInt max_independent_vertex_data ("max-independent-vertex-data", -1, PRC_DESC("Specifies the maximum number of bytes of all vertex data " @@ -176,7 +179,7 @@ set_usage_hint(GeomVertexArrayData::UsageHint usage_hint) { * */ void GeomVertexArrayData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_num_rows() << " rows: " << *get_array_format(); } @@ -184,7 +187,7 @@ output(ostream &out) const { * */ void GeomVertexArrayData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { _array_format->write_with_data(out, indent_level, this); } @@ -842,7 +845,7 @@ copy_subdata_from(size_t to_start, size_t to_size, * Python. */ void GeomVertexArrayDataHandle:: -set_data(const string &data) { +set_data(const vector_uchar &data) { nassertv(_writable); mark_used(); @@ -864,7 +867,7 @@ set_data(const string &data) { * This is primarily for the benefit of high-level languages like Python. */ void GeomVertexArrayDataHandle:: -set_subdata(size_t start, size_t size, const string &data) { +set_subdata(size_t start, size_t size, const vector_uchar &data) { nassertv(_writable); mark_used(); diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 40935563e5..917b27c71a 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -316,10 +316,10 @@ PUBLISHED: PyObject *buffer, size_t from_start, size_t from_size)); - INLINE std::string get_data() const; - void set_data(const std::string &data); - INLINE std::string get_subdata(size_t start, size_t size) const; - void set_subdata(size_t start, size_t size, const std::string &data); + INLINE vector_uchar get_data() const; + void set_data(const vector_uchar &data); + INLINE vector_uchar get_subdata(size_t start, size_t size) const; + void set_subdata(size_t start, size_t size, const vector_uchar &data); INLINE void mark_used() const; diff --git a/panda/src/gobj/geomVertexArrayData_ext.cxx b/panda/src/gobj/geomVertexArrayData_ext.cxx index f35d96ae3a..73c795f0b5 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.cxx +++ b/panda/src/gobj/geomVertexArrayData_ext.cxx @@ -19,7 +19,7 @@ struct InternalBufferData { CPT(GeomVertexArrayDataHandle) _handle; Py_ssize_t _num_rows; Py_ssize_t _stride; - string _format; + std::string _format; }; /** @@ -251,8 +251,8 @@ copy_subdata_from(size_t to_start, size_t to_size, } size_t from_buffer_orig_size = (size_t) view.len; - from_start = min(from_start, from_buffer_orig_size); - from_size = min(from_size, from_buffer_orig_size - from_start); + from_start = std::min(from_start, from_buffer_orig_size); + from_size = std::min(from_size, from_buffer_orig_size - from_start); _this->copy_subdata_from(to_start, to_size, (const unsigned char *) view.buf, diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 9e0d35cccd..578e99d805 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -21,6 +21,10 @@ #include "indirectLess.h" #include "lightMutexHolder.h" +using std::max; +using std::min; +using std::move; + GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = nullptr; TypeHandle GeomVertexArrayFormat::_type_handle; @@ -460,7 +464,7 @@ count_unused_space() const { * */ void GeomVertexArrayFormat:: -output(ostream &out) const { +output(std::ostream &out) const { Columns::const_iterator ci; int last_pos = 0; out << "["; @@ -484,7 +488,7 @@ output(ostream &out) const { * */ void GeomVertexArrayFormat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Array format (stride = " << get_stride() << "):\n"; consider_sort_columns(); @@ -503,7 +507,7 @@ write(ostream &out, int indent_level) const { * */ void GeomVertexArrayFormat:: -write_with_data(ostream &out, int indent_level, +write_with_data(std::ostream &out, int indent_level, const GeomVertexArrayData *array_data) const { consider_sort_columns(); int num_rows = array_data->get_num_rows(); @@ -536,7 +540,7 @@ write_with_data(ostream &out, int indent_level, * the columns in memory, as understood by Python's struct module. If pad is * true, extra padding bytes are added to the end as 'x' characters as needed. */ -string GeomVertexArrayFormat:: +std::string GeomVertexArrayFormat:: get_format_string(bool pad) const { consider_sort_columns(); @@ -553,9 +557,7 @@ get_format_string(bool pad) const { int fi = 0; int offset = 0; - for (int ci = 0; ci < get_num_columns(); ++ci) { - const GeomVertexColumn *column = get_column(ci); - + for (const GeomVertexColumn *column : _columns) { if (offset < column->get_start()) { // Add padding bytes to fill the gap. int pad = column->get_start() - offset; @@ -616,7 +618,7 @@ get_format_string(bool pad) const { memset((void*) (fmt + fi), 'x', pad); } - string fmt_string (fmt); + std::string fmt_string (fmt); free(fmt); return fmt_string; } diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index b43930d3b5..d04b69a307 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -16,6 +16,9 @@ #include "bamReader.h" #include "bamWriter.h" +using std::max; +using std::min; + /** * */ @@ -97,7 +100,7 @@ set_column_alignment(int column_alignment) { * */ void GeomVertexColumn:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_name() << "(" << get_num_components(); switch (get_numeric_type()) { case NT_uint8: diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index dd1d800309..bfea5a10ef 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -677,7 +677,7 @@ has_column(const InternalName *name) const { /** * */ -INLINE int GeomVertexDataPipelineBase:: +INLINE size_t GeomVertexDataPipelineBase:: get_num_arrays() const { return _cdata->_arrays.size(); } @@ -686,8 +686,8 @@ get_num_arrays() const { * */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: -get_array(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr); +get_array(size_t i) const { + nassertr(i < _cdata->_arrays.size(), nullptr); return _cdata->_arrays[i].get_read_pointer(); } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index f2597614ef..5e5fa7a1d4 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -22,6 +22,8 @@ #include "pset.h" #include "indent.h" +using std::ostream; + TypeHandle GeomVertexData::_type_handle; TypeHandle GeomVertexData::CDataCache::_type_handle; TypeHandle GeomVertexData::CacheEntry::_type_handle; @@ -60,7 +62,7 @@ make_cow_copy() { * */ GeomVertexData:: -GeomVertexData(const string &name, +GeomVertexData(const std::string &name, const GeomVertexFormat *format, GeomVertexData::UsageHint usage_hint) : _name(name), @@ -210,7 +212,7 @@ compare_to(const GeomVertexData &other) const { * graph for vertex computations. */ void GeomVertexData:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; _char_pcollector = PStatCollector(_animation_pcollector, name); _skinning_pcollector = PStatCollector(_char_pcollector, "Skinning"); @@ -342,7 +344,7 @@ void GeomVertexData:: clear_rows() { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); - nassertv(cdata->_format->get_num_arrays() == (int)cdata->_arrays.size()); + nassertv(cdata->_format->get_num_arrays() == cdata->_arrays.size()); Arrays::iterator ai; for (ai = cdata->_arrays.begin(); @@ -761,7 +763,7 @@ convert_to(const GeomVertexFormat *new_format) const { if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. - entry = new CacheEntry((GeomVertexData *)this, move(key)); + entry = new CacheEntry((GeomVertexData *)this, std::move(key)); { LightMutexHolder holder(_cache_lock); @@ -969,7 +971,7 @@ animate_vertices(bool force, Thread *current_thread) const { if (!cdata->_transform_blend_table.is_null()) { if (cdata->_slider_table != nullptr) { modified = - max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), + std::max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), cdata->_slider_table->get_modified(current_thread)); } else { modified = cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread); @@ -1316,7 +1318,7 @@ describe_vertex(ostream &out, int row) const { const GeomVertexColumn *column = format->get_column(ci); reader.set_column(ai, column); - int num_values = min(column->get_num_values(), 4); + int num_values = std::min(column->get_num_values(), 4); const LVecBase4 &d = reader.get_data4(); out << " " << *column->get_name(); @@ -1470,7 +1472,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { new_format = orig_format->get_post_animated_format(); cdata->_animated_vertices = new GeomVertexData(get_name(), new_format, - min(get_usage_hint(), UH_dynamic)); + std::min(get_usage_hint(), UH_dynamic)); } PT(GeomVertexData) new_data = cdata->_animated_vertices; @@ -2241,7 +2243,7 @@ get_num_bytes() const { */ int GeomVertexDataPipelineReader:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_readers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2393,7 +2395,7 @@ make_array_readers() { */ int GeomVertexDataPipelineWriter:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_writers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2412,7 +2414,7 @@ get_num_rows() const { bool GeomVertexDataPipelineWriter:: set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2508,7 +2510,7 @@ set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: unclean_set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2535,7 +2537,7 @@ unclean_set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: reserve_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 52d177e5e2..9b861c1cbc 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -419,8 +419,8 @@ public: INLINE bool has_column(const InternalName *name) const; INLINE UsageHint get_usage_hint() const; - INLINE int get_num_arrays() const; - INLINE CPT(GeomVertexArrayData) get_array(int i) const; + INLINE size_t get_num_arrays() const; + INLINE CPT(GeomVertexArrayData) get_array(size_t i) const; INLINE const TransformTable *get_transform_table() const; INLINE CPT(TransformBlendTable) get_transform_blend_table() const; INLINE const SliderTable *get_slider_table() const; diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index 05814c5bd8..2b3479cc4f 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -173,7 +173,7 @@ get_union_format(const GeomVertexFormat *other) const { // D, E) in array 1. In general, a column will appear in the result in the // first array it appears in either of the inputs. - size_t num_arrays = max(_arrays.size(), other->_arrays.size()); + size_t num_arrays = std::max(_arrays.size(), other->_arrays.size()); for (size_t ai = 0; ai < num_arrays; ++ai) { PT(GeomVertexArrayFormat) new_array = new GeomVertexArrayFormat; @@ -565,7 +565,7 @@ maybe_align_columns_for_animation() { * */ void GeomVertexFormat:: -output(ostream &out) const { +output(std::ostream &out) const { if (_arrays.empty()) { out << "(empty)"; @@ -589,7 +589,7 @@ output(ostream &out) const { * */ void GeomVertexFormat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < _arrays.size(); i++) { indent(out, indent_level) << "Array " << i << ":\n"; @@ -606,7 +606,7 @@ write(ostream &out, int indent_level) const { * */ void GeomVertexFormat:: -write_with_data(ostream &out, int indent_level, +write_with_data(std::ostream &out, int indent_level, const GeomVertexData *data) const { indent(out, indent_level) << data->get_num_rows() << " rows.\n"; @@ -716,7 +716,7 @@ do_register() { int num_columns = array_format->get_num_columns(); for (int i = 0; i < num_columns; i++) { const GeomVertexColumn *column = array_format->get_column(i); - pair result; + std::pair result; result = _columns_by_name.insert(DataTypesByName::value_type(column->get_name(), DataTypeRecord())); if (!result.second) { gobj_cat.warning() diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index b803095915..c1a4f96051 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -13,7 +13,6 @@ #include "geomVertexReader.h" - #ifndef NDEBUG // This is defined just for the benefit of having something non-NULL to // return from a nassertr() call. @@ -60,7 +59,7 @@ set_column(int array, const GeomVertexColumn *column) { * */ void GeomVertexReader:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexReader()"; @@ -103,7 +102,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index e1743ca39d..1bad4afd9d 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/panda/src/gobj/geomVertexRewriter.cxx @@ -17,7 +17,7 @@ * */ void GeomVertexRewriter:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexRewriter()"; diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index 51e8b91bf5..eaae2603ac 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -13,7 +13,6 @@ #include "geomVertexWriter.h" - #ifdef _DEBUG // This is defined just for the benefit of having something non-NULL to // return from a nassertr() call. @@ -92,7 +91,7 @@ reserve_num_rows(int num_rows) { * */ void GeomVertexWriter:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexWriter()"; @@ -134,7 +133,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/indexBufferContext.cxx b/panda/src/gobj/indexBufferContext.cxx index ebb65ea89f..2c3e68ba0b 100644 --- a/panda/src/gobj/indexBufferContext.cxx +++ b/panda/src/gobj/indexBufferContext.cxx @@ -19,7 +19,7 @@ TypeHandle IndexBufferContext::_type_handle; * */ void IndexBufferContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } @@ -27,6 +27,6 @@ output(ostream &out) const { * */ void IndexBufferContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index 828b6db97a..6803f9bab8 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -18,6 +18,8 @@ #include "bamReader.h" #include "preparedGraphicsObjects.h" +using std::string; + PT(InternalName) InternalName::_root; PT(InternalName) InternalName::_error; PT(InternalName) InternalName::_default; @@ -248,7 +250,7 @@ get_net_basename(int n) const { * */ void InternalName:: -output(ostream &out) const { +output(std::ostream &out) const { if (_parent == get_root()) { out << _basename; diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index a03651dbf5..f1cdf0a725 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -13,6 +13,8 @@ #include "internalName_ext.h" +using std::string; + #ifdef HAVE_PYTHON /** @@ -74,7 +76,7 @@ make(PyStringObject *str) { iname->ref(); InternalName::_py_intern_table.insert(std::make_pair((PyObject *)str, iname.p())); - return iname.p(); + return iname; } } diff --git a/panda/src/gobj/lens.I b/panda/src/gobj/lens.I index 91fb6e7170..d20d53bfd7 100644 --- a/panda/src/gobj/lens.I +++ b/panda/src/gobj/lens.I @@ -667,9 +667,11 @@ do_get_film_offset(const CData *cdata) const { */ INLINE void Lens:: do_set_near(CData *cdata, PN_stdfloat near_distance) { - cdata->_near_distance = near_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (near_distance != cdata->_near_distance) { + cdata->_near_distance = near_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } /** @@ -685,9 +687,11 @@ do_get_near(const CData *cdata) const { */ INLINE void Lens:: do_set_far(CData *cdata, PN_stdfloat far_distance) { - cdata->_far_distance = far_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (far_distance != cdata->_far_distance) { + cdata->_far_distance = far_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } /** @@ -703,10 +707,12 @@ do_get_far(const CData *cdata) const { */ INLINE void Lens:: do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance) { - cdata->_near_distance = near_distance; - cdata->_far_distance = far_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (near_distance != cdata->_near_distance || far_distance != cdata->_far_distance) { + cdata->_near_distance = near_distance; + cdata->_far_distance = far_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } INLINE std::ostream & diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index cb7a496e97..f66f2ba6b9 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -23,6 +23,9 @@ #include "config_gobj.h" #include "plane.h" +using std::max; +using std::min; + TypeHandle Lens::_type_handle; TypeHandle Lens::CData::_type_handle; @@ -627,7 +630,7 @@ make_geometry() { PT(Geom) geom = new Geom(cdata->_geom_data); geom->add_primitive(line); - return geom.p(); + return geom; } /** @@ -676,7 +679,7 @@ make_bounds() const { * */ void Lens:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -684,7 +687,7 @@ output(ostream &out) const { * */ void Lens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " fov = " << get_fov() << "\n"; } diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index b9e30ba262..dcaef86980 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -32,8 +32,18 @@ Material(const std::string &name) : Namable(name) { * */ INLINE Material:: -Material(const Material ©) : Namable(copy) { - operator = (copy); +Material(const Material ©) : + Namable(copy) , + _base_color(copy._base_color), + _ambient(copy._ambient), + _diffuse(copy._diffuse), + _specular(copy._specular), + _emission(copy._emission), + _shininess(copy._shininess), + _roughness(copy._roughness), + _metallic(copy._metallic), + _refractive_index(copy._refractive_index), + _flags(copy._flags & ~(F_attrib_lock | F_used_by_auto_shader)) { } /** @@ -99,8 +109,8 @@ get_ambient() const { */ INLINE void Material:: clear_ambient() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_ambient() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_ambient; _ambient = _base_color; @@ -129,8 +139,8 @@ get_diffuse() const { */ INLINE void Material:: clear_diffuse() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_diffuse() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_diffuse; _diffuse = _base_color * (1 - _metallic); @@ -177,8 +187,8 @@ get_emission() const { */ INLINE void Material:: clear_emission() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_emission() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_emission; _emission.set(0.0f, 0.0f, 0.0f, 0.0f); @@ -253,8 +263,8 @@ get_local() const { */ INLINE void Material:: set_local(bool local) { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (is_used_by_auto_shader() && get_local() != local) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } if (local) { _flags |= F_local; @@ -278,8 +288,8 @@ get_twoside() const { */ INLINE void Material:: set_twoside(bool twoside) { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (is_used_by_auto_shader() && get_twoside() != twoside) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } if (twoside) { _flags |= F_twoside; @@ -313,7 +323,7 @@ operator < (const Material &other) const { } /** - * + * @deprecated This no longer has any meaning in 1.10. */ INLINE bool Material:: is_attrib_locked() const { @@ -321,17 +331,35 @@ is_attrib_locked() const { } /** - * + * @deprecated This no longer has any meaning in 1.10. */ INLINE void Material:: set_attrib_lock() { _flags |= F_attrib_lock; } +/** + * Internal. Returns true if a shader has been generated that uses this. + */ +INLINE bool Material:: +is_used_by_auto_shader() const { + return (_flags & F_attrib_lock) != 0; +} + +/** + * Called by the shader generator to indicate that a shader has been generated + * that uses this material. + */ +INLINE void Material:: +mark_used_by_auto_shader() { + _flags |= F_used_by_auto_shader; +} + /** * */ INLINE int Material:: get_flags() const { - return _flags; + // F_used_by_auto_shader is an internal flag, ignore it. + return _flags & ~F_used_by_auto_shader; } diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 12d4f15365..24bc0fb590 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -28,6 +28,11 @@ PT(Material) Material::_default; void Material:: operator = (const Material ©) { Namable::operator = (copy); + + if (is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); + } + _base_color = copy._base_color; _ambient = copy._ambient; _diffuse = copy._diffuse; @@ -37,7 +42,7 @@ operator = (const Material ©) { _roughness = copy._roughness; _metallic = copy._metallic; _refractive_index = copy._refractive_index; - _flags = copy._flags & (~F_attrib_lock); + _flags = (copy._flags & ~(F_attrib_lock | F_used_by_auto_shader)) | (_flags & (F_attrib_lock | F_used_by_auto_shader)); } /** @@ -53,10 +58,8 @@ operator = (const Material ©) { */ void Material:: set_base_color(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_base_color) == 0) { - nassertv(!is_attrib_locked()); - } + if (!has_base_color() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _base_color = color; _flags |= F_base_color | F_metallic; @@ -81,8 +84,8 @@ set_base_color(const LColor &color) { */ void Material:: clear_base_color() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_base_color() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_base_color; _base_color.set(0.0f, 0.0f, 0.0f, 0.0f); @@ -116,10 +119,8 @@ clear_base_color() { */ void Material:: set_ambient(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_ambient)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_ambient() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _ambient = color; _flags |= F_ambient; @@ -137,10 +138,8 @@ set_ambient(const LColor &color) { */ void Material:: set_diffuse(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_diffuse)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_diffuse() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _diffuse = color; _flags |= F_diffuse; @@ -160,10 +159,8 @@ set_diffuse(const LColor &color) { */ void Material:: set_specular(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_specular)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_specular() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _specular = color; _flags |= F_specular; @@ -174,8 +171,8 @@ set_specular(const LColor &color) { */ void Material:: clear_specular() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_specular() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_specular; @@ -201,10 +198,8 @@ clear_specular() { */ void Material:: set_emission(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_emission)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_emission() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _emission = color; _flags |= F_emission; @@ -275,11 +270,6 @@ set_roughness(PN_stdfloat roughness) { */ void Material:: set_metallic(PN_stdfloat metallic) { - if (enforce_attrib_lock) { - if ((_flags & F_metallic) == 0) { - nassertv(!is_attrib_locked()); - } - } _metallic = metallic; _flags |= F_metallic; @@ -305,9 +295,6 @@ set_metallic(PN_stdfloat metallic) { */ void Material:: clear_metallic() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); - } _flags &= ~F_metallic; _metallic = 0; @@ -395,7 +382,7 @@ compare_to(const Material &other) const { * */ void Material:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Material " << get_name(); if (has_base_color()) { out << " c(" << get_base_color() << ")"; @@ -432,7 +419,7 @@ output(ostream &out) const { * */ void Material:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Material " << get_name() << "\n"; if (has_base_color()) { indent(out, indent_level + 2) << "base_color = " << get_ambient() << "\n"; @@ -482,7 +469,7 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); if (manager->get_file_minor_ver() >= 39) { - me.add_int32(_flags); + me.add_int32(_flags & ~F_used_by_auto_shader); if (_flags & F_metallic) { // Metalness workflow. @@ -570,4 +557,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { set_roughness(_shininess); } } + + if (is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); + } } diff --git a/panda/src/gobj/material.h b/panda/src/gobj/material.h index 5835a81ae3..259d5d6874 100644 --- a/panda/src/gobj/material.h +++ b/panda/src/gobj/material.h @@ -21,6 +21,7 @@ #include "luse.h" #include "numeric_types.h" #include "config_gobj.h" +#include "graphicsStateGuardianBase.h" class FactoryParams; @@ -127,7 +128,11 @@ PUBLISHED: MAKE_PROPERTY(local, get_local, set_local); MAKE_PROPERTY(twoside, get_twoside, set_twoside); +protected: + INLINE bool is_used_by_auto_shader() const; + public: + INLINE void mark_used_by_auto_shader(); INLINE int get_flags() const; enum Flags { @@ -142,6 +147,7 @@ public: F_metallic = 0x100, F_base_color = 0x200, F_refractive_index = 0x400, + F_used_by_auto_shader = 0x800, }; private: diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 58fec6dcbc..a2dd6c9064 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -22,7 +22,7 @@ MaterialPool *MaterialPool::_global_ptr = nullptr; * Lists the contents of the material pool to the indicated output stream. */ void MaterialPool:: -write(ostream &out) { +write(std::ostream &out) { get_global_ptr()->ns_list_contents(out); } @@ -100,7 +100,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void MaterialPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _materials.size() << " materials:\n"; diff --git a/panda/src/gobj/matrixLens.cxx b/panda/src/gobj/matrixLens.cxx index 147870a954..db647516c7 100644 --- a/panda/src/gobj/matrixLens.cxx +++ b/panda/src/gobj/matrixLens.cxx @@ -41,7 +41,7 @@ is_linear() const { * */ void MatrixLens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":\n"; get_projection_mat().write(out, indent_level + 2); } diff --git a/panda/src/gobj/orthographicLens.cxx b/panda/src/gobj/orthographicLens.cxx index 86c8fe0ef5..131903935a 100644 --- a/panda/src/gobj/orthographicLens.cxx +++ b/panda/src/gobj/orthographicLens.cxx @@ -49,7 +49,7 @@ is_orthographic() const { * */ void OrthographicLens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " film size = " << get_film_size() << "\n"; } diff --git a/panda/src/gobj/paramTexture.cxx b/panda/src/gobj/paramTexture.cxx index 7250cab5ec..892fe157c9 100644 --- a/panda/src/gobj/paramTexture.cxx +++ b/panda/src/gobj/paramTexture.cxx @@ -21,7 +21,7 @@ TypeHandle ParamTextureImage::_type_handle; * */ void ParamTextureSampler:: -output(ostream &out) const { +output(std::ostream &out) const { out << "texture "; if (_texture != nullptr) { @@ -96,7 +96,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ void ParamTextureImage:: -output(ostream &out) const { +output(std::ostream &out) const { out << "texture "; if (_texture != nullptr) { diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index 0fc83ec15b..160ae74aca 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -71,9 +71,14 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { PN_stdfloat fNear = do_get_near(lens_cdata); PN_stdfloat a, b; + // Take the limits if either near or far is infinite. if (cinf(fFar)) { a = 1; b = -2 * fNear; + } else if (cinf(fNear)) { + // This is valid if the near/far planes are inverted. + a = -1; + b = 2 * fFar; } else { PN_stdfloat far_minus_near = fFar-fNear; a = (fFar + fNear); diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index a77a8837d7..4f6ecea1ed 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -162,7 +162,7 @@ set_graphics_memory_limit(size_t limit) { * vertex buffers are allocated in the LRU. */ void PreparedGraphicsObjects:: -show_graphics_memory_lru(ostream &out) const { +show_graphics_memory_lru(std::ostream &out) const { _graphics_memory_lru.write(out, 0); } @@ -171,7 +171,7 @@ show_graphics_memory_lru(ostream &out) const { * vertex buffers are allocated in the LRU. */ void PreparedGraphicsObjects:: -show_residency_trackers(ostream &out) const { +show_residency_trackers(std::ostream &out) const { out << "Textures:\n"; _texture_residency.write(out, 2); @@ -204,7 +204,7 @@ PT(PreparedGraphicsObjects::EnqueuedObject) PreparedGraphicsObjects:: enqueue_texture_future(Texture *tex) { ReMutexHolder holder(_lock); - pair result = + std::pair result = _enqueued_textures.insert(EnqueuedTextures::value_type(tex, nullptr)); if (result.first->second == nullptr) { result.first->second = new EnqueuedObject(this, tex); @@ -713,7 +713,7 @@ PT(PreparedGraphicsObjects::EnqueuedObject) PreparedGraphicsObjects:: enqueue_shader_future(Shader *shader) { ReMutexHolder holder(_lock); - pair result = + std::pair result = _enqueued_shaders.insert(EnqueuedShaders::value_type(shader, nullptr)); if (result.first->second == nullptr) { result.first->second = new EnqueuedObject(this, shader); @@ -1668,10 +1668,10 @@ end_frame(Thread *current_thread) { /** * Returns a new, unique name for a newly-constructed object. */ -string PreparedGraphicsObjects:: +std::string PreparedGraphicsObjects:: init_name() { ++_name_index; - ostringstream strm; + std::ostringstream strm; strm << "context" << _name_index; return strm.str(); } diff --git a/panda/src/gobj/samplerContext.cxx b/panda/src/gobj/samplerContext.cxx index aad143c2fc..5b8d9b3322 100644 --- a/panda/src/gobj/samplerContext.cxx +++ b/panda/src/gobj/samplerContext.cxx @@ -19,7 +19,7 @@ TypeHandle SamplerContext::_type_handle; * */ void SamplerContext:: -output(ostream &out) const { +output(std::ostream &out) const { SavedContext::output(out); } @@ -27,6 +27,6 @@ output(ostream &out) const { * */ void SamplerContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/samplerState.cxx b/panda/src/gobj/samplerState.cxx index be8bd7b23d..9f1a5766bc 100644 --- a/panda/src/gobj/samplerState.cxx +++ b/panda/src/gobj/samplerState.cxx @@ -20,6 +20,8 @@ #include "samplerContext.h" #include "preparedGraphicsObjects.h" +using std::string; + TypeHandle SamplerState::_type_handle; SamplerState SamplerState::_default; @@ -283,7 +285,7 @@ compare_to(const SamplerState &other) const { * */ void SamplerState:: -output(ostream &out) const { +output(std::ostream &out) const { out << "sampler" << " wrap(u=" << _wrap_u << ", v=" << _wrap_v << ", w=" << _wrap_w @@ -298,7 +300,7 @@ output(ostream &out) const { * */ void SamplerState:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SamplerState\n"; indent(out, indent_level) << " wrap_u = " << _wrap_u << "\n"; indent(out, indent_level) << " wrap_v = " << _wrap_v << "\n"; diff --git a/panda/src/gobj/savedContext.cxx b/panda/src/gobj/savedContext.cxx index 2b93299121..92a1af46ca 100644 --- a/panda/src/gobj/savedContext.cxx +++ b/panda/src/gobj/savedContext.cxx @@ -20,7 +20,7 @@ TypeHandle SavedContext::_type_handle; * */ void SavedContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SavedContext " << this; } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void SavedContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 4f41cf57f1..220bd56ed2 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -27,6 +27,12 @@ #include #endif +using std::istream; +using std::move; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle Shader::_type_handle; Shader::ShaderTable Shader::_load_table; Shader::ShaderTable Shader::_make_table; @@ -613,12 +619,29 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, 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(); + //NB. Cg does have a CG_DOUBLE type, but at least for the ARB + // profiles and GLSL profiles it just maps to float. + switch (base_type) { + case CG_UINT: + case CG_ULONG: + case CG_USHORT: + case CG_UCHAR: + case CG_BOOL: + p._numeric_type = SPT_uint; + break; + case CG_INT: + case CG_LONG: + case CG_SHORT: + case CG_CHAR: + p._numeric_type = SPT_int; + break; + default: + p._numeric_type = SPT_float; + break; + } + success &= compile_parameter(p, arg_dim); break; } @@ -675,7 +698,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { ShaderVarSpec bind; bind._id = p._id; bind._append_uv = -1; - bind._integer = p._integer; + bind._numeric_type = p._numeric_type; if (pieces.size() == 2) { if (pieces[1] == "position") { @@ -2455,7 +2478,7 @@ bool Shader:: do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { if (_language == SL_GLSL && glsl_preprocess) { // Preprocess the GLSL file as we read it. - set open_files; + std::set open_files; ostringstream sstr; if (!r_preprocess_source(sstr, fn, Filename(), open_files, record)) { return false; @@ -2482,7 +2505,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { if (record != nullptr) { record->add_dependent_file(vf); } - _last_modified = max(_last_modified, vf->get_timestamp()); + _last_modified = std::max(_last_modified, vf->get_timestamp()); _source_files.push_back(vf->get_filename()); } @@ -2491,6 +2514,9 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { into.resize(into.size() - 1); } + // Except add back a newline at the end, which is needed by Intel drivers. + into += "\n"; + return true; } @@ -2504,7 +2530,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { bool Shader:: r_preprocess_source(ostream &out, const Filename &fn, const Filename &source_dir, - set &once_files, + std::set &once_files, BamCacheRecord *record, int depth) { if (depth > glsl_include_recursion_limit) { @@ -2543,7 +2569,7 @@ r_preprocess_source(ostream &out, const Filename &fn, if (record != nullptr) { record->add_dependent_file(vf); } - _last_modified = max(_last_modified, vf->get_timestamp()); + _last_modified = std::max(_last_modified, vf->get_timestamp()); _source_files.push_back(full_fn); // We give each file an unique index. This is so that we can identify a @@ -2646,7 +2672,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } char pragma[64]; - int nread = 0; + size_t nread = 0; // What kind of directive is it? if (strcmp(directive, "pragma") == 0 && sscanf(line.c_str(), " # pragma %63s", pragma) == 1) { @@ -2655,13 +2681,13 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn, source_dir; { char incfile[2048]; - if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %n", incfile, &nread) == 1 + if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %zn", incfile, &nread) == 1 && nread == line.size()) { // A regular include, with double quotes. Probably a local file. source_dir = full_fn.get_dirname(); incfn = incfile; - } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %n", incfile, &nread) == 1 + } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %zn", incfile, &nread) == 1 && nread == line.size()) { // Angled includes are also OK, but we don't search in the directory // of the source file. @@ -2690,7 +2716,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (strcmp(pragma, "once") == 0) { // Do a stricter syntax check, just to be extra safe. - if (sscanf(line.c_str(), " # pragma%*[ \t]once %n", &nread) != 0 || + if (sscanf(line.c_str(), " # pragma%*[ \t]once %zn", &nread) != 0 || nread != line.size()) { shader_cat.error() << "Malformed #pragma once at line " << lineno @@ -2782,7 +2808,7 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn; { char incfile[2048]; - if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %n", incfile, &nread) != 1 + if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %zn", incfile, &nread) != 1 || nread != line.size()) { // Couldn't parse it. shader_cat.error() @@ -2809,7 +2835,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (ext_google_line > 0 && strcmp(directive, "line") == 0) { // It's a #line directive. See if it uses a string instead of number. char filestr[2048]; - if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %n", &lineno, filestr, &nread) == 2 + if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %zn", &lineno, filestr, &nread) == 2 && nread == line.size()) { // Warn about extension use if requested. if (ext_google_line == 1) { @@ -3168,7 +3194,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { // It makes little sense to cache the shader before compilation, so we keep // the record for when we have the compiled the shader. - swap(shader->_record, record); + std::swap(shader->_record, record); shader->_cache_compiled_shader = BamCache::get_global_ptr()->get_cache_compiled_shaders(); shader->_fullpath = shader->_source_files[0]; return shader; @@ -3233,7 +3259,7 @@ make(string body, ShaderLanguage lang) { shader_cat.warning() << "Dumping shader: " << fn << "\n"; pofstream s; - s.open(fn.c_str(), ios::out | ios::trunc); + s.open(fn.c_str(), std::ios::out | std::ios::trunc); s << shader->get_text(); s.close(); } @@ -3408,8 +3434,7 @@ parse_eof() { */ PT(AsyncFuture) Shader:: prepare(PreparedGraphicsObjects *prepared_objects) { - PT(PreparedGraphicsObjects::EnqueuedObject) obj = prepared_objects->enqueue_shader_future(this); - return obj.p(); + return prepared_objects->enqueue_shader_future(this); } /** diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 8e65c005e9..99b8d45e53 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -331,6 +331,14 @@ public: int _seqno; }; + enum ShaderPtrType { + SPT_float, + SPT_double, + SPT_int, + SPT_uint, + SPT_unknown + }; + struct ShaderArgInfo { ShaderArgId _id; ShaderArgClass _class; @@ -338,17 +346,10 @@ public: ShaderArgType _type; ShaderArgDir _direction; bool _varying; - bool _integer; + ShaderPtrType _numeric_type; NotifyCategory *_cat; }; - enum ShaderPtrType { - SPT_float, - SPT_double, - SPT_int, - SPT_unknown - }; - // Container structure for data of parameters ShaderPtrSpec. struct ShaderPtrData { private: @@ -424,7 +425,7 @@ public: PT(InternalName) _name; int _append_uv; int _elements; - bool _integer; + ShaderPtrType _numeric_type; }; struct ShaderPtrSpec { diff --git a/panda/src/gobj/shaderBuffer.I b/panda/src/gobj/shaderBuffer.I index 59d62d0171..ccbd160521 100644 --- a/panda/src/gobj/shaderBuffer.I +++ b/panda/src/gobj/shaderBuffer.I @@ -19,8 +19,7 @@ INLINE ShaderBuffer:: ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint) : Namable(name), _data_size_bytes(size), - _usage_hint(usage_hint), - _contexts(nullptr) { + _usage_hint(usage_hint) { } /** @@ -32,8 +31,13 @@ ShaderBuffer(const std::string &name, vector_uchar initial_data, UsageHint usage Namable(name), _data_size_bytes(initial_data.size()), _usage_hint(usage_hint), - _initial_data(initial_data), - _contexts(nullptr) { + _initial_data(std::move(initial_data)) { + + // Make sure it is padded to 16 bytes. Some drivers like that. + if ((_initial_data.size() & 15u) != 0) { + _initial_data.resize((_initial_data.size() + 15u) & ~15u, 0); + _data_size_bytes = _initial_data.size(); + } } /** diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index da9dc37d4d..4e21319b49 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -28,7 +28,7 @@ ShaderBuffer:: * */ void ShaderBuffer:: -output(ostream &out) const { +output(std::ostream &out) const { out << "buffer " << get_name() << ", " << _data_size_bytes << "B, " << _usage_hint; } @@ -193,7 +193,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (scan.get_bool() && _data_size_bytes > 0) { nassertv_always(_data_size_bytes <= scan.get_remaining_size()); - _initial_data.resize(_data_size_bytes); + _initial_data.resize((_data_size_bytes + 15u) & ~15u); scan.extract_bytes(&_initial_data[0], _data_size_bytes); } else { _initial_data.clear(); diff --git a/panda/src/gobj/shaderBuffer.h b/panda/src/gobj/shaderBuffer.h index 69bdf985d9..bdf0538857 100644 --- a/panda/src/gobj/shaderBuffer.h +++ b/panda/src/gobj/shaderBuffer.h @@ -63,7 +63,7 @@ private: vector_uchar _initial_data; typedef pmap Contexts; - Contexts *_contexts; + Contexts *_contexts = nullptr; public: static void register_with_read_factory(); diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index 2129ba6681..1f8bf4e01c 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -32,9 +32,9 @@ SimpleAllocator(size_t max_size, Mutex &lock) : * pointer. */ SimpleAllocatorBlock *SimpleAllocator:: -alloc(size_t size) { +alloc(size_t size, size_t alignment) { MutexHolder holder(_lock); - return do_alloc(size); + return do_alloc(size, alignment); } /** @@ -148,6 +148,24 @@ SimpleAllocatorBlock(SimpleAllocator *alloc, { } +/** + * Transfers ownership from the given SimpleAllocatorBlock to this one. + */ +INLINE SimpleAllocatorBlock:: +SimpleAllocatorBlock(SimpleAllocatorBlock &&from) : + _allocator(from._allocator) +{ + if (_allocator == nullptr) { + return; + } + + MutexHolder holder(_allocator->_lock); + _start = from._start; + _size = from._size; + LinkedListNode::operator = (std::move(from)); + from._allocator = nullptr; +} + /** * The block automatically frees itself when it destructs. */ @@ -156,6 +174,28 @@ INLINE SimpleAllocatorBlock:: free(); } +/** + * Frees this block and instead takes ownership of the given other block. + */ +INLINE SimpleAllocatorBlock &SimpleAllocatorBlock:: +operator = (SimpleAllocatorBlock &&from) { + free(); + + _allocator = from._allocator; + if (_allocator == nullptr) { + _start = 0; + _size = 0; + return *this; + } + + MutexHolder holder(_allocator->_lock); + _start = from._start; + _size = from._size; + LinkedListNode::operator = (std::move(from)); + from._allocator = nullptr; + return *this; +} + /** * Releases the allocated space. */ diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index 5790f35428..fa6b20d1a3 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -13,6 +13,37 @@ #include "simpleAllocator.h" +/** + * Move constructor. + */ +SimpleAllocator:: +SimpleAllocator(SimpleAllocator &&from) noexcept : + LinkedListNode(std::move(from)), + _total_size(from._total_size), + _max_size(from._max_size), + _contiguous(from._contiguous), + _lock(from._lock) +{ + MutexHolder holder(_lock); + from._total_size = 0; + from._max_size = 0; + from._contiguous = 0; + + // We still need to leave the list in a valid state. + from._prev = &from; + from._next = &from; + + // Change all the blocks to point to the new allocator. + LinkedListNode *next = _next; + while (next != this) { + SimpleAllocatorBlock *block = (SimpleAllocatorBlock *)next; + nassertv(block->_allocator == &from); + block->_allocator = this; + + next = block->_next; + } +} + /** * */ @@ -32,7 +63,7 @@ SimpleAllocator:: * */ void SimpleAllocator:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; @@ -42,7 +73,7 @@ output(ostream &out) const { * */ void SimpleAllocator:: -write(ostream &out) const { +write(std::ostream &out) const { MutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; @@ -66,7 +97,7 @@ write(ostream &out) const { * Assumes the lock is already held. */ SimpleAllocatorBlock *SimpleAllocator:: -do_alloc(size_t size) { +do_alloc(size_t size, size_t alignment) { if (size > _contiguous) { // Don't even bother. return nullptr; @@ -86,9 +117,9 @@ do_alloc(size_t size) { // Scan until we have reached the last allocated block. while (block->_next != this) { SimpleAllocatorBlock *next = (SimpleAllocatorBlock *)block->_next; - size_t free_size = next->_start - end; - if (size <= free_size) { - SimpleAllocatorBlock *new_block = make_block(end, size); + size_t start = end + ((alignment - end) % alignment); + if (start + size <= next->_start) { + SimpleAllocatorBlock *new_block = make_block(start, size); nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(next); @@ -103,6 +134,7 @@ do_alloc(size_t size) { } return new_block; } + size_t free_size = next->_start - end; if (free_size > best) { best = free_size; } @@ -113,9 +145,9 @@ do_alloc(size_t size) { } // No free blocks; check for room at the end. - size_t free_size = _max_size - end; - if (size <= free_size) { - SimpleAllocatorBlock *new_block = make_block(end, size); + size_t start = end + ((alignment - end) % alignment); + if (start + size <= _max_size) { + SimpleAllocatorBlock *new_block = make_block(start, size); nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(this); @@ -131,6 +163,7 @@ do_alloc(size_t size) { return new_block; } + size_t free_size = _max_size - end; if (free_size > best) { best = free_size; } @@ -168,7 +201,7 @@ changed_contiguous() { * */ void SimpleAllocatorBlock:: -output(ostream &out) const { +output(std::ostream &out) const { if (_allocator == nullptr) { out << "free block\n"; } else { diff --git a/panda/src/gobj/simpleAllocator.h b/panda/src/gobj/simpleAllocator.h index 9e4cb7661b..5a9ca7b616 100644 --- a/panda/src/gobj/simpleAllocator.h +++ b/panda/src/gobj/simpleAllocator.h @@ -29,9 +29,10 @@ class SimpleAllocatorBlock; class EXPCL_PANDA_GOBJ SimpleAllocator : public LinkedListNode { PUBLISHED: INLINE explicit SimpleAllocator(size_t max_size, Mutex &lock); + SimpleAllocator(SimpleAllocator &&from) noexcept; virtual ~SimpleAllocator(); - INLINE SimpleAllocatorBlock *alloc(size_t size); + INLINE SimpleAllocatorBlock *alloc(size_t size, size_t alignment=1); INLINE bool is_empty() const; INLINE size_t get_total_size() const; @@ -45,7 +46,7 @@ PUBLISHED: void write(std::ostream &out) const; protected: - SimpleAllocatorBlock *do_alloc(size_t size); + SimpleAllocatorBlock *do_alloc(size_t size, size_t alignment=1); INLINE bool do_is_empty() const; virtual SimpleAllocatorBlock *make_block(size_t start, size_t size); @@ -91,6 +92,14 @@ protected: INLINE SimpleAllocatorBlock(SimpleAllocator *alloc, size_t start, size_t size); +public: + SimpleAllocatorBlock() = default; + SimpleAllocatorBlock(const SimpleAllocatorBlock ©) = delete; + INLINE SimpleAllocatorBlock(SimpleAllocatorBlock &&from); + + SimpleAllocatorBlock &operator = (const SimpleAllocatorBlock ©) = delete; + INLINE SimpleAllocatorBlock &operator = (SimpleAllocatorBlock &&from); + PUBLISHED: INLINE ~SimpleAllocatorBlock(); INLINE void free(); @@ -114,9 +123,9 @@ protected: INLINE bool do_realloc(size_t size); private: - SimpleAllocator *_allocator; - size_t _start; - size_t _size; + SimpleAllocator *_allocator = nullptr; + size_t _start = 0; + size_t _size = 0; friend class SimpleAllocator; }; diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index b24b48146c..dfdb9113da 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -14,6 +14,8 @@ #include "simpleLru.h" #include "indent.h" +using std::ostream; + // We define this as a reference to an allocated object, instead of as a // concrete object, so that it won't get destructed when the program exits. // (If it did, there would be an ordering issue between it and the various @@ -24,7 +26,7 @@ LightMutex &SimpleLru::_global_lock = *new LightMutex; * */ SimpleLru:: -SimpleLru(const string &name, size_t max_size) : +SimpleLru(const std::string &name, size_t max_size) : LinkedListNode(true), Namable(name) { diff --git a/panda/src/gobj/sliderTable.cxx b/panda/src/gobj/sliderTable.cxx index 169f023e3f..52ccdacc1c 100644 --- a/panda/src/gobj/sliderTable.cxx +++ b/panda/src/gobj/sliderTable.cxx @@ -124,7 +124,7 @@ add_slider(const VertexSlider *slider, const SparseArray &rows) { * */ void SliderTable:: -write(ostream &out) const { +write(std::ostream &out) const { for (size_t i = 0; i < _sliders.size(); ++i) { out << i << ". " << *_sliders[i]._slider << " " << _sliders[i]._rows << "\n"; diff --git a/panda/src/gobj/test_gobj.cxx b/panda/src/gobj/test_gobj.cxx deleted file mode 100644 index 74b408ec97..0000000000 --- a/panda/src/gobj/test_gobj.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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." - * - * @file test_gobj.cxx - * @author shochet - * @date 2000-02-02 - */ - -#include "geom.h" -#include "perspectiveProjection.h" - -int main() { - nout << "running test_gobj" << endl; - PT(GeomTri) triangle = new GeomTri; - Frustumf frust; - PT(PerspectiveProjection) proj = new PerspectiveProjection(frust); - LMatrix4f mat = proj->get_projection_mat(); - nout << "default proj matrix: " << mat; - return 0; -} diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index c766c5b82d..4abb480348 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2342,6 +2342,24 @@ get_unsigned_int(const unsigned char *&p) { return (double)v.ui / 4294967295.0; } +/** + * This is used by store() to retrieve the next consecutive component value + * from the indicated element of the array, which is taken to be an array of + * unsigned ints with the value packed in the 24 least significant bits. + */ +INLINE double Texture:: +get_unsigned_int_24(const unsigned char *&p) { + union { + uint32_t ui; + uint8_t uc[4]; + } v; + v.uc[0] = (*p++); + v.uc[1] = (*p++); + v.uc[2] = (*p++); + v.uc[3] = (*p++); + return (double)(v.ui & 0xffffff) / (double)0xffffff; +} + /** * This is used by store() to retrieve the next consecutive component value * from the indicated element of the array, which is taken to be an array of diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 2479105093..c538391018 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -49,6 +49,14 @@ #include +using std::endl; +using std::istream; +using std::max; +using std::min; +using std::ostream; +using std::string; +using std::swap; + ConfigVariableEnum texture_quality_level ("texture-quality-level", Texture::QL_normal, PRC_DESC("This specifies a global quality level for all textures. You " @@ -1419,8 +1427,7 @@ peek() { */ PT(AsyncFuture) Texture:: prepare(PreparedGraphicsObjects *prepared_objects) { - PT(PreparedGraphicsObjects::EnqueuedObject) obj = prepared_objects->enqueue_texture_future(this); - return obj.p(); + return prepared_objects->enqueue_texture_future(this); } /** @@ -3960,7 +3967,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) default: gobj_cat.error() << filename << ": unsupported texture compression (FourCC: 0x" - << hex << header.pf.four_cc << dec << ").\n"; + << std::hex << header.pf.four_cc << std::dec << ").\n"; return false; } @@ -4216,7 +4223,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } // See: https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - uint32_t gl_type, type_size, gl_format, internal_format, gl_base_format, + uint32_t gl_type, /*type_size,*/ gl_format, internal_format, gl_base_format, width, height, depth, num_array_elements, num_faces, num_mipmap_levels, kvdata_size; @@ -4224,7 +4231,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) if (ktx.get_uint32() == 0x04030201) { big_endian = false; gl_type = ktx.get_uint32(); - type_size = ktx.get_uint32(); + /*type_size = */ktx.get_uint32(); gl_format = ktx.get_uint32(); internal_format = ktx.get_uint32(); gl_base_format = ktx.get_uint32(); @@ -4238,7 +4245,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } else { big_endian = true; gl_type = ktx.get_be_uint32(); - type_size = ktx.get_be_uint32(); + /*type_size = */ktx.get_be_uint32(); gl_format = ktx.get_be_uint32(); internal_format = ktx.get_be_uint32(); gl_base_format = ktx.get_be_uint32(); @@ -4432,8 +4439,8 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) if (base_format != gl_base_format) { gobj_cat.error() << filename << " has internal format that is incompatible with base " - "format (0x" << hex << gl_base_format << ", expected 0x" - << base_format << dec << ")\n"; + "format (0x" << std::hex << gl_base_format << ", expected 0x" + << base_format << std::dec << ")\n"; return false; } @@ -4895,14 +4902,14 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } } - do_set_ram_mipmap_image(cdata, (int)n, move(image), + do_set_ram_mipmap_image(cdata, (int)n, std::move(image), row_size * do_get_expected_mipmap_y_size(cdata, (int)n)); } else { // Compressed image. We'll trust that the file has the right size. image = PTA_uchar::empty_array(image_size); ktx.extract_bytes(image.p(), image_size); - do_set_ram_mipmap_image(cdata, (int)n, move(image), image_size / depth); + do_set_ram_mipmap_image(cdata, (int)n, std::move(image), image_size / depth); } ktx.skip_bytes(3 - ((image_size + 3) & 3)); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 852f618c81..7cb5f305fb 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -858,6 +858,7 @@ private: INLINE static double get_unsigned_byte(const unsigned char *&p); INLINE static double get_unsigned_short(const unsigned char *&p); INLINE static double get_unsigned_int(const unsigned char *&p); + INLINE static double get_unsigned_int_24(const unsigned char *&p); INLINE static double get_float(const unsigned char *&p); INLINE static double get_half_float(const unsigned char *&p); diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index 16c6a908f6..57f91a8ef8 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -181,7 +181,7 @@ reserve(size_t num) { * NULL if no texture has that name. */ Texture *TextureCollection:: -find_texture(const string &name) const { +find_texture(const std::string &name) const { int num_textures = get_num_textures(); for (int i = 0; i < num_textures; i++) { Texture *texture = get_texture(i); @@ -235,7 +235,7 @@ size() const { * indicated output stream. */ void TextureCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_textures() == 1) { out << "1 Texture"; } else { @@ -248,7 +248,7 @@ output(ostream &out) const { * indicated output stream. */ void TextureCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_textures(); i++) { indent(out, indent_level) << *get_texture(i) << "\n"; } diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx index 233249ee6f..127bba9ac5 100644 --- a/panda/src/gobj/textureCollection_ext.cxx +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -44,9 +44,9 @@ __init__(PyObject *self, PyObject *sequence) { DTOOL_Call_ExtractThisPointerForType(item, &Dtool_Texture, (void **)&tex); if (tex == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; + std::ostringstream stream; stream << "Element " << i << " in sequence passed to TextureCollection constructor is not a Texture"; - string str = stream.str(); + std::string str = stream.str(); PyErr_SetString(PyExc_TypeError, str.c_str()); Py_DECREF(fast); return; diff --git a/panda/src/gobj/textureContext.cxx b/panda/src/gobj/textureContext.cxx index 32224a7bde..7a83a17a01 100644 --- a/panda/src/gobj/textureContext.cxx +++ b/panda/src/gobj/textureContext.cxx @@ -40,7 +40,7 @@ get_native_buffer_id() const { * */ void TextureContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_texture() << ", " << get_data_size_bytes(); } @@ -48,6 +48,6 @@ output(ostream &out) const { * */ void TextureContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index b4e1be9224..7bb17ab87a 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -94,6 +94,10 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { _get_component = Texture::get_half_float; break; + case Texture::T_unsigned_int_24_8: + _get_component = Texture::get_unsigned_int_24; + break; + default: // Not supported. _image.clear(); @@ -108,6 +112,8 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { case Texture::F_depth_component32: case Texture::F_red: case Texture::F_r16: + case Texture::F_r32: + case Texture::F_r32i: _get_texel = get_texel_r; break; @@ -178,7 +184,7 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { default: // Not supported. gobj_cat.error() << "Unsupported texture peeker format: " - << Texture::format_format(_format) << endl; + << Texture::format_format(_format) << std::endl; _image.clear(); return; } diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index 6ff48f14d3..1c25485f51 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -275,3 +275,23 @@ PT(Texture) TexturePool:: make_texture(const std::string &extension) { return get_global_ptr()->ns_make_texture(extension); } + +/** + * Defines relative ordering between LookupKey instances. + */ +INLINE bool TexturePool::LookupKey:: +operator < (const LookupKey &other) const { + if (_fullpath != other._fullpath) { + return _fullpath < other._fullpath; + } + if (_alpha_fullpath != other._alpha_fullpath) { + return _alpha_fullpath < other._alpha_fullpath; + } + if (_primary_file_num_channels != other._primary_file_num_channels) { + return _primary_file_num_channels < other._primary_file_num_channels; + } + if (_alpha_file_channel != other._alpha_file_channel) { + return _alpha_file_channel < other._alpha_file_channel; + } + return _texture_type < other._texture_type; +} diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index 1b39a24273..c09df1d9e3 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -28,6 +28,10 @@ #include "mutexHolder.h" #include "dcast.h" +using std::istream; +using std::ostream; +using std::string; + TexturePool *TexturePool::_global_ptr; /** @@ -128,7 +132,7 @@ write_texture_types(ostream &out, int indent_level) const { PT(Texture) tex = func(); string name = tex->get_type().get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) + indent(out, std::max(30 - (int)name.length(), 0)) << " ." << extension << "\n"; } } @@ -173,16 +177,23 @@ bool TexturePool:: ns_has_texture(const Filename &orig_filename) { MutexHolder holder(_lock); - Filename filename; - resolve_filename(filename, orig_filename, false, LoaderOptions()); + LookupKey key; + resolve_filename(key._fullpath, orig_filename, false, LoaderOptions()); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. return true; } + // It might still have been loaded with non-standard settings. + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + if (ti->first._fullpath == key._fullpath) { + return true; + } + } + return false; } @@ -192,13 +203,14 @@ ns_has_texture(const Filename &orig_filename) { Texture *TexturePool:: ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions &options) { - Filename filename; - + LookupKey key; + key._primary_file_num_channels = primary_file_num_channels; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); + Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -218,54 +230,54 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading texture " << filename << "\n"; + << "Loading texture " << key._fullpath << "\n"; - string ext = downcase(filename.get_extension()); + string ext = downcase(key._fullpath.get_extension()); if (ext == "txo" || ext == "bam") { // Assume this is a txo file, which might conceivably contain a movie // file or some other subclass of Texture. In that case, use // make_from_txo() to load it instead of read(). VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - filename.set_binary(); - PT(VirtualFile) file = vfs->get_file(filename); + key._fullpath.set_binary(); + PT(VirtualFile) file = vfs->get_file(key._fullpath); if (file == nullptr) { // No such file. gobj_cat.error() - << "Could not find " << filename << "\n"; + << "Could not find " << key._fullpath << "\n"; return nullptr; } if (gobj_cat.is_debug()) { gobj_cat.debug() - << "Reading texture object " << filename << "\n"; + << "Reading texture object " << key._fullpath << "\n"; } istream *in = file->open_read_file(true); - tex = Texture::make_from_txo(*in, filename); + tex = Texture::make_from_txo(*in, key._fullpath); vfs->close_read_file(in); if (tex == nullptr) { return nullptr; } - tex->set_fullpath(filename); + tex->set_fullpath(key._fullpath); tex->clear_alpha_fullpath(); tex->set_keep_ram_image(false); } else { // Read it the conventional way. tex = ns_make_texture(ext); - if (!tex->read(filename, Filename(), primary_file_num_channels, 0, + if (!tex->read(key._fullpath, Filename(), primary_file_num_channels, 0, 0, 0, false, read_mipmaps, record, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } } @@ -300,8 +312,8 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); @@ -309,7 +321,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, // Now look again--someone may have just loaded this texture in another // thread. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -317,7 +329,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -353,16 +365,16 @@ ns_load_texture(const Filename &orig_filename, read_mipmaps, options); } - Filename filename; - Filename alpha_filename; - + LookupKey key; + key._primary_file_num_channels = primary_file_num_channels; + key._alpha_file_channel = alpha_file_channel; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); - resolve_filename(alpha_filename, orig_alpha_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); + resolve_filename(key._alpha_fullpath, orig_alpha_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -376,26 +388,26 @@ ns_load_texture(const Filename &orig_filename, bool store_record = false; // Can one of our texture filters supply the texture? - tex = pre_load(orig_filename, alpha_filename, primary_file_num_channels, + tex = pre_load(orig_filename, orig_alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading texture " << filename << " and alpha component " - << alpha_filename << endl; - tex = ns_make_texture(filename.get_extension()); - if (!tex->read(filename, alpha_filename, primary_file_num_channels, + << "Loading texture " << key._fullpath << " and alpha component " + << key._alpha_fullpath << std::endl; + tex = ns_make_texture(key._fullpath.get_extension()); + if (!tex->read(key._fullpath, key._alpha_fullpath, primary_file_num_channels, alpha_file_channel, 0, 0, false, read_mipmaps, nullptr, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } @@ -429,17 +441,17 @@ ns_load_texture(const Filename &orig_filename, // Set the original filenames, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); - tex->set_fullpath(filename); + tex->set_fullpath(key._fullpath); tex->set_alpha_filename(orig_alpha_filename); - tex->set_alpha_fullpath(alpha_filename); - tex->_texture_pool_key = filename; + tex->set_alpha_fullpath(key._alpha_fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -447,7 +459,7 @@ ns_load_texture(const Filename &orig_filename, return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -478,18 +490,19 @@ ns_load_3d_texture(const Filename &filename_pattern, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; + LookupKey key; + key._texture_type = Texture::TT_3d_texture; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_3d_texture) { - // This texture was previously loaded, as a 3d texture - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -499,7 +512,7 @@ ns_load_3d_texture(const Filename &filename_pattern, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -507,12 +520,12 @@ ns_load_3d_texture(const Filename &filename_pattern, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading 3-d texture " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading 3-d texture " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_3d_texture(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -541,23 +554,23 @@ ns_load_3d_texture(const Filename &filename_pattern, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_3d_texture) { - // This texture was previously loaded, as a 3d texture - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -579,21 +592,19 @@ ns_load_2d_texture_array(const Filename &filename_pattern, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; - Filename unique_filename; //differentiate 3d-textures from 2d-texture arrays + LookupKey key; + key._texture_type = Texture::TT_2d_texture_array; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); - // Differentiate from preloaded 3d textures - unique_filename = filename + ".2DARRAY"; + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(unique_filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_2d_texture_array) { - // This texture was previously loaded, as a 2d texture array - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -603,7 +614,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -611,12 +622,12 @@ ns_load_2d_texture_array(const Filename &filename_pattern, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading 2-d texture array " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading 2-d texture array " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_2d_texture_array(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -645,23 +656,23 @@ ns_load_2d_texture_array(const Filename &filename_pattern, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = unique_filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(unique_filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_2d_texture_array) { - // This texture was previously loaded, as a 2d texture array - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[unique_filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -683,16 +694,19 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; + LookupKey key; + key._texture_type = Texture::TT_cube_map; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. - return (*ti).second; + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -702,7 +716,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -710,12 +724,12 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading cube map texture " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading cube map texture " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_cube_map(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -744,21 +758,23 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. - return (*ti).second; + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -815,15 +831,22 @@ ns_add_texture(Texture *tex) { if (!tex->_texture_pool_key.empty()) { ns_release_texture(tex); } - string filename = tex->get_fullpath(); - if (filename.empty()) { + + Texture::CDReader tex_cdata(tex->_cycler); + if (tex_cdata->_fullpath.empty()) { gobj_cat.error() << "Attempt to call add_texture() on an unnamed texture.\n"; + return; } + LookupKey key; + key._fullpath = tex_cdata->_fullpath; + key._alpha_fullpath = tex_cdata->_alpha_fullpath; + key._alpha_file_channel = tex_cdata->_alpha_file_channel; + key._texture_type = tex_cdata->_texture_type; + // We blow away whatever texture was there previously, if any. - tex->_texture_pool_key = filename; - _textures[filename] = tex; - nassertv(!tex->get_fullpath().empty()); + tex->_texture_pool_key = key._fullpath; + _textures[key] = tex; } /** @@ -833,13 +856,13 @@ void TexturePool:: ns_release_texture(Texture *tex) { MutexHolder holder(_lock); - if (!tex->_texture_pool_key.empty()) { - Textures::iterator ti; - ti = _textures.find(tex->_texture_pool_key); - if (ti != _textures.end() && (*ti).second == tex) { + Textures::iterator ti; + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + if (tex == (*ti).second) { _textures.erase(ti); + tex->_texture_pool_key = string(); + break; } - tex->_texture_pool_key = string(); } // Blow away the cache of resolved relative filenames. @@ -882,7 +905,7 @@ ns_garbage_collect() { if (tex->get_ref_count() == 1) { if (gobj_cat.is_debug()) { gobj_cat.debug() - << "Releasing " << (*ti).first << "\n"; + << "Releasing " << (*ti).first._fullpath << "\n"; } ++num_released; tex->_texture_pool_key = string(); @@ -923,14 +946,14 @@ ns_list_contents(ostream &out) const { total_ram_size = 0; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { Texture *tex = (*ti).second; - out << (*ti).first << "\n"; + out << (*ti).first._fullpath << "\n"; out << " (count = " << tex->get_ref_count() << ", ram = " << tex->get_ram_image_size() << ", size = " << tex->get_ram_page_size() << ", w = " << tex->get_x_size() << ", h = " << tex->get_y_size() << ")\n"; - nassertv(tex->_texture_pool_key == (*ti).first); + nassertv(tex->_texture_pool_key == (*ti).first._fullpath); total_ram_size += tex->get_ram_image_size(); total_size += tex->get_ram_page_size(); } @@ -1245,11 +1268,11 @@ load_filters() { Filename dlname = Filename::dso_filename("lib" + name + ".so"); gobj_cat->info() - << "loading texture filter: " << dlname.to_os_specific() << endl; + << "loading texture filter: " << dlname.to_os_specific() << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { gobj_cat.info() - << "Unable to load: " << load_dso_error() << endl; + << "Unable to load: " << load_dso_error() << std::endl; } } } diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index 866374ec96..de6812e4d5 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -149,8 +149,17 @@ private: static TexturePool *_global_ptr; Mutex _lock; - typedef pmap Textures; - Textures _textures; // indexed by fullpath + struct LookupKey { + Filename _fullpath; + Filename _alpha_fullpath; + int _primary_file_num_channels = 0; + int _alpha_file_channel = 0; + Texture::TextureType _texture_type = Texture::TT_2d_texture; + + INLINE bool operator < (const LookupKey &other) const; + }; + typedef pmap Textures; + Textures _textures; typedef pmap RelpathLookup; RelpathLookup _relpath_lookup; diff --git a/panda/src/gobj/texturePoolFilter.cxx b/panda/src/gobj/texturePoolFilter.cxx index f0b98c877e..c63803860c 100644 --- a/panda/src/gobj/texturePoolFilter.cxx +++ b/panda/src/gobj/texturePoolFilter.cxx @@ -51,6 +51,6 @@ post_load(Texture *tex) { * */ void TexturePoolFilter:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/gobj/textureStage.cxx b/panda/src/gobj/textureStage.cxx index 120bb4feb3..4fecd20999 100644 --- a/panda/src/gobj/textureStage.cxx +++ b/panda/src/gobj/textureStage.cxx @@ -16,6 +16,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::ostream; + PT(TextureStage) TextureStage::_default_stage; UpdateSeq TextureStage::_sort_seq; @@ -25,7 +27,7 @@ TypeHandle TextureStage::_type_handle; * Initialize the texture stage at construction */ TextureStage:: -TextureStage(const string &name) : _used_by_auto_shader(false) { +TextureStage(const std::string &name) : _used_by_auto_shader(false) { _name = name; _sort = 0; _priority = 0; diff --git a/panda/src/gobj/textureStagePool.cxx b/panda/src/gobj/textureStagePool.cxx index f47addd52b..01e009ef7c 100644 --- a/panda/src/gobj/textureStagePool.cxx +++ b/panda/src/gobj/textureStagePool.cxx @@ -17,6 +17,10 @@ #include "configVariableEnum.h" #include "string_utils.h" +using std::istream; +using std::ostream; +using std::string; + TextureStagePool *TextureStagePool::_global_ptr = nullptr; diff --git a/panda/src/gobj/texture_ext.cxx b/panda/src/gobj/texture_ext.cxx index 3cd291843f..9af792be08 100644 --- a/panda/src/gobj/texture_ext.cxx +++ b/panda/src/gobj/texture_ext.cxx @@ -77,7 +77,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image(move(data), compression, page_size); + _this->set_ram_image(std::move(data), compression, page_size); PyBuffer_Release(&view); return; @@ -102,7 +102,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(buffer_len, Texture::get_class_type()); memcpy(data.p(), buffer, buffer_len); - _this->set_ram_image(move(data), compression, page_size); + _this->set_ram_image(std::move(data), compression, page_size); return; } #endif @@ -117,7 +117,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, * support compressed image data or sub-pages; use set_ram_image() for that. */ void Extension:: -set_ram_image_as(PyObject *image, const string &provided_format) { +set_ram_image_as(PyObject *image, const std::string &provided_format) { // Check if perhaps a PointerToArray object was passed in. if (DtoolInstance_Check(image)) { if (DtoolInstance_TYPE(image) == &Dtool_ConstPointerToArray_unsigned_char) { @@ -155,7 +155,7 @@ set_ram_image_as(PyObject *image, const string &provided_format) { PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image_as(move(data), provided_format); + _this->set_ram_image_as(std::move(data), provided_format); PyBuffer_Release(&view); return; diff --git a/panda/src/gobj/transformBlend.cxx b/panda/src/gobj/transformBlend.cxx index 656a691a95..9ca70390e2 100644 --- a/panda/src/gobj/transformBlend.cxx +++ b/panda/src/gobj/transformBlend.cxx @@ -54,7 +54,7 @@ add_transform(const VertexTransform *transform, PN_stdfloat weight) { TransformEntry entry; entry._transform = transform; entry._weight = weight; - pair result = _entries.insert(entry); + std::pair result = _entries.insert(entry); if (!result.second) { // If the new value was not inserted, it was already there; increment // the existing weight factor. @@ -168,7 +168,7 @@ get_weight(const VertexTransform *transform) const { * */ void TransformBlend:: -output(ostream &out) const { +output(std::ostream &out) const { if (_entries.empty()) { out << "empty"; } else { @@ -186,7 +186,7 @@ output(ostream &out) const { * */ void TransformBlend:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Thread *current_thread = Thread::get_current_thread(); Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { @@ -218,7 +218,7 @@ recompute_result(CData *cdata, Thread *current_thread) { UpdateSeq seq; Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { - seq = max(seq, (*ei)._transform->get_modified(current_thread)); + seq = std::max(seq, (*ei)._transform->get_modified(current_thread)); } if (cdata->_modified != seq) { diff --git a/panda/src/gobj/transformBlendTable.cxx b/panda/src/gobj/transformBlendTable.cxx index da76d38626..266da16c3b 100644 --- a/panda/src/gobj/transformBlendTable.cxx +++ b/panda/src/gobj/transformBlendTable.cxx @@ -107,7 +107,7 @@ add_blend(const TransformBlend &blend) { // latest. const TransformBlend &added_blend = _blends[new_position]; _blend_index[&added_blend] = new_position; - _max_simultaneous_transforms = max(_max_simultaneous_transforms, + _max_simultaneous_transforms = std::max(_max_simultaneous_transforms, (int)blend.get_num_transforms()); // We can't compute this one as we go, so set it to a special value to @@ -122,7 +122,7 @@ add_blend(const TransformBlend &blend) { * */ void TransformBlendTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < _blends.size(); ++i) { indent(out, indent_level) << i << ". " << _blends[i] << "\n"; @@ -158,7 +158,7 @@ rebuild_index() { for (size_t ti = 0; ti < blend.get_num_transforms(); ++ti) { transforms.insert(blend.get_transform(ti)); } - _max_simultaneous_transforms = max((size_t)_max_simultaneous_transforms, + _max_simultaneous_transforms = std::max((size_t)_max_simultaneous_transforms, blend.get_num_transforms()); } @@ -179,7 +179,7 @@ recompute_modified(TransformBlendTable::CData *cdata, Thread *current_thread) { UpdateSeq seq; Blends::const_iterator bi; for (bi = _blends.begin(); bi != _blends.end(); ++bi) { - seq = max(seq, (*bi).get_modified(current_thread)); + seq = std::max(seq, (*bi).get_modified(current_thread)); } cdata->_modified = seq; diff --git a/panda/src/gobj/transformTable.cxx b/panda/src/gobj/transformTable.cxx index df66f7a696..3ddadca33a 100644 --- a/panda/src/gobj/transformTable.cxx +++ b/panda/src/gobj/transformTable.cxx @@ -111,7 +111,7 @@ add_transform(const VertexTransform *transform) { * */ void TransformTable:: -write(ostream &out) const { +write(std::ostream &out) const { for (size_t i = 0; i < _transforms.size(); ++i) { out << i << ". " << *_transforms[i] << "\n"; } diff --git a/panda/src/gobj/userVertexSlider.cxx b/panda/src/gobj/userVertexSlider.cxx index d6363082a8..a868be2058 100644 --- a/panda/src/gobj/userVertexSlider.cxx +++ b/panda/src/gobj/userVertexSlider.cxx @@ -21,7 +21,7 @@ TypeHandle UserVertexSlider::_type_handle; * */ UserVertexSlider:: -UserVertexSlider(const string &name) : +UserVertexSlider(const std::string &name) : VertexSlider(InternalName::make(name)) { } diff --git a/panda/src/gobj/userVertexTransform.cxx b/panda/src/gobj/userVertexTransform.cxx index d83aeb4c8a..c27cb38d61 100644 --- a/panda/src/gobj/userVertexTransform.cxx +++ b/panda/src/gobj/userVertexTransform.cxx @@ -21,7 +21,7 @@ TypeHandle UserVertexTransform::_type_handle; * */ UserVertexTransform:: -UserVertexTransform(const string &name) : +UserVertexTransform(const std::string &name) : _name(name) { } @@ -39,7 +39,7 @@ get_matrix(LMatrix4 &matrix) const { * */ void UserVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } diff --git a/panda/src/gobj/vertexBufferContext.cxx b/panda/src/gobj/vertexBufferContext.cxx index cde6ec023a..b0eab66a74 100644 --- a/panda/src/gobj/vertexBufferContext.cxx +++ b/panda/src/gobj/vertexBufferContext.cxx @@ -20,7 +20,7 @@ TypeHandle VertexBufferContext::_type_handle; * */ void VertexBufferContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void VertexBufferContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index a891811091..e1d3ad5c56 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -102,7 +102,7 @@ do_clean_realloc(size_t reserved_size) { _reserved_size = reserved_size; } - _size = min(_size, _reserved_size); + _size = std::min(_size, _reserved_size); } /** diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index e7adb80d33..74e58edb58 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -211,7 +211,7 @@ flush_threads() { * */ void VertexDataPage:: -output(ostream &out) const { +output(std::ostream &out) const { SimpleAllocator::output(out); } @@ -219,7 +219,7 @@ output(ostream &out) const { * */ void VertexDataPage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SimpleAllocator::write(out); } @@ -391,7 +391,7 @@ make_resident() { while (result != Z_STREAM_END) { unsigned char *start_out = (unsigned char *)z_source.next_out; nassertv(start_out < end_data); - z_source.avail_out = min((size_t)(end_data - start_out), (size_t)inflate_page_size); + z_source.avail_out = std::min((size_t)(end_data - start_out), (size_t)inflate_page_size); nassertv(z_source.avail_out != 0); result = inflate(&z_source, flush); if (result < 0 && result != Z_BUF_ERROR) { @@ -884,7 +884,7 @@ start_threads(int num_threads) { _threads.reserve(num_threads); for (int i = 0; i < num_threads; ++i) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "VertexDataPage" << _threads.size(); PT(PageThread) thread = new PageThread(this, name_strm.str()); thread->start(TP_low, true); @@ -919,7 +919,7 @@ stop_threads() { * */ VertexDataPage::PageThread:: -PageThread(PageThreadManager *manager, const string &name) : +PageThread(PageThreadManager *manager, const std::string &name) : Thread(name, name), _manager(manager), _working_cvar(_tlock) diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index 97a77688a8..37839099dc 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -28,11 +28,14 @@ #include #endif +using std::dec; +using std::hex; + /** * */ VertexDataSaveFile:: -VertexDataSaveFile(const Filename &directory, const string &prefix, +VertexDataSaveFile(const Filename &directory, const std::string &prefix, size_t max_size) : SimpleAllocator(max_size, _lock) { @@ -50,12 +53,12 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, int index = 0; while (true) { ++index; - ostringstream strm; + std::ostringstream strm; strm << prefix << "_" << index << ".dat"; - string basename = strm.str(); + std::string basename = strm.str(); _filename = Filename(dir, basename); - string os_specific = _filename.to_os_specific(); + std::string os_specific = _filename.to_os_specific(); if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -201,7 +204,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { PT(VertexDataSaveBlock) block = (VertexDataSaveBlock *)SimpleAllocator::do_alloc(size); if (block != nullptr) { - _total_file_size = max(_total_file_size, block->get_start() + size); + _total_file_size = std::max(_total_file_size, block->get_start() + size); block->set_compressed(compressed); #ifdef _WIN32 diff --git a/panda/src/gobj/vertexSlider.cxx b/panda/src/gobj/vertexSlider.cxx index 86d841ad53..bc05232eb2 100644 --- a/panda/src/gobj/vertexSlider.cxx +++ b/panda/src/gobj/vertexSlider.cxx @@ -40,7 +40,7 @@ VertexSlider:: * */ void VertexSlider:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << *get_name(); } @@ -48,7 +48,7 @@ output(ostream &out) const { * */ void VertexSlider:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << " = " << get_slider() << "\n"; } diff --git a/panda/src/gobj/vertexTransform.cxx b/panda/src/gobj/vertexTransform.cxx index 35a60bd25a..972584b527 100644 --- a/panda/src/gobj/vertexTransform.cxx +++ b/panda/src/gobj/vertexTransform.cxx @@ -68,7 +68,7 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { * */ void VertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -76,7 +76,7 @@ output(ostream &out) const { * */ void VertexTransform:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; LMatrix4 mat; diff --git a/panda/src/gobj/videoTexture.cxx b/panda/src/gobj/videoTexture.cxx index 0cde2d98f6..a3b5e2c72b 100644 --- a/panda/src/gobj/videoTexture.cxx +++ b/panda/src/gobj/videoTexture.cxx @@ -23,7 +23,7 @@ TypeHandle VideoTexture::_type_handle; * */ VideoTexture:: -VideoTexture(const string &name) : +VideoTexture(const std::string &name) : Texture(name) { // We don't want to try to compress each frame as it's loaded. @@ -104,8 +104,8 @@ set_video_size(int video_width, int video_height) { Texture::CDWriter cdata(Texture::_cycler, true); do_set_pad_size(cdata, - max(cdata->_x_size - _video_width, 0), - max(cdata->_y_size - _video_height, 0), + std::max(cdata->_x_size - _video_width, 0), + std::max(cdata->_y_size - _video_height, 0), 0); } @@ -181,7 +181,7 @@ do_can_reload(const Texture::CData *cdata) const { */ bool VideoTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const { AutoTextureScale ats = do_get_auto_texture_scale(cdata_tex); if (ats != ATS_none) { diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index 1b68d1482a..33f6fc88ad 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -133,7 +133,7 @@ generate() { gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** diff --git a/panda/src/grutil/fisheyeMaker.cxx b/panda/src/grutil/fisheyeMaker.cxx index f245242aec..5e7d7395ec 100644 --- a/panda/src/grutil/fisheyeMaker.cxx +++ b/panda/src/grutil/fisheyeMaker.cxx @@ -177,7 +177,7 @@ generate() { int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { - int piece_end = min(ring_size + 1, piece_size + 1 + vi); + int piece_end = std::min(ring_size + 1, piece_size + 1 + vi); for (int pi = vi; pi < piece_end; ++pi) { tristrips->add_vertex(last_ring_vertex + pi % last_ring_size); tristrips->add_vertex(ring_vertex + pi % ring_size); @@ -284,7 +284,7 @@ generate() { int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { - int piece_end = min(ring_size + 1, piece_size + 1 + vi); + int piece_end = std::min(ring_size + 1, piece_size + 1 + vi); for (int pi = vi; pi < piece_end; ++pi) { tristrips->add_vertex(last_ring_vertex + pi % last_ring_size); tristrips->add_vertex(ring_vertex + pi % ring_size); @@ -322,7 +322,7 @@ generate() { } } - return geom_node.p(); + return geom_node; } /** diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 0b9fc9d1bb..f015e0ab55 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -31,7 +31,7 @@ TypeHandle FrameRateMeter::_type_handle; * */ FrameRateMeter:: -FrameRateMeter(const string &name) : +FrameRateMeter(const std::string &name) : TextNode(name), _last_aspect_ratio(-1) { diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index a627ac11f7..457e55d901 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -29,6 +29,9 @@ #include "collideMask.h" +using std::max; +using std::min; + static ConfigVariableBool geomipterrain_incorrect_normals ("geomipterrain-incorrect-normals", false, PRC_DESC("If true, uses the incorrect normal vector calculation that " @@ -256,7 +259,7 @@ generate_block(unsigned short mx, geom->add_primitive(prim); geom->set_bounds_type(BoundingVolume::BT_box); - ostringstream sname; + std::ostringstream sname; sname << "gmm" << mx << "x" << my; PT(GeomNode) node = new GeomNode(sname.str()); node->add_geom(geom); diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index 7e53416855..534c1f5700 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -29,7 +29,7 @@ * which will render the described path. */ LineSegs:: -LineSegs(const string &name) : Namable(name) { +LineSegs(const std::string &name) : Namable(name) { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _thick = 1.0f; } diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 44f3d541d4..36f4913085 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -35,7 +35,7 @@ TypeHandle MovieTexture::_type_handle; * do_load_one. */ MovieTexture:: -MovieTexture(const string &name) : +MovieTexture(const std::string &name) : Texture(name) { } @@ -141,6 +141,7 @@ void MovieTexture:: do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const LoaderOptions &options) { int x_max = 1; int y_max = 1; + bool rgb = false; bool alpha = false; double len = 0.0; @@ -150,7 +151,8 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L if (t->size_x() > x_max) x_max = t->size_x(); if (t->size_y() > y_max) y_max = t->size_y(); if (t->length() > len) len = t->length(); - if (t->get_num_components() == 4) alpha=true; + if (t->get_num_components() >= 3) rgb=true; + if (t->get_num_components() == 4 || t->get_num_components() == 2) alpha=true; } t = cdata->_pages[i]._alpha; if (t) { @@ -167,15 +169,16 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L do_adjust_this_size(cdata_tex, x_max, y_max, get_name(), true); - do_reconsider_image_properties(cdata_tex, x_max, y_max, alpha?4:3, + int num_components = (rgb ? 3 : 1) + alpha; + do_reconsider_image_properties(cdata_tex, x_max, y_max, num_components, T_unsigned_byte, cdata->_pages.size(), options); cdata_tex->_orig_file_x_size = cdata->_video_width; cdata_tex->_orig_file_y_size = cdata->_video_height; do_set_pad_size(cdata_tex, - max(cdata_tex->_x_size - cdata_tex->_orig_file_x_size, 0), - max(cdata_tex->_y_size - cdata_tex->_orig_file_y_size, 0), + std::max(cdata_tex->_x_size - cdata_tex->_orig_file_x_size, 0), + std::max(cdata_tex->_y_size - cdata_tex->_orig_file_y_size, 0), 0); } @@ -185,7 +188,7 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L */ bool MovieTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const { AutoTextureScale ats = do_get_auto_texture_scale(cdata_tex); if (ats != ATS_none) { @@ -282,7 +285,7 @@ do_load_one(Texture::CData *cdata_tex, */ bool MovieTexture:: do_load_one(Texture::CData *cdata_tex, - const PNMImage &pnmimage, const string &name, int z, int n, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options) { grutil_cat.error() << "You cannot load a static image into a MovieTexture\n"; return false; @@ -406,7 +409,7 @@ make_copy_impl() const { CDWriter cdata_copy(copy->_cycler, true); copy->do_assign(cdata_copy, cdata_copy_tex, this, cdata, cdata_tex); - return copy.p(); + return copy; } /** @@ -531,7 +534,7 @@ play() { void MovieTexture:: set_time(double t) { CDWriter cdata(_cycler); - t = min(cdata->_video_length, max(0.0, t)); + t = std::min(cdata->_video_length, std::max(0.0, t)); if (cdata->_playing) { double now = ClockObject::get_global_clock()->get_frame_time(); cdata->_clock = t - (now * cdata->_play_rate); diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 5d76ade23a..fdad25bb48 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -37,6 +37,9 @@ #include "geomVertexWriter.h" #include "geomVertexReader.h" +using std::max; +using std::min; + /** * */ @@ -236,7 +239,7 @@ flatten(GraphicsOutput *window) { window); static int multitex_id = 1; - ostringstream multitex_name_strm; + std::ostringstream multitex_name_strm; multitex_name_strm << "multitex" << multitex_id; multitex_id++; @@ -437,7 +440,7 @@ scan_geom_node(GeomNode *node, const RenderState *state, if (grutil_cat.is_debug()) { grutil_cat.debug() << "geom " << gi << " net_state =\n"; - geom_net_state->write(cerr, 2); + geom_net_state->write(std::cerr, 2); } // Get out the net TextureAttrib and TexMatrixAttrib from the state. diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index 5fb44d6cc1..7d4cb2deac 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -46,7 +46,7 @@ get_matrix(LMatrix4 &matrix) const { * */ void NodeVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { if (_prev != nullptr) { _prev->output(out); out << " * "; diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 4d1a65d416..f3d60787a8 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -23,6 +23,9 @@ #include "pnmImage.h" #include "config_grutil.h" +using std::max; +using std::min; + /** * The PfmVizzer constructor receives a reference to a PfmFile which it will * operate on. It does not keep ownership of this reference; it is your @@ -777,7 +780,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { num_vertices = x_size * y_size; max_indices = (x_size - 1) * (y_size - 1) * 6; - ostringstream mesh_name; + std::ostringstream mesh_name; mesh_name << "mesh_" << xci << "_" << yci; PT(GeomVertexData) vdata = new GeomVertexData (mesh_name.str(), format, Geom::UH_static); diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index 44f2971aa5..fb2c3959ab 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/panda/src/grutil/rigidBodyCombiner.cxx @@ -30,7 +30,7 @@ TypeHandle RigidBodyCombiner::_type_handle; * */ RigidBodyCombiner:: -RigidBodyCombiner(const string &name) : PandaNode(name) { +RigidBodyCombiner(const std::string &name) : PandaNode(name) { set_cull_callback(); _internal_root = new PandaNode(name); diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index 9881575f62..02d6ed3709 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -29,7 +29,7 @@ TypeHandle SceneGraphAnalyzerMeter::_type_handle; * */ SceneGraphAnalyzerMeter:: -SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { +SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node) : TextNode(name) { set_cull_callback(); Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index d5ecdf21e2..44c8397279 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -34,6 +34,10 @@ #include "config_grutil.h" #include "typeHandle.h" +using std::endl; +using std::max; +using std::min; + ConfigVariableBool stm_use_hexagonal_layout ("stm-use-hexagonal-layout", false, PRC_DESC("Set this to true to use a hexagonal vertex layout. This approximates " @@ -542,7 +546,7 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat state = state->set_attrib(current_shader_attrib, 10000); // Emit chunk - CullableObject *object = new CullableObject(_chunk_geom, move(state), move(modelview_transform)); + CullableObject *object = new CullableObject(_chunk_geom, std::move(state), std::move(modelview_transform)); trav->get_cull_handler()->record_object(object, trav); // After rendering, increment the view index diff --git a/panda/src/iphone/iphone_runappmf_src.mm b/panda/src/iphone/iphone_runappmf_src.mm index 40479f894f..56d97e8364 100644 --- a/panda/src/iphone/iphone_runappmf_src.mm +++ b/panda/src/iphone/iphone_runappmf_src.mm @@ -15,7 +15,6 @@ #include #include #include -using namespace std; #include "pnotify.h" diff --git a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm index dba09cbcc9..82e92f4b70 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm @@ -51,7 +51,7 @@ IPhoneGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string IPhoneGraphicsPipe:: +std::string IPhoneGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } diff --git a/panda/src/linmath/coordinateSystem.cxx b/panda/src/linmath/coordinateSystem.cxx index 6eb81077ca..b94b0ec4ff 100644 --- a/panda/src/linmath/coordinateSystem.cxx +++ b/panda/src/linmath/coordinateSystem.cxx @@ -21,6 +21,11 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + static ConfigVariableEnum default_cs ("coordinate-system", CS_zup_right, PRC_DESC("The default coordinate system to use throughout Panda for " diff --git a/panda/src/linmath/coordinateSystem.h b/panda/src/linmath/coordinateSystem.h index 313645a35e..b365297f84 100644 --- a/panda/src/linmath/coordinateSystem.h +++ b/panda/src/linmath/coordinateSystem.h @@ -26,10 +26,10 @@ enum CoordinateSystem { // turn is loaded from the config variable "coordinate-system". CS_default, - CS_zup_right, - CS_yup_right, - CS_zup_left, - CS_yup_left, + CS_zup_right, // Z-Up, Right-handed + CS_yup_right, // Y-Up, Right-handed + CS_zup_left, // Z-Up, Left-handed + CS_yup_left, // Y-Up, Left-handed // CS_invalid is not a coordinate system at all. It can be used in user- // input processing code to indicate a contradictory coordinate system diff --git a/panda/src/linmath/lmatrix3_src.cxx b/panda/src/linmath/lmatrix3_src.cxx index e21160b2fd..e654b3accd 100644 --- a/panda/src/linmath/lmatrix3_src.cxx +++ b/panda/src/linmath/lmatrix3_src.cxx @@ -326,7 +326,7 @@ almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { * */ void FLOATNAME(LMatrix3):: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " @@ -346,7 +346,7 @@ output(ostream &out) const { * */ void FLOATNAME(LMatrix3):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " diff --git a/panda/src/linmath/lmatrix4_src.cxx b/panda/src/linmath/lmatrix4_src.cxx index 427841965f..0a1d5a6a0e 100644 --- a/panda/src/linmath/lmatrix4_src.cxx +++ b/panda/src/linmath/lmatrix4_src.cxx @@ -306,7 +306,7 @@ almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { * */ void FLOATNAME(LMatrix4):: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " @@ -334,7 +334,7 @@ output(ostream &out) const { * */ void FLOATNAME(LMatrix4):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " diff --git a/panda/src/linmath/lsimpleMatrix.I b/panda/src/linmath/lsimpleMatrix.I index 7ce8b4ed69..6d322bfb75 100644 --- a/panda/src/linmath/lsimpleMatrix.I +++ b/panda/src/linmath/lsimpleMatrix.I @@ -11,33 +11,6 @@ * @date 2011-12-15 */ -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix() { - // No default initialization. -} - -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix(const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - -/** - * - */ -template -INLINE void LSimpleMatrix:: -operator = (const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - /** * */ diff --git a/panda/src/linmath/lsimpleMatrix.h b/panda/src/linmath/lsimpleMatrix.h index 3228caf5bb..faeecd9516 100644 --- a/panda/src/linmath/lsimpleMatrix.h +++ b/panda/src/linmath/lsimpleMatrix.h @@ -28,9 +28,6 @@ template class LSimpleMatrix { public: - INLINE LSimpleMatrix(); - INLINE LSimpleMatrix(const LSimpleMatrix ©); - INLINE void operator = (const LSimpleMatrix ©); INLINE const FloatType &operator () (int row, int col) const; INLINE FloatType &operator () (int row, int col); INLINE const FloatType &operator () (int col) const; diff --git a/panda/src/linmath/test_math.cxx b/panda/src/linmath/test_math.cxx index 41d1d15431..5a92f433d2 100644 --- a/panda/src/linmath/test_math.cxx +++ b/panda/src/linmath/test_math.cxx @@ -19,6 +19,10 @@ #include "pnotify.h" #include +using std::cerr; +using std::cout; +using std::endl; + void test() { LMatrix4f x = LMatrix4f::ident_mat(); LMatrix4f y = LMatrix4f::ident_mat(); diff --git a/panda/src/mathutil/boundingBox.cxx b/panda/src/mathutil/boundingBox.cxx index e2ce9c6c6a..1f0a1b7758 100644 --- a/panda/src/mathutil/boundingBox.cxx +++ b/panda/src/mathutil/boundingBox.cxx @@ -22,6 +22,9 @@ #include #include +using std::max; +using std::min; + const int BoundingBox::plane_def[6][3] = { { 0, 4, 5 }, { 4, 6, 7 }, @@ -111,7 +114,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingBox:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bbox, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingHexahedron.cxx b/panda/src/mathutil/boundingHexahedron.cxx index b765f043b0..7046215821 100644 --- a/panda/src/mathutil/boundingHexahedron.cxx +++ b/panda/src/mathutil/boundingHexahedron.cxx @@ -14,11 +14,15 @@ #include "boundingHexahedron.h" #include "boundingSphere.h" #include "boundingBox.h" +#include "boundingPlane.h" #include "config_mathutil.h" #include #include +using std::max; +using std::min; + TypeHandle BoundingHexahedron::_type_handle; /** @@ -151,7 +155,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingHexahedron:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bhexahedron, empty"; } else if (is_infinite()) { @@ -165,7 +169,7 @@ output(ostream &out) const { * */ void BoundingHexahedron:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "bhexahedron, empty\n"; } else if (is_infinite()) { @@ -353,6 +357,14 @@ contains_box(const BoundingBox *box) const { return result; } +/** + * + */ +int BoundingHexahedron:: +contains_plane(const BoundingPlane *plane) const { + return plane->contains_hexahedron(this) & ~IF_all; +} + /** * */ diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index ac87135509..de09e03dac 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -79,6 +79,7 @@ protected: virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; + virtual int contains_plane(const BoundingPlane *plane) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; private: diff --git a/panda/src/mathutil/boundingLine.cxx b/panda/src/mathutil/boundingLine.cxx index 38dd4704a5..93de2f6d5e 100644 --- a/panda/src/mathutil/boundingLine.cxx +++ b/panda/src/mathutil/boundingLine.cxx @@ -60,7 +60,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingLine:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bline, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingPlane.cxx b/panda/src/mathutil/boundingPlane.cxx index b0a36ab3e3..5c2ee9b386 100644 --- a/panda/src/mathutil/boundingPlane.cxx +++ b/panda/src/mathutil/boundingPlane.cxx @@ -53,7 +53,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingPlane:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bplane, empty"; } else if (is_infinite()) { @@ -202,7 +202,29 @@ contains_line(const BoundingLine *line) const { */ int BoundingPlane:: contains_plane(const BoundingPlane *plane) const { - return IF_possible; + // We assume the plane normals are normalized. + LPlane other_plane = plane->get_plane(); + PN_stdfloat dot = _plane.get_normal().dot(other_plane.get_normal()); + if (dot >= 1.0) { + // The planes are parallel, with the same normal. + if (_plane.get_w() <= other_plane.get_w()) { + return IF_possible | IF_some | IF_all; + } else { + return IF_possible | IF_some; + } + + } else if (dot <= -1.0) { + // The planes are opposing. + if (_plane.get_w() >= -other_plane.get_w()) { + return IF_no_intersection; + } else { + return IF_possible | IF_some; + } + + } else { + // The planes are not parallel, so they inevitably intersect. + return IF_possible | IF_some; + } } /** diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index 82e02870a0..ecfdfea4ca 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -42,6 +42,8 @@ public: PUBLISHED: INLINE_MATHUTIL const LPlane &get_plane() const; + MAKE_PROPERTY(plane, get_plane); + public: virtual const BoundingPlane *as_bounding_plane() const; @@ -82,6 +84,7 @@ private: friend class BoundingSphere; friend class BoundingBox; + friend class BoundingHexahedron; }; #include "boundingPlane.I" diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index a0754b9b55..32e48adad9 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -22,6 +22,9 @@ #include +using std::max; +using std::min; + TypeHandle BoundingSphere::_type_handle; /** @@ -116,7 +119,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingSphere:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bsphere, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingVolume.cxx b/panda/src/mathutil/boundingVolume.cxx index d81f905e25..a806dc819b 100644 --- a/panda/src/mathutil/boundingVolume.cxx +++ b/panda/src/mathutil/boundingVolume.cxx @@ -24,6 +24,10 @@ #include "indent.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle BoundingVolume::_type_handle; diff --git a/panda/src/mathutil/frustum_src.I b/panda/src/mathutil/frustum_src.I index f76d5bec53..f884b29f45 100644 --- a/panda/src/mathutil/frustum_src.I +++ b/panda/src/mathutil/frustum_src.I @@ -140,7 +140,6 @@ get_perspective_projection_mat(CoordinateSystem cs) const { cs = get_default_coordinate_system(); } - FLOATTYPE recip_far_minus_near = 1.0f/(_ffar - _fnear); FLOATTYPE recip_r_minus_l = 1.0f/(_r - _l); FLOATTYPE recip_t_minus_b = 1.0f/(_t - _b); FLOATTYPE two_fnear = 2.0f*_fnear; @@ -149,8 +148,20 @@ get_perspective_projection_mat(CoordinateSystem cs) const { FLOATTYPE a = two_fnear * recip_r_minus_l; FLOATTYPE e = two_fnear * recip_t_minus_b; FLOATTYPE b = (_t + _b) * recip_t_minus_b; - FLOATTYPE c = (_ffar + _fnear) * recip_far_minus_near; - FLOATTYPE f = -_ffar * two_fnear * recip_far_minus_near; + FLOATTYPE c, f; + + // Take the limits if either near or far is infinite. + if (cinf(_ffar)) { + c = 1; + f = -2 * _fnear; + } else if (cinf(_fnear)) { + c = -1; + f = 2 * _ffar; + } else { + FLOATTYPE recip_far_minus_near = 1.0f / (_ffar - _fnear); + c = (_ffar + _fnear) * recip_far_minus_near; + f = -_ffar * two_fnear * recip_far_minus_near; + } /* FLOATTYPE a = (2.0f * _fnear) / (_r - _l); diff --git a/panda/src/mathutil/intersectionBoundingVolume.cxx b/panda/src/mathutil/intersectionBoundingVolume.cxx index a8af2d2b97..334cb428fe 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.cxx +++ b/panda/src/mathutil/intersectionBoundingVolume.cxx @@ -74,7 +74,7 @@ xform(const LMatrix4 &mat) { * */ void IntersectionBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "intersection, empty"; } else if (is_infinite()) { @@ -94,7 +94,7 @@ output(ostream &out) const { * */ void IntersectionBoundingVolume:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "intersection, empty\n"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/omniBoundingVolume.cxx b/panda/src/mathutil/omniBoundingVolume.cxx index 65e556b767..687374c1be 100644 --- a/panda/src/mathutil/omniBoundingVolume.cxx +++ b/panda/src/mathutil/omniBoundingVolume.cxx @@ -46,7 +46,7 @@ xform(const LMatrix4 &) { * */ void OmniBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { out << "omni"; } diff --git a/panda/src/mathutil/parabola_src.cxx b/panda/src/mathutil/parabola_src.cxx index a695a89c31..437ab012e5 100644 --- a/panda/src/mathutil/parabola_src.cxx +++ b/panda/src/mathutil/parabola_src.cxx @@ -27,7 +27,7 @@ xform(const FLOATNAME(LMatrix4) &mat) { * */ void FLOATNAME(LParabola):: -output(ostream &out) const { +output(std::ostream &out) const { out << "LParabola(" << _a << ", " << _b << ", " << _c << ")"; } @@ -35,7 +35,7 @@ output(ostream &out) const { * */ void FLOATNAME(LParabola):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/mathutil/plane_src.I b/panda/src/mathutil/plane_src.I index f357b34e60..7ea0acc828 100644 --- a/panda/src/mathutil/plane_src.I +++ b/panda/src/mathutil/plane_src.I @@ -137,6 +137,37 @@ dist_to_plane(const FLOATNAME(LPoint3) &point) const { return (_v(0) * point[0] + _v(1) * point[1] + _v(2) * point[2] + _v(3)); } +/** + * Normalizes the plane in place. Returns true if the plane was normalized, + * false if the plane had a zero-length normal vector. + */ +INLINE_MATHUTIL bool FLOATNAME(LPlane):: +normalize() { + FLOATTYPE l2 = get_normal().length_squared(); + if (l2 == (FLOATTYPE)0.0f) { + return false; + + } else if (!IS_THRESHOLD_EQUAL(l2, 1.0f, NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE))) { + (*this) /= csqrt(l2); + } + + return true; +} + +/** + * Normalizes the plane and returns the normalized plane as a copy. If the + * plane's normal was a zero-length vector, the same plane is returned. + */ +INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane):: +normalized() const { + FLOATTYPE l2 = get_normal().length_squared(); + if (l2 != (FLOATTYPE)0.0f) { + return (*this) / csqrt(l2); + } else { + return (*this); + } +} + /** * Returns the point within the plane nearest to the indicated point in space. */ diff --git a/panda/src/mathutil/plane_src.cxx b/panda/src/mathutil/plane_src.cxx index 3a3baff375..7ba18701c6 100644 --- a/panda/src/mathutil/plane_src.cxx +++ b/panda/src/mathutil/plane_src.cxx @@ -145,7 +145,7 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, * */ void FLOATNAME(LPlane):: -output(ostream &out) const { +output(std::ostream &out) const { out << "LPlane("; FLOATNAME(LVecBase4)::output(out); out << ")"; @@ -155,6 +155,6 @@ output(ostream &out) const { * */ void FLOATNAME(LPlane):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/mathutil/plane_src.h b/panda/src/mathutil/plane_src.h index c3301aa641..c1dffc4d5d 100644 --- a/panda/src/mathutil/plane_src.h +++ b/panda/src/mathutil/plane_src.h @@ -39,6 +39,9 @@ PUBLISHED: FLOATNAME(LPoint3) get_point() const; INLINE_MATHUTIL FLOATTYPE dist_to_plane(const FLOATNAME(LPoint3) &point) const; + + INLINE_MATHUTIL bool normalize(); + INLINE_MATHUTIL FLOATNAME(LPlane) normalized() const; INLINE_MATHUTIL FLOATNAME(LPoint3) project(const FLOATNAME(LPoint3) &point) const; INLINE_MATHUTIL void flip(); diff --git a/panda/src/mathutil/test_tri.cxx b/panda/src/mathutil/test_tri.cxx index 57852b3773..e09b86fc21 100644 --- a/panda/src/mathutil/test_tri.cxx +++ b/panda/src/mathutil/test_tri.cxx @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { t.triangulate(); for (int i = 0; i < t.get_num_triangles(); ++i) { - cerr << "tri: " << t.get_triangle_v0(i) << " " + std::cerr << "tri: " << t.get_triangle_v0(i) << " " << t.get_triangle_v1(i) << " " << t.get_triangle_v2(i) << "\n"; } diff --git a/panda/src/mathutil/unionBoundingVolume.cxx b/panda/src/mathutil/unionBoundingVolume.cxx index ed575b518b..2c4d7c41a9 100644 --- a/panda/src/mathutil/unionBoundingVolume.cxx +++ b/panda/src/mathutil/unionBoundingVolume.cxx @@ -74,7 +74,7 @@ xform(const LMatrix4 &mat) { * */ void UnionBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "union, empty"; } else if (is_infinite()) { @@ -94,7 +94,7 @@ output(ostream &out) const { * */ void UnionBoundingVolume:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "union, empty\n"; } else if (is_infinite()) { diff --git a/panda/src/movies/flacAudio.cxx b/panda/src/movies/flacAudio.cxx index b7c205b25b..07f41ca350 100644 --- a/panda/src/movies/flacAudio.cxx +++ b/panda/src/movies/flacAudio.cxx @@ -41,7 +41,7 @@ FlacAudio:: PT(MovieAudioCursor) FlacAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/flacAudioCursor.cxx b/panda/src/movies/flacAudioCursor.cxx index e30fbfba8f..19eb71cbc9 100644 --- a/panda/src/movies/flacAudioCursor.cxx +++ b/panda/src/movies/flacAudioCursor.cxx @@ -25,7 +25,7 @@ extern "C" { * Callback passed to dr_flac to implement file I/O via the VirtualFileSystem. */ static size_t cb_read_proc(void *user, void *buffer, size_t size) { - istream *stream = (istream *)user; + std::istream *stream = (std::istream *)user; nassertr(stream != nullptr, false); stream->read((char *)buffer, size); @@ -42,10 +42,10 @@ static size_t cb_read_proc(void *user, void *buffer, size_t size) { * Callback passed to dr_flac to implement file I/O via the VirtualFileSystem. */ static bool cb_seek_proc(void *user, int offset) { - istream *stream = (istream *)user; + std::istream *stream = (std::istream *)user; nassertr(stream != nullptr, false); - stream->seekg(offset, ios::cur); + stream->seekg(offset, std::ios::cur); return !stream->fail(); } @@ -56,7 +56,7 @@ TypeHandle FlacAudioCursor::_type_handle; * pointer positioned at the start of the data. */ FlacAudioCursor:: -FlacAudioCursor(FlacAudio *src, istream *stream) : +FlacAudioCursor(FlacAudio *src, std::istream *stream) : MovieAudioCursor(src), _is_valid(false), _drflac(nullptr) @@ -99,7 +99,7 @@ FlacAudioCursor:: */ void FlacAudioCursor:: seek(double t) { - t = max(t, 0.0); + t = std::max(t, 0.0); uint64_t sample = t * _drflac->sampleRate; diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index cea9c65f60..1ce78b0209 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -149,7 +149,7 @@ find_all_microphones_ds() { stat = waveInOpen(nullptr, i, &format, 0, 0, WAVE_FORMAT_QUERY); if (stat == MMSYSERR_NOERROR) { PT(MicrophoneAudioDS) p = new MicrophoneAudioDS(); - ostringstream name; + std::ostringstream name; name << "WaveIn: " << caps.szPname << " Chan:" << chan << " HZ:" << freq; p->set_name(name.str()); p->_device_id = i; diff --git a/panda/src/movies/movieAudio.cxx b/panda/src/movies/movieAudio.cxx index 0dee90e805..6843984ac3 100644 --- a/panda/src/movies/movieAudio.cxx +++ b/panda/src/movies/movieAudio.cxx @@ -24,7 +24,7 @@ TypeHandle MovieAudio::_type_handle; * construct a subclass of this class. */ MovieAudio:: -MovieAudio(const string &name) : +MovieAudio(const std::string &name) : Namable(name) { } diff --git a/panda/src/movies/movieAudioCursor.cxx b/panda/src/movies/movieAudioCursor.cxx index f386401103..33acc0e10c 100644 --- a/panda/src/movies/movieAudioCursor.cxx +++ b/panda/src/movies/movieAudioCursor.cxx @@ -92,9 +92,9 @@ read_samples(int n, Datagram *dg) { * This is not particularly efficient, but it may be a convenient way to * manipulate samples in python. */ -string MovieAudioCursor:: +std::string MovieAudioCursor:: read_samples(int n) { - ostringstream result; + std::ostringstream result; int16_t tmp[4096]; while (n > 0) { int blocksize = (4096 / _audio_channels); diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 024cf53634..012deff1cd 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -17,6 +17,9 @@ #include "config_putil.h" #include "load_dso.h" +using std::endl; +using std::string; + MovieTypeRegistry *MovieTypeRegistry::_global_ptr = nullptr; /** diff --git a/panda/src/movies/movieVideo.cxx b/panda/src/movies/movieVideo.cxx index cdeb797213..57b755a453 100644 --- a/panda/src/movies/movieVideo.cxx +++ b/panda/src/movies/movieVideo.cxx @@ -26,7 +26,7 @@ TypeHandle MovieVideo::_type_handle; * need to construct a subclass of this class. */ MovieVideo:: -MovieVideo(const string &name) : +MovieVideo(const std::string &name) : Namable(name) { } diff --git a/panda/src/movies/movieVideoCursor.cxx b/panda/src/movies/movieVideoCursor.cxx index 761e7e2fa6..96ead8c8f0 100644 --- a/panda/src/movies/movieVideoCursor.cxx +++ b/panda/src/movies/movieVideoCursor.cxx @@ -60,7 +60,21 @@ setup_texture(Texture *tex) const { int fullx = size_x(); int fully = size_y(); tex->adjust_this_size(fullx, fully, tex->get_name(), true); - Texture::Format fmt = (get_num_components() == 4) ? Texture::F_rgba : Texture::F_rgb; + Texture::Format fmt; + switch (get_num_components()) { + case 1: + fmt = Texture::F_luminance; + break; + case 2: + fmt = Texture::F_luminance_alpha; + break; + default: + fmt = Texture::F_rgb; + break; + case 4: + fmt = Texture::F_rgba; + break; + } tex->setup_texture(Texture::TT_2d_texture, fullx, fully, 1, Texture::T_unsigned_byte, fmt); tex->set_pad_size(fullx - size_x(), fully - size_y()); } @@ -113,7 +127,9 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { nassertv(t->get_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv((t->get_num_components() == 3) || (t->get_num_components() == 4)); + nassertv((t->get_num_components() == 3) || (t->get_num_components() == 4) || + (t->get_num_components() == 1 && get_num_components() == 1) || + (t->get_num_components() == 2 && get_num_components() == 2)); nassertv(t->get_component_width() == 1); nassertv(page < t->get_num_pages()); @@ -132,17 +148,19 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { } else { unsigned char *p = buffer->_block; - if (t->get_num_components() == get_num_components()) { - int src_stride = size_x() * get_num_components(); - int dst_stride = t->get_x_size() * t->get_num_components(); + int src_width = get_num_components(); + int dst_width = t->get_num_components(); + if (src_width == dst_width) { + int src_stride = src_width * size_x(); + int dst_stride = dst_width * t->get_x_size(); for (int y=0; yget_num_components(); + nassertv(src_width >= 3); + nassertv(dst_width >= 3); for (int y = 0; y < size_y(); ++y) { for (int x = 0; x < size_x(); ++x) { data[0] = p[0]; @@ -168,9 +186,20 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src PStatTimer timer(_copy_pcollector); + // Is this a grayscale texture? + if (get_num_components() < 3) { + if (get_num_components() == 1 || alpha_src < 2 || alpha_src == 3) { + // There's only one "RGB" channel to take from. + alpha_src = 1; + } else { + // Alpha is actually in the second channel for grayscale-alpha. + alpha_src = 2; + } + } + nassertv(t->get_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv(t->get_num_components() == 4); + nassertv(t->get_num_components() == 4 || t->get_num_components() == 2); nassertv(t->get_component_width() == 1); nassertv(page < t->get_z_size()); nassertv((alpha_src >= 0) && (alpha_src <= get_num_components())); @@ -186,14 +215,16 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src PStatTimer timer2(_copy_pcollector_copy); int src_width = get_num_components(); + int dst_width = t->get_num_components(); int src_stride = size_x() * src_width; - int dst_stride = t->get_x_size() * 4; + int dst_stride = t->get_x_size() * dst_width; unsigned char *p = buffer->_block; if (alpha_src == 0) { + nassertv(src_width >= 3); for (int y=0; yget_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv(t->get_num_components() == 4); + nassertv(t->get_num_components() == 4 || t->get_num_components() == 2); nassertv(t->get_component_width() == 1); nassertv(page < t->get_z_size()); @@ -238,18 +269,35 @@ apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { unsigned char *data = img.p() + page * t->get_expected_ram_page_size(); PStatTimer timer2(_copy_pcollector_copy); - int src_stride = size_x() * get_num_components(); int src_width = get_num_components(); - int dst_stride = t->get_x_size() * 4; + int dst_width = t->get_num_components(); + int src_stride = size_x() * src_width; + int dst_stride = t->get_x_size() * dst_width; unsigned char *p = buffer->_block; - for (int y=0; y= 3) { + // It has RGB values. + nassertv(dst_width >= 3); + for (int y = 0; y < size_y(); ++y) { + for (int x = 0; x < size_x(); ++x) { + data[x * dst_width + 0] = p[x * src_width + 0]; + data[x * dst_width + 1] = p[x * src_width + 1]; + data[x * dst_width + 2] = p[x * src_width + 2]; + } + data += dst_stride; + p += src_stride; + } + } else if (dst_width == 4) { + // It has only grayscale. + for (int y = 0; y < size_y(); ++y) { + for (int x = 0; x < size_x(); ++x) { + unsigned char gray = p[x * src_width]; + data[x * dst_width + 0] = gray; + data[x * dst_width + 1] = gray; + data[x * dst_width + 2] = gray; + } + data += dst_stride; + p += src_stride; } - data += dst_stride; - p += src_stride; } } diff --git a/panda/src/movies/opusAudio.cxx b/panda/src/movies/opusAudio.cxx index 024560156a..54be404cd2 100644 --- a/panda/src/movies/opusAudio.cxx +++ b/panda/src/movies/opusAudio.cxx @@ -43,7 +43,7 @@ OpusAudio:: PT(MovieAudioCursor) OpusAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/opusAudioCursor.cxx b/panda/src/movies/opusAudioCursor.cxx index 698648c5cb..2b1591e971 100644 --- a/panda/src/movies/opusAudioCursor.cxx +++ b/panda/src/movies/opusAudioCursor.cxx @@ -18,6 +18,8 @@ #include +using std::istream; + /** * Callbacks passed to libopusfile to implement file I/O via the * VirtualFileSystem. @@ -46,15 +48,15 @@ int cb_seek(void *stream, opus_int64 offset, int whence) { switch (whence) { case SEEK_SET: - in->seekg(offset, ios::beg); + in->seekg(offset, std::ios::beg); break; case SEEK_CUR: - in->seekg(offset, ios::cur); + in->seekg(offset, std::ios::cur); break; case SEEK_END: - in->seekg(offset, ios::end); + in->seekg(offset, std::ios::end); break; default: @@ -165,7 +167,7 @@ seek(double t) { return; } - t = max(t, 0.0); + t = std::max(t, 0.0); // Use op_time_seek_lap if cross-lapping is enabled. int error = op_pcm_seek(_op, (ogg_int64_t)(t * 48000.0)); diff --git a/panda/src/movies/userDataAudio.cxx b/panda/src/movies/userDataAudio.cxx index 81865e3b8b..f02726d10b 100644 --- a/panda/src/movies/userDataAudio.cxx +++ b/panda/src/movies/userDataAudio.cxx @@ -107,7 +107,7 @@ append(DatagramIterator *src, int n) { * but it may be convenient to deal with samples in python. */ void UserDataAudio:: -append(const string &str) { +append(const std::string &str) { nassertv(!_aborted); int samples = str.size() / (2 * _desired_channels); int words = samples * _desired_channels; diff --git a/panda/src/movies/vorbisAudio.cxx b/panda/src/movies/vorbisAudio.cxx index b3e32c84f4..db4c70b000 100644 --- a/panda/src/movies/vorbisAudio.cxx +++ b/panda/src/movies/vorbisAudio.cxx @@ -43,7 +43,7 @@ VorbisAudio:: PT(MovieAudioCursor) VorbisAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/vorbisAudioCursor.cxx b/panda/src/movies/vorbisAudioCursor.cxx index 6f6002158f..d4478c9f07 100644 --- a/panda/src/movies/vorbisAudioCursor.cxx +++ b/panda/src/movies/vorbisAudioCursor.cxx @@ -16,6 +16,8 @@ #ifdef HAVE_VORBIS +using std::istream; + TypeHandle VorbisAudioCursor::_type_handle; /** @@ -82,7 +84,7 @@ seek(double t) { return; } - t = max(t, 0.0); + t = std::max(t, 0.0); // Use ov_time_seek_lap if cross-lapping is enabled. if (vorbis_seek_lap) { @@ -189,15 +191,15 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { switch (whence) { case SEEK_SET: - stream->seekg(offset, ios::beg); + stream->seekg(offset, std::ios::beg); break; case SEEK_CUR: - stream->seekg(offset, ios::cur); + stream->seekg(offset, std::ios::cur); break; case SEEK_END: - stream->seekg(offset, ios::end); + stream->seekg(offset, std::ios::end); break; default: diff --git a/panda/src/movies/wavAudio.cxx b/panda/src/movies/wavAudio.cxx index 685a0a7d68..854d2aef5c 100644 --- a/panda/src/movies/wavAudio.cxx +++ b/panda/src/movies/wavAudio.cxx @@ -41,7 +41,7 @@ WavAudio:: PT(MovieAudioCursor) WavAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index 5f6cf05047..381ce2d81b 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -94,7 +94,7 @@ TypeHandle WavAudioCursor::_type_handle; * pointer positioned at the start of the data. */ WavAudioCursor:: -WavAudioCursor(WavAudio *src, istream *stream) : +WavAudioCursor(WavAudio *src, std::istream *stream) : MovieAudioCursor(src), _is_valid(false), _stream(stream), @@ -291,8 +291,8 @@ WavAudioCursor:: */ void WavAudioCursor:: seek(double t) { - t = max(t, 0.0); - streampos pos = _data_start + (streampos) min((size_t) (t * _byte_rate), _data_size); + t = std::max(t, 0.0); + std::streampos pos = _data_start + (std::streampos) std::min((size_t) (t * _byte_rate), _data_size); if (_can_seek_fast) { _stream->seekg(pos); @@ -303,7 +303,7 @@ seek(double t) { } if (!_can_seek_fast) { - streampos current = _stream->tellg(); + std::streampos current = _stream->tellg(); if (pos > current) { // It is ahead of our current position. Skip ahead. @@ -327,7 +327,7 @@ seek(double t) { void WavAudioCursor:: read_samples(int n, int16_t *data) { int desired = n * _audio_channels; - int read_samples = min(desired, ((int) (_data_size - _data_pos)) / _bytes_per_sample); + int read_samples = std::min(desired, ((int) (_data_size - _data_pos)) / _bytes_per_sample); if (read_samples <= 0) { return; diff --git a/panda/src/nativenet/socket_portable.h b/panda/src/nativenet/socket_portable.h index d4bdd1fa98..a4a249f92e 100644 --- a/panda/src/nativenet/socket_portable.h +++ b/panda/src/nativenet/socket_portable.h @@ -12,7 +12,9 @@ const int BASIC_ERROR = -1; // Interrogate doesn't need to parse any of this. typedef unsigned long SOCKET; -typedef unsigned short sa_family_t; + +#include +#include /************************************************************************ * HP SOCKET LIBRARY STUFF diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index 9fcbdcbe91..80af80147a 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -119,9 +119,9 @@ get_net_max_block() { // This function is used in the ReaderThread and WriterThread constructors to // make a simple name for each thread. -string -make_thread_name(const string &thread_name, int thread_index) { - ostringstream stream; +std::string +make_thread_name(const std::string &thread_name, int thread_index) { + std::ostringstream stream; stream << thread_name << "_" << thread_index; return stream.str(); } diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 1e96a758de..aecfc111ac 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -303,7 +303,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { LightReMutexHolder holder(_write_mutex); DatagramUDPHeader header(datagram); - string data; + std::string data; data += header.get_header(); data += datagram.get_message(); @@ -374,7 +374,7 @@ send_raw_datagram(const NetDatagram &datagram) { Socket_UDP *udp; DCAST_INTO_R(udp, _socket, false); - string data = datagram.get_message(); + std::string data = datagram.get_message(); LightReMutexHolder holder(_write_mutex); Socket_Address addr = datagram.get_address().get_addr(); @@ -430,7 +430,7 @@ do_flush() { Socket_TCP *tcp; DCAST_INTO_R(tcp, _socket, false); - string sending_data; + std::string sending_data; _queued_data.swap(sending_data); _queued_count = 0; @@ -438,7 +438,7 @@ do_flush() { #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) int max_send = net_max_write_per_epoch; - int data_sent = tcp->SendData(sending_data.data(), min((size_t)max_send, sending_data.size())); + int data_sent = tcp->SendData(sending_data.data(), std::min((size_t)max_send, sending_data.size())); bool okflag = (data_sent == (int)sending_data.size()); if (!okflag) { int total_sent = 0; @@ -453,7 +453,7 @@ do_flush() { } else { Thread::consider_yield(); } - data_sent = tcp->SendData(sending_data.data() + total_sent, min((size_t)max_send, sending_data.size() - total_sent)); + data_sent = tcp->SendData(sending_data.data() + total_sent, std::min((size_t)max_send, sending_data.size() - total_sent)); if (data_sent > 0) { total_sent += data_sent; } diff --git a/panda/src/net/connectionListener.cxx b/panda/src/net/connectionListener.cxx index a48791b24d..2ab8b33ef7 100644 --- a/panda/src/net/connectionListener.cxx +++ b/panda/src/net/connectionListener.cxx @@ -19,8 +19,8 @@ #include "config_net.h" #include "socket_tcp_listen.h" -static string -listener_thread_name(const string &thread_name) { +static std::string +listener_thread_name(const std::string &thread_name) { if (!thread_name.empty()) { return thread_name; } @@ -32,7 +32,7 @@ listener_thread_name(const string &thread_name) { */ ConnectionListener:: ConnectionListener(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : ConnectionReader(manager, num_threads, listener_thread_name(thread_name)) { } diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index 0d7da68000..f125356f50 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -33,6 +33,9 @@ #include #endif +using std::stringstream; +using std::string; + /** * */ @@ -412,7 +415,7 @@ wait_for_readers(double timeout) { double wait_timeout = get_net_max_block(); if (!block_forever) { - wait_timeout = min(wait_timeout, stop - now); + wait_timeout = std::min(wait_timeout, stop - now); } uint32_t wait_timeout_ms = (uint32_t)(wait_timeout * 1000.0); @@ -489,7 +492,7 @@ scan_interfaces() { // p->AdapterName appears to be a GUID. Not sure if this is actually // useful to anyone; we'll store the "friendly name" instead. TextEncoder encoder; - encoder.set_wtext(wstring(p->FriendlyName)); + encoder.set_wtext(std::wstring(p->FriendlyName)); string friendly_name = encoder.get_text(); Interface iface; @@ -716,12 +719,12 @@ remove_writer(ConnectionWriter *writer) { */ string ConnectionManager:: format_mac_address(const unsigned char *data, size_t data_size) { - stringstream strm; + std::stringstream strm; for (size_t di = 0; di < data_size; ++di) { if (di != 0) { strm << "-"; } - strm << hex << setw(2) << setfill('0') << (unsigned int)data[di]; + strm << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)data[di]; } return strm.str(); @@ -731,7 +734,7 @@ format_mac_address(const unsigned char *data, size_t data_size) { * */ void ConnectionManager::Interface:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << " ["; if (has_ip()) { out << " " << get_ip().get_ip_string(); diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index 4f9a31dca5..9fbab3e1dc 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -27,6 +27,8 @@ #include "atomicAdjust.h" #include "config_downloader.h" +using std::min; + static const int read_buffer_size = maximum_udp_datagram + datagram_udp_header_size; /** @@ -60,7 +62,7 @@ get_socket() const { * */ ConnectionReader::ReaderThread:: -ReaderThread(ConnectionReader *reader, const string &thread_name, +ReaderThread(ConnectionReader *reader, const std::string &thread_name, int thread_index) : Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), @@ -85,7 +87,7 @@ thread_main() { */ ConnectionReader:: ConnectionReader(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : _manager(manager) { if (!Thread::is_threading_supported()) { @@ -111,7 +113,7 @@ ConnectionReader(ConnectionManager *manager, int num_threads, _currently_polling_thread = -1; - string reader_thread_name = thread_name; + std::string reader_thread_name = thread_name; if (thread_name.empty()) { reader_thread_name = "ReaderThread"; } diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index 554f8118c1..47cde6c35d 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -24,7 +24,7 @@ * */ ConnectionWriter::WriterThread:: -WriterThread(ConnectionWriter *writer, const string &thread_name, +WriterThread(ConnectionWriter *writer, const std::string &thread_name, int thread_index) : Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), @@ -50,7 +50,7 @@ thread_main() { */ ConnectionWriter:: ConnectionWriter(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : _manager(manager) { if (!Thread::is_threading_supported()) { @@ -70,7 +70,7 @@ ConnectionWriter(ConnectionManager *manager, int num_threads, _immediate = (num_threads <= 0); _shutdown = false; - string writer_thread_name = thread_name; + std::string writer_thread_name = thread_name; if (thread_name.empty()) { writer_thread_name = "WriterThread"; } diff --git a/panda/src/net/datagramTCPHeader.cxx b/panda/src/net/datagramTCPHeader.cxx index bd013f0c33..44db216b3d 100644 --- a/panda/src/net/datagramTCPHeader.cxx +++ b/panda/src/net/datagramTCPHeader.cxx @@ -107,7 +107,7 @@ verify_datagram(const NetDatagram &datagram, int header_size) const { // We write the hex dump into a ostringstream first, to guarantee an // atomic write to the output stream in case we're threaded. - ostringstream hex; + std::ostringstream hex; datagram.dump_hex(hex); hex << "\n"; net_cat.debug() << hex.str(); diff --git a/panda/src/net/datagramUDPHeader.cxx b/panda/src/net/datagramUDPHeader.cxx index 2191c0241a..7c58205e8d 100644 --- a/panda/src/net/datagramUDPHeader.cxx +++ b/panda/src/net/datagramUDPHeader.cxx @@ -73,7 +73,7 @@ verify_datagram(const NetDatagram &datagram) const { // We write the hex dump into a ostringstream first, to guarantee an // atomic write to the output stream in case we're threaded. - ostringstream hex; + std::ostringstream hex; datagram.dump_hex(hex); hex << "\n"; net_cat.debug(false) << hex.str(); diff --git a/panda/src/net/datagram_ui.cxx b/panda/src/net/datagram_ui.cxx index fa9879bf86..d5f0bdea1b 100644 --- a/panda/src/net/datagram_ui.cxx +++ b/panda/src/net/datagram_ui.cxx @@ -19,6 +19,9 @@ #include #include +using std::istream; +using std::ostream; + enum DatagramElement { DE_int32, DE_float64, diff --git a/panda/src/net/fake_http_server.cxx b/panda/src/net/fake_http_server.cxx index 718b6db824..bc29e9806a 100644 --- a/panda/src/net/fake_http_server.cxx +++ b/panda/src/net/fake_http_server.cxx @@ -24,6 +24,8 @@ #include +using std::string; + QueuedConnectionManager cm; QueuedConnectionReader reader(&cm, 10); ConnectionWriter writer(&cm, 10); @@ -65,7 +67,7 @@ receive_data(const Datagram &data) { void ClientState:: receive_line(string line) { - cerr << "received: " << line << "\n"; + std::cerr << "received: " << line << "\n"; // trim trailing whitespace. size_t size = line.size(); while (size > 0 && isspace(line[size - 1])) { diff --git a/panda/src/net/netAddress.cxx b/panda/src/net/netAddress.cxx index 0f0404dc45..9d49623252 100644 --- a/panda/src/net/netAddress.cxx +++ b/panda/src/net/netAddress.cxx @@ -63,7 +63,7 @@ set_broadcast(int port) { * Returns true if the hostname is known, false otherwise. */ bool NetAddress:: -set_host(const string &hostname, int port) { +set_host(const std::string &hostname, int port) { return _addr.set_host(hostname, port); } @@ -102,7 +102,7 @@ is_any() const { /** * Returns the IP address to which this address refers, formatted as a string. */ -string NetAddress:: +std::string NetAddress:: get_ip_string() const { return _addr.get_ip(); } @@ -143,7 +143,7 @@ get_addr() const { * */ void NetAddress:: -output(ostream &out) const { +output(std::ostream &out) const { out << _addr.get_ip_port(); } diff --git a/panda/src/net/queuedConnectionReader.cxx b/panda/src/net/queuedConnectionReader.cxx index bdc562bd22..807b69337c 100644 --- a/panda/src/net/queuedConnectionReader.cxx +++ b/panda/src/net/queuedConnectionReader.cxx @@ -123,7 +123,7 @@ void QueuedConnectionReader:: start_delay(double min_delay, double max_delay) { LightMutexHolder holder(_dd_mutex); _min_delay = min_delay; - _delay_variance = max(max_delay - min_delay, 0.0); + _delay_variance = std::max(max_delay - min_delay, 0.0); _delay_active = true; } diff --git a/panda/src/net/test_datagram.cxx b/panda/src/net/test_datagram.cxx index db2f3fd305..93da4b6c87 100644 --- a/panda/src/net/test_datagram.cxx +++ b/panda/src/net/test_datagram.cxx @@ -14,6 +14,9 @@ #include "netDatagram.h" #include "datagramIterator.h" +using std::cout; +using std::endl; + int main() { NetDatagram dg; diff --git a/panda/src/net/test_raw_server.cxx b/panda/src/net/test_raw_server.cxx index aeec9b0aee..444d65756c 100644 --- a/panda/src/net/test_raw_server.cxx +++ b/panda/src/net/test_raw_server.cxx @@ -82,7 +82,7 @@ main(int argc, char *argv[]) { while (reader.data_available()) { NetDatagram datagram; if (reader.get_data(datagram)) { - string data = datagram.get_message(); + std::string data = datagram.get_message(); nout.write(data.data(), data.length()); nout << std::flush; diff --git a/panda/src/net/test_spam_client.cxx b/panda/src/net/test_spam_client.cxx index e76643e5c2..5488cec357 100644 --- a/panda/src/net/test_spam_client.cxx +++ b/panda/src/net/test_spam_client.cxx @@ -28,7 +28,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; @@ -54,8 +54,8 @@ main(int argc, char *argv[]) { bool lost_connection = false; NetDatagram datagram; - cout << "Enter a datagram.\n"; - cin >> datagram; + std::cout << "Enter a datagram.\n"; + std::cin >> datagram; nout << "Read datagram " << datagram << "\n"; datagram.dump_hex(nout); diff --git a/panda/src/net/test_tcp_client.cxx b/panda/src/net/test_tcp_client.cxx index 4c5b15fa17..c88821149c 100644 --- a/panda/src/net/test_tcp_client.cxx +++ b/panda/src/net/test_tcp_client.cxx @@ -20,6 +20,9 @@ #include "datagram_ui.h" +using std::cin; +using std::cout; + int main(int argc, char *argv[]) { if (argc != 3) { @@ -27,7 +30,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; diff --git a/panda/src/net/test_udp.cxx b/panda/src/net/test_udp.cxx index f069523f48..4aec3ecc76 100644 --- a/panda/src/net/test_udp.cxx +++ b/panda/src/net/test_udp.cxx @@ -20,6 +20,9 @@ #include "datagram_ui.h" +using std::cin; +using std::cout; + int main(int argc, char *argv[]) { if (argc != 3) { @@ -27,7 +30,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 412759f8e7..70ad46169d 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -69,7 +69,7 @@ get_joint(int index) const { } void OdeBody:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() \ << "(id = " << _id \ << ")"; diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx index c291025912..e25c6c45b6 100644 --- a/panda/src/ode/odeGeom.cxx +++ b/panda/src/ode/odeGeom.cxx @@ -107,7 +107,7 @@ get_space() const { void OdeGeom:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << get_type() << "(id = " << _id << ")"; } diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index a089a7b303..dd10c57f0a 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -31,14 +31,14 @@ TypeHandle OdeJoint::_type_handle; OdeJoint:: OdeJoint() : _id(nullptr) { - ostream &out = odejoint_cat.debug(); + std::ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } OdeJoint:: OdeJoint(dJointID id) : _id(id) { - ostream &out = odejoint_cat.debug(); + std::ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } @@ -95,7 +95,7 @@ get_body(int index) const { } void OdeJoint:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() \ << "(id = " << _id \ << ", body1 = "; diff --git a/panda/src/ode/odeMass.cxx b/panda/src/ode/odeMass.cxx index de9d52567a..76c3d360e8 100644 --- a/panda/src/ode/odeMass.cxx +++ b/panda/src/ode/odeMass.cxx @@ -51,7 +51,7 @@ operator = (const OdeMass ©) { void OdeMass:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << get_type() \ << "(mag = " << get_magnitude() \ diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index a07342b82f..f2beca8efb 100644 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -95,7 +95,7 @@ get_geom(int i) { void OdeSpace:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() << "(id = " << _id << ")"; } diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 07d265a41d..c92602ac34 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -13,6 +13,8 @@ #include "odeTriMeshData.h" +using std::ostream; + TypeHandle OdeTriMeshData::_type_handle; OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = nullptr; @@ -43,7 +45,7 @@ unlink_data(dGeomID id) { } void OdeTriMeshData:: -print_data(const string &marker) { +print_data(const std::string &marker) { odetrimeshdata_cat.debug() << get_class_type() << "::print_data(" << marker << ")\n"; const TriMeshDataMap &data_map = get_tri_mesh_data_map(); TriMeshDataMap::const_iterator iter = data_map.begin(); @@ -219,7 +221,7 @@ process_geom(const Geom *geom) { CPT(GeomVertexData) vData = geom->get_vertex_data(); - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { process_primitive(geom->get_primitive(i), vData); } } @@ -306,7 +308,7 @@ analyze(const Geom *geom) { return; } - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { analyze(geom->get_primitive(i)); } } diff --git a/panda/src/ode/odeUtil.cxx b/panda/src/ode/odeUtil.cxx index 0e38b45558..2ae8d281d4 100644 --- a/panda/src/ode/odeUtil.cxx +++ b/panda/src/ode/odeUtil.cxx @@ -28,7 +28,7 @@ get_connecting_joint(const OdeBody &body1, const OdeBody &body2) { */ OdeJointCollection OdeUtil:: get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { - const int max_possible_joints = min(body1.get_num_joints(), body1.get_num_joints()); + const int max_possible_joints = std::min(body1.get_num_joints(), body1.get_num_joints()); dJointID *joint_list = (dJointID *)PANDA_MALLOC_ARRAY(max_possible_joints * sizeof(dJointID)); int num_joints = dConnectingJointList(body1.get_id(), body2.get_id(), diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index d98b5d956a..03bfa46d79 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -25,7 +25,7 @@ TypeHandle osxGraphicsBuffer::_type_handle; */ osxGraphicsBuffer:: osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 9211c52515..5a56a6259d 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -202,7 +202,7 @@ osxGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string osxGraphicsPipe:: +std::string osxGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -344,7 +344,7 @@ release_data(void *info, const void *data, size_t size) { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) osxGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 0ae735b055..2fb60d2d74 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -35,7 +35,7 @@ TypeHandle osxGraphicsStateGuardian::_type_handle; */ void *osxGraphicsStateGuardian:: do_get_extension_func(const char *name) { - string fullname = "_" + string(name); + std::string fullname = "_" + std::string(name); NSSymbol symbol = nullptr; if (NSIsSymbolNameDefined(fullname.c_str())) { @@ -113,8 +113,8 @@ draw_resize_box() { // Get the default texture to apply to the resize box; it's compiled into // the code. - string resize_box_string((const char *)resize_box, resize_box_len); - istringstream resize_box_strm(resize_box_string); + std::string resize_box_string((const char *)resize_box, resize_box_len); + std::istringstream resize_box_strm(resize_box_string); PNMImage resize_box_pnm; if (resize_box_pnm.read(resize_box_strm, "resize_box.rgb")) { PT(Texture) tex = new Texture; diff --git a/panda/src/parametrics/cubicCurveseg.cxx b/panda/src/parametrics/cubicCurveseg.cxx index 6bd2dcef6f..dcb5905cfa 100644 --- a/panda/src/parametrics/cubicCurveseg.cxx +++ b/panda/src/parametrics/cubicCurveseg.cxx @@ -234,7 +234,7 @@ compute_nurbs_basis(int order, if (mink==maxk) { // Huh. What were you thinking? This is a trivial NURBS. parametrics_cat->warning() - << "Trivial NURBS curve specified." << endl; + << "Trivial NURBS curve specified." << std::endl; memset((void *)&basis, 0, sizeof(LMatrix4)); return; } @@ -409,7 +409,7 @@ compute_seg_col(int c, break; default: - cerr << "Invalid rebuild type in compute_seg\n"; + std::cerr << "Invalid rebuild type in compute_seg\n"; return false; } diff --git a/panda/src/parametrics/curveFitter.cxx b/panda/src/parametrics/curveFitter.cxx index e929ebd21e..275a270a4b 100644 --- a/panda/src/parametrics/curveFitter.cxx +++ b/panda/src/parametrics/curveFitter.cxx @@ -137,8 +137,8 @@ get_sample_tangent(int n) const { */ void CurveFitter:: remove_samples(int begin, int end) { - begin = max(0, min((int)_data.size(), begin)); - end = max(0, min((int)_data.size(), end)); + begin = std::max(0, std::min((int)_data.size(), begin)); + end = std::max(0, std::min((int)_data.size(), end)); nassertv(begin <= end); @@ -411,7 +411,7 @@ make_nurbs() const { * */ void CurveFitter:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CurveFitter, " << _data.size() << " samples.\n"; } @@ -419,7 +419,7 @@ output(ostream &out) const { * */ void CurveFitter:: -write(ostream &out) const { +write(std::ostream &out) const { out << "CurveFitter, " << _data.size() << " samples:\n"; Data::const_iterator di; for (di = _data.begin(); di != _data.end(); ++di) { diff --git a/panda/src/parametrics/hermiteCurve.cxx b/panda/src/parametrics/hermiteCurve.cxx index 73931ab001..7bb2399368 100644 --- a/panda/src/parametrics/hermiteCurve.cxx +++ b/panda/src/parametrics/hermiteCurve.cxx @@ -24,6 +24,9 @@ #include +using std::ostream; +using std::string; + TypeHandle HermiteCurve::_type_handle; static const LVecBase3 zerovec_3 = LVecBase3(0.0f, 0.0f, 0.0f); @@ -246,7 +249,7 @@ HermiteCurve(const ParametricCurve &nc) { if (!nc.convert_to_hermite(this)) { parametrics_cat->warning() << "Cannot make a Hermite from the indicated curve." - << endl; + << std::endl; } } @@ -291,7 +294,7 @@ insert_cv(PN_stdfloat t) { return n; } - t = min(max(t, (PN_stdfloat)0.0), get_max_t()); + t = std::min(std::max(t, (PN_stdfloat)0.0), get_max_t()); int n = find_cv(t); nassertr(n+1= 0 && n < get_num_cvs()); out << "CV " << n << ": " << get_cv_point(n) << ", weight " @@ -55,7 +55,7 @@ write_cv(ostream &out, int n) const { * */ void NurbsCurveInterface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level); PN_stdfloat min_t = 0.0f; @@ -93,7 +93,7 @@ write(ostream &out, int indent_level) const { * Formats the Nurbs curve for output to an Egg file. */ bool NurbsCurveInterface:: -format_egg(ostream &out, const string &name, const string &curve_type, +format_egg(std::ostream &out, const std::string &name, const std::string &curve_type, int indent_level) const { indent(out, indent_level) << " " << name << ".pool {\n"; diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx index 12ed399a9d..33d1ce0a81 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx @@ -212,7 +212,7 @@ evaluate(const NodePath &rel_to) const { * */ void NurbsSurfaceEvaluator:: -output(ostream &out) const { +output(std::ostream &out) const { out << "NurbsSurface, (" << get_num_u_knots() << ", " << get_num_v_knots() << ") knots."; } diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index e1bfccb168..86b6f6615f 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -62,10 +62,10 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, // Create four geometry matrices from our (up to) sixteen involved // vertices. LMatrix4 geom_x, geom_y, geom_z, geom_w; - memset(&geom_x, 0, sizeof(geom_x)); - memset(&geom_y, 0, sizeof(geom_y)); - memset(&geom_z, 0, sizeof(geom_z)); - memset(&geom_w, 0, sizeof(geom_w)); + geom_x.fill(0); + geom_y.fill(0); + geom_z.fill(0); + geom_w.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -178,7 +178,7 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) int vn = _v_basis.get_vertex_index(vi); LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -223,7 +223,7 @@ eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d for (int n = 0; n < num_values; n++) { LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 5d3d014722..9893c65604 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -321,8 +321,8 @@ write_egg(Filename filename, CoordinateSystem cs) { * stream. Returns true if the file is successfully written. */ bool ParametricCurve:: -write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { - string curve_type; +write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs) { + std::string curve_type; switch (get_curve_type()) { case PCT_XYZ: curve_type = "xyz"; @@ -339,7 +339,7 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { if (!has_name()) { // If we don't have a name, come up with one. - string name = filename.get_basename_wo_extension(); + std::string name = filename.get_basename_wo_extension(); if (!curve_type.empty()) { name += "_"; @@ -602,7 +602,7 @@ invalidate_all() { * Returns true on success, false on failure. */ bool ParametricCurve:: -format_egg(ostream &, const string &, const string &, int) const { +format_egg(std::ostream &, const std::string &, const std::string &, int) const { return false; } diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 9e3d8b4a1b..96ce9bd503 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -44,7 +44,7 @@ add_curve(ParametricCurve *curve) { void ParametricCurveCollection:: insert_curve(size_t index, ParametricCurve *curve) { prepare_add_curve(curve); - index = min(index, _curves.size()); + index = std::min(index, _curves.size()); _curves.insert(_curves.begin() + index, curve); redraw(); } @@ -307,7 +307,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { // the same length as all the others. CurveFitter fitter; - int num_segments = max(1, (int)cfloor(segments_per_unit * xyz_curve->get_max_t() + 0.5f)); + int num_segments = std::max(1, (int)cfloor(segments_per_unit * xyz_curve->get_max_t() + 0.5f)); if (parametrics_cat.is_debug()) { parametrics_cat.debug() @@ -657,7 +657,7 @@ stitch(const ParametricCurveCollection *a, * indicated output stream. */ void ParametricCurveCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_curves() == 1) { out << "1 ParametricCurve"; } else { @@ -670,7 +670,7 @@ output(ostream &out) const { * to the indicated output stream. */ void ParametricCurveCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { ParametricCurves::const_iterator ci; for (ci = _curves.begin(); ci != _curves.end(); ++ci) { ParametricCurve *curve = (*ci); @@ -700,7 +700,7 @@ write_egg(Filename filename, CoordinateSystem cs) { * specified output stream. Returns true if the file is successfully written. */ bool ParametricCurveCollection:: -write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { +write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs) { if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -740,7 +740,7 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { if (!curve->has_name()) { // If we don't have a name, come up with one. - string name = filename.get_basename_wo_extension(); + std::string name = filename.get_basename_wo_extension(); switch (curve->get_curve_type()) { case PCT_XYZ: diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index d69b4f7025..f5e2fadad9 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -20,6 +20,8 @@ #include "bamWriter.h" #include "bamReader.h" +using std::cerr; + TypeHandle PiecewiseCurve::_type_handle; /** diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index 5837bfd361..ffb2c83119 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -67,7 +67,7 @@ fillin(DatagramIterator &scan, BamReader *reader) { * */ RopeNode:: -RopeNode(const string &name) : +RopeNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -177,7 +177,7 @@ is_renderable() const { * */ void RopeNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); NurbsCurveEvaluator *curve = get_curve(); if (curve != nullptr) { @@ -191,7 +191,7 @@ output(ostream &out) const { * */ void RopeNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); indent(out, indent_level) << *get_curve() << "\n"; } diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index 294c3a7ff4..eec44c0cda 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -66,7 +66,7 @@ fillin(DatagramIterator &scan, BamReader *reader) { * */ SheetNode:: -SheetNode(const string &name) : +SheetNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -155,7 +155,7 @@ is_renderable() const { * */ void SheetNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); NurbsSurfaceEvaluator *surface = get_surface(); if (surface != nullptr) { @@ -169,7 +169,7 @@ output(ostream &out) const { * */ void SheetNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); NurbsSurfaceEvaluator *surface = get_surface(); if (surface != nullptr) { diff --git a/panda/src/particlesystem/arcEmitter.cxx b/panda/src/particlesystem/arcEmitter.cxx index cc56b3130e..a87c7376db 100644 --- a/panda/src/particlesystem/arcEmitter.cxx +++ b/panda/src/particlesystem/arcEmitter.cxx @@ -74,7 +74,7 @@ assign_initial_position(LPoint3& pos) { * Write a starc representation of this instance to . */ void ArcEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ArcEmitter"; #endif //] NDEBUG @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a starc representation of this instance to . */ void ArcEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ArcEmitter:\n"; out.width(indent+2); out<<""; out<<"_start_angle "<. */ void BaseParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticle"; #endif //] NDEBUG @@ -61,7 +61,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticle:\n"; out.width(indent+2); out<<""; out<<"_age "<<_age<<"\n"; diff --git a/panda/src/particlesystem/baseParticleEmitter.cxx b/panda/src/particlesystem/baseParticleEmitter.cxx index 20ef762aa9..c18584b461 100644 --- a/panda/src/particlesystem/baseParticleEmitter.cxx +++ b/panda/src/particlesystem/baseParticleEmitter.cxx @@ -79,7 +79,7 @@ generate(LPoint3& pos, LVector3& vel) { * Write a string representation of this instance to . */ void BaseParticleEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleEmitter"; #endif //] NDEBUG @@ -89,7 +89,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleEmitter:\n"; out.width(indent+2); out<<""; out<<"_emission_type "<<_emission_type<<"\n"; diff --git a/panda/src/particlesystem/baseParticleFactory.cxx b/panda/src/particlesystem/baseParticleFactory.cxx index 162b4df88e..0f0169f99b 100644 --- a/panda/src/particlesystem/baseParticleFactory.cxx +++ b/panda/src/particlesystem/baseParticleFactory.cxx @@ -69,7 +69,7 @@ populate_particle(BaseParticle *bp) { * Write a string representation of this instance to . */ void BaseParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleFactory"; #endif //] NDEBUG @@ -79,7 +79,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleFactory:\n"; out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n"; diff --git a/panda/src/particlesystem/baseParticleRenderer.cxx b/panda/src/particlesystem/baseParticleRenderer.cxx index 2a2072c2a1..f7f33c41ac 100644 --- a/panda/src/particlesystem/baseParticleRenderer.cxx +++ b/panda/src/particlesystem/baseParticleRenderer.cxx @@ -79,7 +79,7 @@ set_ignore_scale(bool ignore_scale) { * Write a string representation of this instance to . */ void BaseParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleRenderer"; #endif //] NDEBUG @@ -89,7 +89,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleRenderer:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleRenderer:\n"; out.width(indent+2); out<<""; out<<"_render_node "<<_render_node_path<<"\n"; diff --git a/panda/src/particlesystem/boxEmitter.cxx b/panda/src/particlesystem/boxEmitter.cxx index 52035e62c7..3b84932dd7 100644 --- a/panda/src/particlesystem/boxEmitter.cxx +++ b/panda/src/particlesystem/boxEmitter.cxx @@ -78,7 +78,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void BoxEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BoxEmitter"; #endif //] NDEBUG @@ -88,7 +88,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BoxEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BoxEmitter:\n"; out.width(indent+2); out<<""; out<<"_vmin "<<_vmin<<"\n"; diff --git a/panda/src/particlesystem/colorInterpolationManager.cxx b/panda/src/particlesystem/colorInterpolationManager.cxx index 27268c2ef8..b2e68ba66d 100644 --- a/panda/src/particlesystem/colorInterpolationManager.cxx +++ b/panda/src/particlesystem/colorInterpolationManager.cxx @@ -14,6 +14,9 @@ #include "colorInterpolationManager.h" #include "mathNumbers.h" +using std::max; +using std::min; + TypeHandle ColorInterpolationFunction::_type_handle; TypeHandle ColorInterpolationFunctionConstant::_type_handle; TypeHandle ColorInterpolationFunctionLinear::_type_handle; diff --git a/panda/src/particlesystem/discEmitter.cxx b/panda/src/particlesystem/discEmitter.cxx index 3b018a2dfe..e07f933bdf 100644 --- a/panda/src/particlesystem/discEmitter.cxx +++ b/panda/src/particlesystem/discEmitter.cxx @@ -115,7 +115,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void DiscEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"DiscEmitter"; #endif //] NDEBUG @@ -125,7 +125,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DiscEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"DiscEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 74df181f2e..8db733c58d 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -200,7 +200,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha_scalar = 1.0f - alpha_scalar; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha_scalar = 2.0f * min(alpha_scalar, 1.0f - alpha_scalar); + alpha_scalar = 2.0f * std::min(alpha_scalar, 1.0f - alpha_scalar); alpha_scalar *= get_user_alpha(); } @@ -252,7 +252,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"GeomParticleRenderer"; #endif //] NDEBUG @@ -262,7 +262,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -write_linear_forces(ostream &out, int indent) const { +write_linear_forces(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_node_vector ("<<_node_vector.size()<<" forces)\n"; @@ -278,7 +278,7 @@ write_linear_forces(ostream &out, int indent) const { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"GeomParticleRenderer:\n"; out.width(indent+2); out<<""; out<<"_geom_node "<<_geom_node<<"\n"; diff --git a/panda/src/particlesystem/lineEmitter.cxx b/panda/src/particlesystem/lineEmitter.cxx index 5a236c03e1..6855fc3aeb 100644 --- a/panda/src/particlesystem/lineEmitter.cxx +++ b/panda/src/particlesystem/lineEmitter.cxx @@ -76,7 +76,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void LineEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LineEmitter"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LineEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LineEmitter:\n"; out.width(indent+2); out<<""; out<<"_endpoint1 "<<_endpoint1<<"\n"; diff --git a/panda/src/particlesystem/lineParticleRenderer.cxx b/panda/src/particlesystem/lineParticleRenderer.cxx index e139e6f2e8..5a2240cfb6 100644 --- a/panda/src/particlesystem/lineParticleRenderer.cxx +++ b/panda/src/particlesystem/lineParticleRenderer.cxx @@ -195,7 +195,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha = 1.0f - alpha; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha = 2.0f * min(alpha, 1.0f - alpha); + alpha = 2.0f * std::min(alpha, 1.0f - alpha); } head_color[3] = alpha; @@ -232,7 +232,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void LineParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LineParticleRenderer"; #endif //] NDEBUG @@ -242,7 +242,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LineParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "LineParticleRenderer:\n"; indent(out, indent_level + 2) << "_head_color "<<_head_color<<"\n"; indent(out, indent_level + 2) << "_tail_color "<<_tail_color<<"\n"; diff --git a/panda/src/particlesystem/orientedParticle.cxx b/panda/src/particlesystem/orientedParticle.cxx index bf828f165c..640c244aa7 100644 --- a/panda/src/particlesystem/orientedParticle.cxx +++ b/panda/src/particlesystem/orientedParticle.cxx @@ -71,7 +71,7 @@ update() { * Write a string representation of this instance to . */ void OrientedParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"OrientedParticle"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void OrientedParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"OrientedParticle:\n"; BaseParticle::write(out, indent+2); diff --git a/panda/src/particlesystem/orientedParticleFactory.cxx b/panda/src/particlesystem/orientedParticleFactory.cxx index 2889a16727..7276d9c2b9 100644 --- a/panda/src/particlesystem/orientedParticleFactory.cxx +++ b/panda/src/particlesystem/orientedParticleFactory.cxx @@ -59,7 +59,7 @@ alloc_particle() const { * Write a string representation of this instance to . */ void OrientedParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"OrientedParticleFactory"; #endif //] NDEBUG @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void OrientedParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"OrientedParticleFactory:\n"; BaseParticleFactory::write(out, indent+2); diff --git a/panda/src/particlesystem/particleSystem.cxx b/panda/src/particlesystem/particleSystem.cxx index 7e22ac9180..32a9480fc0 100644 --- a/panda/src/particlesystem/particleSystem.cxx +++ b/panda/src/particlesystem/particleSystem.cxx @@ -30,6 +30,10 @@ #include "sphereSurfaceEmitter.h" #include "pStatTimer.h" +using std::cout; +using std::endl; +using std::ostream; + TypeHandle ParticleSystem::_type_handle; PStatCollector ParticleSystem::_update_collector("App:Particles:Update"); @@ -594,7 +598,7 @@ sanity_check() { #endif result++; } - pool_size = min(_particle_pool_size, _physics_objects.size()); + pool_size = std::min(_particle_pool_size, _physics_objects.size()); // find out how many particles are REALLY alive and dead int real_live_particle_count = 0; diff --git a/panda/src/particlesystem/particleSystemManager.cxx b/panda/src/particlesystem/particleSystemManager.cxx index e6dbf53fef..b96c7d6105 100644 --- a/panda/src/particlesystem/particleSystemManager.cxx +++ b/panda/src/particlesystem/particleSystemManager.cxx @@ -145,7 +145,7 @@ do_particles(PN_stdfloat dt, ParticleSystem *ps, bool do_render) { * Write a string representation of this instance to . */ void ParticleSystemManager:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ParticleSystemManager"; #endif //] NDEBUG @@ -155,7 +155,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ParticleSystemManager:: -write_ps_list(ostream &out, int indent) const { +write_ps_list(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_ps_list ("<<_ps_list.size()<<" systems)\n"; @@ -171,7 +171,7 @@ write_ps_list(ostream &out, int indent) const { * Write a string representation of this instance to . */ void ParticleSystemManager:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ParticleSystemManager:\n"; out.width(indent+2); out<<""; out<<"_nth_frame "<<_nth_frame<<"\n"; diff --git a/panda/src/particlesystem/pointEmitter.cxx b/panda/src/particlesystem/pointEmitter.cxx index 9c3664e7c7..376cec9a82 100644 --- a/panda/src/particlesystem/pointEmitter.cxx +++ b/panda/src/particlesystem/pointEmitter.cxx @@ -66,7 +66,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void PointEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointEmitter"; #endif //] NDEBUG @@ -76,7 +76,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointEmitter:\n"; out.width(indent+2); out<<""; out<<"_location "<<_location<<"\n"; diff --git a/panda/src/particlesystem/pointParticle.cxx b/panda/src/particlesystem/pointParticle.cxx index 32e1dbf0b2..fac3c5edf2 100644 --- a/panda/src/particlesystem/pointParticle.cxx +++ b/panda/src/particlesystem/pointParticle.cxx @@ -71,7 +71,7 @@ update() { * Write a string representation of this instance to . */ void PointParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticle"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointParticle:\n"; BaseParticle::write(out, indent+2); diff --git a/panda/src/particlesystem/pointParticleFactory.cxx b/panda/src/particlesystem/pointParticleFactory.cxx index 71a06d763e..2e1b645d88 100644 --- a/panda/src/particlesystem/pointParticleFactory.cxx +++ b/panda/src/particlesystem/pointParticleFactory.cxx @@ -59,7 +59,7 @@ alloc_particle() const { * Write a string representation of this instance to . */ void PointParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticleFactory"; #endif //] NDEBUG @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointParticleFactory:\n"; BaseParticleFactory::write(out, indent+2); diff --git a/panda/src/particlesystem/pointParticleRenderer.cxx b/panda/src/particlesystem/pointParticleRenderer.cxx index 2a5d345d37..04374bf536 100644 --- a/panda/src/particlesystem/pointParticleRenderer.cxx +++ b/panda/src/particlesystem/pointParticleRenderer.cxx @@ -167,7 +167,7 @@ create_color(const BaseParticle *p) { if (_alpha_mode == PR_ALPHA_OUT) { parameterized_age = 1.0f - parameterized_age; } else if (_alpha_mode == PR_ALPHA_IN_OUT) { - parameterized_age = 2.0f * min(parameterized_age, + parameterized_age = 2.0f * std::min(parameterized_age, 1.0f - parameterized_age); } } @@ -257,7 +257,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void PointParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticleRenderer"; #endif //] NDEBUG @@ -267,7 +267,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "PointParticleRenderer:\n"; indent(out, indent_level + 2) << "_start_color "<<_start_color<<"\n"; indent(out, indent_level + 2) << "_end_color "<<_end_color<<"\n"; diff --git a/panda/src/particlesystem/rectangleEmitter.cxx b/panda/src/particlesystem/rectangleEmitter.cxx index f261662486..d23de128e3 100644 --- a/panda/src/particlesystem/rectangleEmitter.cxx +++ b/panda/src/particlesystem/rectangleEmitter.cxx @@ -76,7 +76,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void RectangleEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"RectangleEmitter"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void RectangleEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"RectangleEmitter:\n"; out.width(indent+2); out<<""; out<<"_vmin "<<_vmin<<"\n"; diff --git a/panda/src/particlesystem/ringEmitter.cxx b/panda/src/particlesystem/ringEmitter.cxx index c9f7009807..1c4e4ee5fd 100644 --- a/panda/src/particlesystem/ringEmitter.cxx +++ b/panda/src/particlesystem/ringEmitter.cxx @@ -105,7 +105,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void RingEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"RingEmitter"; #endif //] NDEBUG @@ -115,7 +115,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void RingEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"RingEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/sparkleParticleRenderer.cxx b/panda/src/particlesystem/sparkleParticleRenderer.cxx index 5dc2d0772b..63a7124b59 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.cxx +++ b/panda/src/particlesystem/sparkleParticleRenderer.cxx @@ -192,7 +192,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha = 1.0f - alpha; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha = 2.0f * min(alpha, 1.0f - alpha); + alpha = 2.0f * std::min(alpha, 1.0f - alpha); alpha *= get_user_alpha(); } @@ -262,7 +262,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void SparkleParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SparkleParticleRenderer"; #endif //] NDEBUG @@ -272,7 +272,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SparkleParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SparkleParticleRenderer:\n"; indent(out, indent_level + 2) << "_center_color "<<_center_color<<"\n"; indent(out, indent_level + 2) << "_edge_color "<<_edge_color<<"\n"; diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.cxx b/panda/src/particlesystem/sphereSurfaceEmitter.cxx index 37b6a274fb..9fc67113a8 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.cxx +++ b/panda/src/particlesystem/sphereSurfaceEmitter.cxx @@ -71,7 +71,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void SphereSurfaceEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SphereSurfaceEmitter"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SphereSurfaceEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"SphereSurfaceEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/sphereVolumeEmitter.cxx b/panda/src/particlesystem/sphereVolumeEmitter.cxx index 5b541ce220..985b96c21d 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.cxx +++ b/panda/src/particlesystem/sphereVolumeEmitter.cxx @@ -85,7 +85,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void SphereVolumeEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SphereVolumeEmitter"; #endif //] NDEBUG @@ -95,7 +95,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SphereVolumeEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"SphereVolumeEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 58cec0e50a..cdd340c989 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -30,6 +30,9 @@ #include "config_particlesystem.h" #include "pStatTimer.h" +using std::max; +using std::min; + PStatCollector SpriteParticleRenderer::_render_collector("App:Particles:Sprite:Render"); /** @@ -189,7 +192,7 @@ extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col * match the new geometry. */ void SpriteParticleRenderer:: -set_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels) { +set_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels) { // Clear all texture information _anims.clear(); add_from_node(node_path,model,node,size_from_texels,true); @@ -241,7 +244,7 @@ set_from_node(const NodePath &node_path, bool size_from_texels) { * now on. (Default is false) */ void SpriteParticleRenderer:: -add_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels, bool resize) { +add_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels, bool resize) { int anim_count = _anims.size(); if (anim_count == 0) resize = true; @@ -291,7 +294,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader texcoord(geom->get_vertex_data(), InternalName::get_texcoord()); if (texcoord.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); @@ -335,7 +338,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader vertex(geom->get_vertex_data(), InternalName::get_vertex()); if (vertex.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); @@ -744,7 +747,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void SpriteParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SpriteParticleRenderer"; #endif //] NDEBUG @@ -754,7 +757,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SpriteParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SpriteParticleRenderer:\n"; // indent(out, indent_level + 2) << "_sprite_primitive // "<<_sprite_primitive<<"\n"; diff --git a/panda/src/particlesystem/tangentRingEmitter.cxx b/panda/src/particlesystem/tangentRingEmitter.cxx index 5c77c5491e..13bbf6f8bc 100644 --- a/panda/src/particlesystem/tangentRingEmitter.cxx +++ b/panda/src/particlesystem/tangentRingEmitter.cxx @@ -73,7 +73,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void TangentRingEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"TangentRingEmitter"; #endif //] NDEBUG @@ -83,7 +83,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void TangentRingEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"TangentRingEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/zSpinParticle.cxx b/panda/src/particlesystem/zSpinParticle.cxx index 560fa12a72..7808c2833e 100644 --- a/panda/src/particlesystem/zSpinParticle.cxx +++ b/panda/src/particlesystem/zSpinParticle.cxx @@ -108,7 +108,7 @@ get_theta() const { * Write a string representation of this instance to . */ void ZSpinParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ZSpinParticle"; #endif //] NDEBUG @@ -118,7 +118,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ZSpinParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ZSpinParticle:\n"; out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n"; diff --git a/panda/src/particlesystem/zSpinParticleFactory.cxx b/panda/src/particlesystem/zSpinParticleFactory.cxx index f8c21efccb..5f260714d7 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.cxx +++ b/panda/src/particlesystem/zSpinParticleFactory.cxx @@ -76,7 +76,7 @@ populate_child_particle(BaseParticle *bp) const { * Write a string representation of this instance to . */ void ZSpinParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ZSpinParticleFactory"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ZSpinParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ZSpinParticleFactory:\n"; out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n"; diff --git a/panda/src/pgraph/accumulatedAttribs.cxx b/panda/src/pgraph/accumulatedAttribs.cxx index f82ec15d03..94faa3072a 100644 --- a/panda/src/pgraph/accumulatedAttribs.cxx +++ b/panda/src/pgraph/accumulatedAttribs.cxx @@ -85,7 +85,7 @@ operator = (const AccumulatedAttribs ©) { * */ void AccumulatedAttribs:: -write(ostream &out, int attrib_types, int indent_level) const { +write(std::ostream &out, int attrib_types, int indent_level) const { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { _transform->write(out, indent_level); } diff --git a/panda/src/pgraph/alphaTestAttrib.cxx b/panda/src/pgraph/alphaTestAttrib.cxx index a302026623..331b709478 100644 --- a/panda/src/pgraph/alphaTestAttrib.cxx +++ b/panda/src/pgraph/alphaTestAttrib.cxx @@ -46,7 +46,7 @@ make_default() { * */ void AlphaTestAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; output_comparefunc(out,_mode); out << "," << _reference_alpha; diff --git a/panda/src/pgraph/antialiasAttrib.cxx b/panda/src/pgraph/antialiasAttrib.cxx index ef35490753..260b4fdef1 100644 --- a/panda/src/pgraph/antialiasAttrib.cxx +++ b/panda/src/pgraph/antialiasAttrib.cxx @@ -69,7 +69,7 @@ make_default() { * */ void AntialiasAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; int type = get_mode_type(); diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index 995fe2b63c..721feb5572 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -41,7 +41,7 @@ add_node(const NodePath &attrib_node) { nassertv(!attrib_node.is_empty()); LightMutexHolder holder(_lock); - pair result = _entries.insert(Entry(attrib_node)); + std::pair result = _entries.insert(Entry(attrib_node)); if (!result.second) { // Replace an existing node. (*result.first)._node = attrib_node; @@ -119,10 +119,10 @@ get_node_type(int n) const { * be the node name as it was at the time the node was recorded; if the node * has changed names since then, this will still return the original name. */ -string AttribNodeRegistry:: +std::string AttribNodeRegistry:: get_node_name(int n) const { LightMutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_entries.size(), string()); + nassertr(n >= 0 && n < (int)_entries.size(), std::string()); return _entries[n]._name; } @@ -148,7 +148,7 @@ find_node(const NodePath &attrib_node) const { * the registry, or -1 if there is no such node in the registry. */ int AttribNodeRegistry:: -find_node(TypeHandle type, const string &name) const { +find_node(TypeHandle type, const std::string &name) const { LightMutexHolder holder(_lock); Entries::const_iterator ei = _entries.find(Entry(type, name)); if (ei != _entries.end()) { @@ -180,7 +180,7 @@ clear() { * */ void AttribNodeRegistry:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(_lock); typedef pmap Counts; @@ -211,7 +211,7 @@ output(ostream &out) const { * */ void AttribNodeRegistry:: -write(ostream &out) const { +write(std::ostream &out) const { LightMutexHolder holder(_lock); Entries::const_iterator ei; diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 52d12156d0..23c6a4d7d8 100644 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -99,7 +99,7 @@ set_volume(PN_stdfloat volume) const { * */ void AudioVolumeAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "off"; diff --git a/panda/src/pgraph/auxBitplaneAttrib.cxx b/panda/src/pgraph/auxBitplaneAttrib.cxx index 662ae36b19..16f87b03f2 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.cxx +++ b/panda/src/pgraph/auxBitplaneAttrib.cxx @@ -57,7 +57,7 @@ make_default() { * */ void AuxBitplaneAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << _outputs << ")"; } diff --git a/panda/src/pgraph/auxSceneData.cxx b/panda/src/pgraph/auxSceneData.cxx index b0a50cb1c0..2ef626c270 100644 --- a/panda/src/pgraph/auxSceneData.cxx +++ b/panda/src/pgraph/auxSceneData.cxx @@ -20,7 +20,7 @@ TypeHandle AuxSceneData::_type_handle; * */ void AuxSceneData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " expires " << get_expiration_time(); } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void AuxSceneData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index fa8ae7f4c0..5bf0d5af88 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -24,6 +24,8 @@ #include "virtualFileSystem.h" #include "dcast.h" +using std::string; + /** * */ @@ -61,7 +63,7 @@ open_read(const Filename &bam_filename, bool report_errors) { * for information purposes only. Returns true if successful, false on error. */ bool BamFile:: -open_read(istream &in, const string &bam_filename, bool report_errors) { +open_read(std::istream &in, const string &bam_filename, bool report_errors) { close(); if (!_din.open(in)) { @@ -205,7 +207,7 @@ open_write(const Filename &bam_filename, bool report_errors) { * for information purposes only. Returns true if successful, false on error. */ bool BamFile:: -open_write(ostream &out, const string &bam_filename, bool report_errors) { +open_write(std::ostream &out, const string &bam_filename, bool report_errors) { close(); if (!_dout.open(out)) { diff --git a/panda/src/pgraph/billboardEffect.cxx b/panda/src/pgraph/billboardEffect.cxx index 737b370c42..c5843bb667 100644 --- a/panda/src/pgraph/billboardEffect.cxx +++ b/panda/src/pgraph/billboardEffect.cxx @@ -66,7 +66,7 @@ prepare_flatten_transform(const TransformState *net_transform) const { * */ void BillboardEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "(off)"; diff --git a/panda/src/pgraph/cacheStats.cxx b/panda/src/pgraph/cacheStats.cxx index e16c14801e..4721171e86 100644 --- a/panda/src/pgraph/cacheStats.cxx +++ b/panda/src/pgraph/cacheStats.cxx @@ -49,7 +49,7 @@ reset(double now) { * */ void CacheStats:: -write(ostream &out, const char *name) const { +write(std::ostream &out, const char *name) const { #ifndef NDEBUG out << name << " cache: " << _cache_hits << " hits, " << _cache_misses << " misses\n" diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 5658a0472f..daeeb5340d 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPH CacheStats { public: - constexpr CacheStats() = default; + CacheStats() = default; void init(); void reset(double now); void write(std::ostream &out, const char *name) const; diff --git a/panda/src/pgraph/camera.I b/panda/src/pgraph/camera.I index 1ab7bc2e41..7d32f433d3 100644 --- a/panda/src/pgraph/camera.I +++ b/panda/src/pgraph/camera.I @@ -64,7 +64,7 @@ get_num_display_regions() const { */ INLINE DisplayRegion *Camera:: get_display_region(size_t n) const { - nassertr(n < (int)_display_regions.size(), nullptr); + nassertr(n < _display_regions.size(), nullptr); return _display_regions[n]; } diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index 4ab1039d05..5a10d6145e 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -16,6 +16,8 @@ #include "lens.h" #include "throw_event.h" +using std::string; + TypeHandle Camera::_type_handle; /** @@ -195,7 +197,7 @@ get_aux_scene_data(const NodePath &node_path) const { * Outputs all of the NodePaths and AuxSceneDatas in use. */ void Camera:: -list_aux_scene_data(ostream &out) const { +list_aux_scene_data(std::ostream &out) const { out << _aux_data.size() << " data objects held:\n"; AuxData::const_iterator ai; for (ai = _aux_data.begin(); ai != _aux_data.end(); ++ai) { diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index f833d2dd94..de3f1183c9 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -375,7 +375,7 @@ add_on_plane(const NodePath &plane) const { attrib->_on_planes.insert(plane); attrib->_off_planes.erase(plane); - pair insert_result = + std::pair insert_result = attrib->_on_planes.insert(Planes::value_type(plane)); if (insert_result.second) { // Also ensure it is removed from the off_planes list. @@ -552,7 +552,7 @@ compose_off(const RenderAttrib *other) const { * */ void ClipPlaneAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_off_planes.empty()) { if (_on_planes.empty()) { diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 5af6ace015..7bfbecee79 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -75,7 +75,7 @@ make_default() { * */ void ColorAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_color_type()) { case T_vertex: diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx index 9341f2d808..f9a24d96bf 100644 --- a/panda/src/pgraph/colorBlendAttrib.cxx +++ b/panda/src/pgraph/colorBlendAttrib.cxx @@ -19,6 +19,8 @@ #include "datagram.h" #include "datagramIterator.h" +using std::ostream; + TypeHandle ColorBlendAttrib::_type_handle; int ColorBlendAttrib::_attrib_slot; diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 572f3e0e14..088c3142ef 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -129,7 +129,7 @@ lower_attrib_can_override() const { * */ void ColorScaleAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "off"; diff --git a/panda/src/pgraph/colorWriteAttrib.cxx b/panda/src/pgraph/colorWriteAttrib.cxx index 98c889a0de..671fa82629 100644 --- a/panda/src/pgraph/colorWriteAttrib.cxx +++ b/panda/src/pgraph/colorWriteAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void ColorWriteAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_channels == 0) { out << "off"; diff --git a/panda/src/pgraph/compassEffect.cxx b/panda/src/pgraph/compassEffect.cxx index d972e7f45a..41bd9af880 100644 --- a/panda/src/pgraph/compassEffect.cxx +++ b/panda/src/pgraph/compassEffect.cxx @@ -50,7 +50,7 @@ safe_to_transform() const { * */ void CompassEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_properties == 0) { out << " none"; diff --git a/panda/src/pgraph/cullBinAttrib.cxx b/panda/src/pgraph/cullBinAttrib.cxx index f8eb40626d..27238c9c31 100644 --- a/panda/src/pgraph/cullBinAttrib.cxx +++ b/panda/src/pgraph/cullBinAttrib.cxx @@ -28,7 +28,7 @@ int CullBinAttrib::_attrib_slot; * only to certain kinds of bins (in particular CullBinFixed type bins). */ CPT(RenderAttrib) CullBinAttrib:: -make(const string &bin_name, int draw_order) { +make(const std::string &bin_name, int draw_order) { CullBinAttrib *attrib = new CullBinAttrib; attrib->_bin_name = bin_name; attrib->_draw_order = draw_order; @@ -48,7 +48,7 @@ make_default() { * */ void CullBinAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_bin_name.empty()) { out << "(default)"; diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 56aed8c730..5826905c89 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -18,6 +18,8 @@ #include "string_utils.h" #include "configVariableColor.h" +using std::string; + CullBinManager *CullBinManager::_global_ptr = nullptr; /** @@ -165,7 +167,7 @@ find_bin(const string &name) const { * */ void CullBinManager:: -write(ostream &out) const { +write(std::ostream &out) const { if (!_bins_are_sorted) { ((CullBinManager *)this)->do_sort_bins(); } @@ -316,8 +318,8 @@ parse_bin_type(const string &bin_type) { /** * */ -ostream & -operator << (ostream &out, CullBinManager::BinType bin_type) { +std::ostream & +operator << (std::ostream &out, CullBinManager::BinType bin_type) { switch (bin_type) { case CullBinManager::BT_invalid: return out << "invalid"; diff --git a/panda/src/pgraph/cullFaceAttrib.cxx b/panda/src/pgraph/cullFaceAttrib.cxx index db3527a653..054d8061b3 100644 --- a/panda/src/pgraph/cullFaceAttrib.cxx +++ b/panda/src/pgraph/cullFaceAttrib.cxx @@ -99,7 +99,7 @@ get_effective_mode() const { * */ void CullFaceAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_actual_mode()) { case M_cull_none: diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index fcb7a0c532..fafbae6cfa 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -18,6 +18,9 @@ #include "occluderEffect.h" #include "boundingBox.h" +using std::max; +using std::min; + /** * Returns a pointer to an empty CullPlanes object. */ @@ -200,8 +203,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (plane.get_normal().dot(LVector3::forward()) >= 0.0) { if (occluder_node->is_double_sided()) { - swap(points_near[0], points_near[3]); - swap(points_near[1], points_near[2]); + std::swap(points_near[0], points_near[3]); + std::swap(points_near[1], points_near[2]); plane = LPlane(points_near[0], points_near[1], points_near[2]); } else { // This occluder is facing the wrong direction. Ignore it. @@ -429,7 +432,7 @@ remove_occluder(const NodePath &occluder) const { * */ void CullPlanes:: -write(ostream &out) const { +write(std::ostream &out) const { out << "CullPlanes (" << _planes.size() << " planes and " << _occluders.size() << " occluders):\n"; Planes::const_iterator pi; diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 8f3e8dc19a..faee06ee53 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -359,7 +359,7 @@ make_new_bin(int bin_index) { nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), nullptr); // Prevent unnecessary refunref by swapping the PointerTos. - swap(_bins[bin_index], bin); + std::swap(_bins[bin_index], bin); } return bin_ptr; diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 50726c2ee7..0ecf27666a 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -237,7 +237,7 @@ draw_bounding_volume(const BoundingVolume *vol, _cull_handler->record_object(outer_viz, this); CullableObject *inner_viz = - new CullableObject(move(bounds_viz), get_bounds_inner_viz_state(), + new CullableObject(std::move(bounds_viz), get_bounds_inner_viz_state(), internal_transform); _cull_handler->record_object(inner_viz, this); } @@ -267,7 +267,7 @@ show_bounds(CullTraverserData &data, bool tight) { if (bounds_viz != nullptr) { _geoms_pcollector.add_level(1); CullableObject *outer_viz = - new CullableObject(move(bounds_viz), get_bounds_outer_viz_state(), + new CullableObject(std::move(bounds_viz), get_bounds_outer_viz_state(), internal_transform); _cull_handler->record_object(outer_viz, this); } diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index e0aed703e9..8d54308af8 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -41,7 +41,7 @@ apply_transform_and_state(CullTraverser *trav) { // camera. This indicates some special state transition for this node, // which is unique to this camera. const Camera *camera = trav->get_scene()->get_camera_node(); - string tag_state = _node_reader.get_tag(trav->get_tag_state_key()); + std::string tag_state = _node_reader.get_tag(trav->get_tag_state_key()); node_state = node_state->compose(camera->get_tag_state(tag_state)); } _node_reader.compose_draw_mask(_draw_mask); @@ -154,7 +154,7 @@ is_in_view_impl() { if (pgraph_cat.is_spam()) { pgraph_cat.spam() - << get_node_path() << " cull result = " << hex << result << dec << "\n"; + << get_node_path() << " cull result = " << std::hex << result << std::dec << "\n"; } if (result == BoundingVolume::IF_no_intersection) { @@ -202,8 +202,8 @@ is_in_view_impl() { if (pgraph_cat.is_spam()) { pgraph_cat.spam() - << get_node_path() << " cull planes cull result = " << hex - << result << dec << "\n"; + << get_node_path() << " cull planes cull result = " << std::hex + << result << std::dec << "\n"; _cull_planes->write(pgraph_cat.spam(false)); } diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 3e6db8453c..dae73b00ed 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -114,8 +114,8 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "munge_points_to_quads() for geometry with bits: " - << hex << geom_rendering << ", unsupported: " - << (unsupported_bits & Geom::GR_point_bits) << dec << "\n"; + << std::hex << geom_rendering << ", unsupported: " + << (unsupported_bits & Geom::GR_point_bits) << std::dec << "\n"; } if (!munge_points_to_quads(traverser, force)) { return false; @@ -161,7 +161,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, _munged_data->animate_vertices(force, current_thread); if (animated_vertices != _munged_data) { cpu_animated = true; - swap(_munged_data, animated_vertices); + std::swap(_munged_data, animated_vertices); } #ifndef NDEBUG @@ -187,7 +187,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, * */ void CullableObject:: -output(ostream &out) const { +output(std::ostream &out) const { if (_geom != nullptr) { out << *_geom; } else { @@ -583,7 +583,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } _geom = new_geom.p(); - _munged_data = move(new_data); + _munged_data = std::move(new_data); return true; } diff --git a/panda/src/pgraph/depthOffsetAttrib.cxx b/panda/src/pgraph/depthOffsetAttrib.cxx index a04e72bffb..5516dd52ff 100644 --- a/panda/src/pgraph/depthOffsetAttrib.cxx +++ b/panda/src/pgraph/depthOffsetAttrib.cxx @@ -60,7 +60,7 @@ make_default() { * */ void DepthOffsetAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":(" << get_offset() << ", " << get_min_value() << ", " << get_max_value() << ")"; } diff --git a/panda/src/pgraph/depthTestAttrib.cxx b/panda/src/pgraph/depthTestAttrib.cxx index b75f63b436..eb4093b168 100644 --- a/panda/src/pgraph/depthTestAttrib.cxx +++ b/panda/src/pgraph/depthTestAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void DepthTestAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; output_comparefunc(out,_mode); } diff --git a/panda/src/pgraph/depthWriteAttrib.cxx b/panda/src/pgraph/depthWriteAttrib.cxx index eef6264d47..b12d0c30b8 100644 --- a/panda/src/pgraph/depthWriteAttrib.cxx +++ b/panda/src/pgraph/depthWriteAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void DepthWriteAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_off: diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index 2ea72cd889..07c8f1f931 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -22,7 +22,7 @@ TypeHandle FindApproxLevelEntry::_type_handle; * Formats the entry for meaningful output. For debugging only. */ void FindApproxLevelEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _node_path << "):"; if (is_solution(0)) { out << " solution!"; @@ -38,7 +38,7 @@ output(ostream &out) const { * For debugging only. */ void FindApproxLevelEntry:: -write_level(ostream &out, int indent_level) const { +write_level(std::ostream &out, int indent_level) const { for (const FindApproxLevelEntry *entry = this; entry != nullptr; entry = entry->_next) { diff --git a/panda/src/pgraph/findApproxPath.cxx b/panda/src/pgraph/findApproxPath.cxx index 0b8d035580..093a160f32 100644 --- a/panda/src/pgraph/findApproxPath.cxx +++ b/panda/src/pgraph/findApproxPath.cxx @@ -17,6 +17,9 @@ #include "string_utils.h" #include "pandaNode.h" +using std::ostream; +using std::string; + /** * Returns true if the indicated node matches this component, false otherwise. diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 654c6fd613..dc45af63ee 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -27,8 +27,8 @@ TypeHandle Fog::_type_handle; -ostream & -operator << (ostream &out, Fog::Mode mode) { +std::ostream & +operator << (std::ostream &out, Fog::Mode mode) { switch (mode) { case Fog::M_linear: return out << "linear"; @@ -47,7 +47,7 @@ operator << (ostream &out, Fog::Mode mode) { * */ Fog:: -Fog(const string &name) : +Fog(const std::string &name) : PandaNode(name) { _mode = M_linear; @@ -112,7 +112,7 @@ xform(const LMatrix4 &mat) { * */ void Fog:: -output(ostream &out) const { +output(std::ostream &out) const { out << "fog: " << _mode; switch (_mode) { case M_linear: diff --git a/panda/src/pgraph/fogAttrib.cxx b/panda/src/pgraph/fogAttrib.cxx index 17016cd7b0..3a511f7d19 100644 --- a/panda/src/pgraph/fogAttrib.cxx +++ b/panda/src/pgraph/fogAttrib.cxx @@ -54,7 +54,7 @@ make_off() { * */ void FogAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "(off)"; diff --git a/panda/src/pgraph/geomDrawCallbackData.cxx b/panda/src/pgraph/geomDrawCallbackData.cxx index 1b6dc76082..b8bdae2d78 100644 --- a/panda/src/pgraph/geomDrawCallbackData.cxx +++ b/panda/src/pgraph/geomDrawCallbackData.cxx @@ -21,7 +21,7 @@ TypeHandle GeomDrawCallbackData::_type_handle; * */ void GeomDrawCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_obj << ", " << (void *)_gsg << ", " << _force << ")"; } diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index cbbb7bb609..328870364a 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -51,7 +51,7 @@ TypeHandle GeomNode::_type_handle; * */ GeomNode:: -GeomNode(const string &name) : +GeomNode(const std::string &name) : PandaNode(name) { _preserved = preserve_geom_nodes; @@ -559,7 +559,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } CullableObject *object = - new CullableObject(move(geom), move(state), internal_transform); + new CullableObject(std::move(geom), std::move(state), internal_transform); trav->get_cull_handler()->record_object(object, trav); } } @@ -782,7 +782,7 @@ unify(int max_indices, bool preserve_order) { * Writes a short description of all the Geoms in the node. */ void GeomNode:: -write_geoms(ostream &out, int indent_level) const { +write_geoms(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); write(out, indent_level); GeomList::const_iterator gi; @@ -798,7 +798,7 @@ write_geoms(ostream &out, int indent_level) const { * Writes a detailed description of all the Geoms in the node. */ void GeomNode:: -write_verbose(ostream &out, int indent_level) const { +write_verbose(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); write(out, indent_level); GeomList::const_iterator gi; @@ -816,7 +816,7 @@ write_verbose(ostream &out, int indent_level) const { * */ void GeomNode:: -output(ostream &out) const { +output(std::ostream &out) const { // Accumulate the total set of RenderAttrib types that are applied to any of // our Geoms, so we can output them too. The result will be the list of // attrib types that might be applied to some Geoms, but not necessarily to diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index e21327b304..cfc023b528 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -151,7 +151,7 @@ transform_vertices(GeomNode *node, const LMatrix4 &mat) { GeomNode::GeomEntry &entry = (*gi); PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy(); if (transform_vertices(new_geom, mat)) { - entry._geom = move(new_geom); + entry._geom = std::move(new_geom); any_changed = true; } } @@ -1479,7 +1479,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { PT(GeomVertexData) new_vdata = new GeomVertexData(*vdata); new_vdata->unclean_set_num_rows(new_num_vertices); - int num_arrays = vdata->get_num_arrays(); + size_t num_arrays = vdata->get_num_arrays(); nassertv(num_arrays == new_vdata->get_num_arrays()); GeomVertexDataPipelineReader reader(vdata, current_thread); @@ -1487,7 +1487,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { GeomVertexDataPipelineWriter writer(new_vdata, true, current_thread); writer.check_array_writers(); - for (int a = 0; a < num_arrays; ++a) { + for (size_t a = 0; a < num_arrays; ++a) { const GeomVertexArrayDataHandle *array_reader = reader.get_array_reader(a); GeomVertexArrayDataHandle *array_writer = writer.get_array_writer(a); diff --git a/panda/src/pgraph/internalNameCollection.cxx b/panda/src/pgraph/internalNameCollection.cxx index 93b92e3518..9c3779c88e 100644 --- a/panda/src/pgraph/internalNameCollection.cxx +++ b/panda/src/pgraph/internalNameCollection.cxx @@ -211,7 +211,7 @@ size() const { * indicated output stream. */ void InternalNameCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_names() == 1) { out << "1 InternalName"; } else { @@ -224,7 +224,7 @@ output(ostream &out) const { * the indicated output stream. */ void InternalNameCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_names(); i++) { indent(out, indent_level) << *get_name(i) << "\n"; } diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 60307c2ce0..1b428d9e98 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -26,7 +26,7 @@ TypeHandle LensNode::_type_handle; * */ LensNode:: -LensNode(const string &name, Lens *lens) : +LensNode(const std::string &name, Lens *lens) : PandaNode(name) { if (lens == nullptr) { @@ -171,7 +171,7 @@ hide_frustum() { * */ void LensNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " ("; @@ -190,7 +190,7 @@ output(ostream &out) const { * */ void LensNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); for (Lenses::const_iterator li = _lenses.begin(); diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 1ad177b1b4..1d6fce8cf7 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -420,7 +420,7 @@ add_on_light(const NodePath &light) const { LightAttrib *attrib = new LightAttrib(*this); - pair insert_result = + std::pair insert_result = attrib->_on_lights.insert(Lights::value_type(light)); if (insert_result.second) { lobj->attrib_ref(); @@ -523,7 +523,7 @@ get_ambient_contribution() const { * */ void LightAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_off_lights.empty()) { if (_on_lights.empty()) { @@ -572,7 +572,7 @@ output(ostream &out) const { * */ void LightAttrib:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":"; if (_off_lights.empty()) { if (_on_lights.empty()) { diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 93adfc305b..3f5caee8d9 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -176,7 +176,7 @@ make_hdr2() { * */ void LightRampAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (_mode) { case LRT_default: diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 866f3c2f14..03ae0e0587 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -32,6 +32,8 @@ #include "configVariableInt.h" #include "configVariableEnum.h" +using std::string; + bool Loader::_file_types_loaded = false; PT(Loader) Loader::_global_ptr; TypeHandle Loader::_type_handle; @@ -96,7 +98,7 @@ make_async_save_request(const Filename &filename, const LoaderOptions &options, * graph defined there. */ PT(PandaNode) Loader:: -load_bam_stream(istream &in) { +load_bam_stream(std::istream &in) { BamFile bam_file; if (!bam_file.open_read(in)) { return nullptr; @@ -109,7 +111,7 @@ load_bam_stream(istream &in) { * */ void Loader:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); int num_tasks = _task_manager->make_task_chain(_task_chain)->get_num_tasks(); @@ -473,15 +475,15 @@ load_file_types() { string name = words[0]; Filename dlname = Filename::dso_filename("lib" + name + ".so"); loader_cat.info() - << "loading file type module: " << name << endl; + << "loading file type module: " << name << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { loader_cat.warning() << "Unable to load " << dlname.to_os_specific() - << ": " << load_dso_error() << endl; + << ": " << load_dso_error() << std::endl; } else if (loader_cat.is_debug()) { loader_cat.debug() - << "done loading file type module: " << name << endl; + << "done loading file type module: " << name << std::endl; } } else if (words.size() > 1) { diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index a7189526ed..262da5859f 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -41,9 +41,9 @@ LoaderFileType:: * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this loader. */ -string LoaderFileType:: +std::string LoaderFileType:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/panda/src/pgraph/loaderFileTypeBam.cxx b/panda/src/pgraph/loaderFileTypeBam.cxx index 985ffb706a..7d2f6fd2cd 100644 --- a/panda/src/pgraph/loaderFileTypeBam.cxx +++ b/panda/src/pgraph/loaderFileTypeBam.cxx @@ -32,7 +32,7 @@ LoaderFileTypeBam() { /** * */ -string LoaderFileTypeBam:: +std::string LoaderFileTypeBam:: get_name() const { return "Bam"; } @@ -40,7 +40,7 @@ get_name() const { /** * */ -string LoaderFileTypeBam:: +std::string LoaderFileTypeBam:: get_extension() const { return "bam"; } diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index 6f5f6fed44..c7df6731eb 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -21,6 +21,8 @@ #include +using std::string; + LoaderFileTypeRegistry *LoaderFileTypeRegistry::_global_ptr; /** @@ -152,16 +154,16 @@ get_type_from_extension(const string &extension) { _deferred_types.erase(di); loader_cat->info() - << "loading file type module: " << name << endl; + << "loading file type module: " << name << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { loader_cat->warning() << "Unable to load " << dlname.to_os_specific() << ": " - << load_dso_error() << endl; + << load_dso_error() << std::endl; return nullptr; } else if (loader_cat.is_debug()) { loader_cat.debug() - << "done loading file type module: " << name << endl; + << "done loading file type module: " << name << std::endl; } // Now try again to find the LoaderFileType. @@ -183,7 +185,7 @@ get_type_from_extension(const string &extension) { * per line. */ void LoaderFileTypeRegistry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_types.empty()) { indent(out, indent_level) << "(No file types are known).\n"; } else { @@ -192,7 +194,7 @@ write(ostream &out, int indent_level) const { LoaderFileType *type = (*ti); string name = type->get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) << " "; + indent(out, std::max(30 - (int)name.length(), 0)) << " "; bool comma = false; if (!type->get_extension().empty()) { diff --git a/panda/src/pgraph/logicOpAttrib.cxx b/panda/src/pgraph/logicOpAttrib.cxx index 28381dfc5b..75aff15fce 100644 --- a/panda/src/pgraph/logicOpAttrib.cxx +++ b/panda/src/pgraph/logicOpAttrib.cxx @@ -53,7 +53,7 @@ make_default() { * */ void LogicOpAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":" << get_operation(); } @@ -138,8 +138,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { /** * */ -ostream & -operator << (ostream &out, LogicOpAttrib::Operation op) { +std::ostream & +operator << (std::ostream &out, LogicOpAttrib::Operation op) { switch (op) { case LogicOpAttrib::O_none: return out << "none"; diff --git a/panda/src/pgraph/materialAttrib.cxx b/panda/src/pgraph/materialAttrib.cxx index baeac4dc38..2ff453b8c6 100644 --- a/panda/src/pgraph/materialAttrib.cxx +++ b/panda/src/pgraph/materialAttrib.cxx @@ -56,7 +56,7 @@ make_default() { * */ void MaterialAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_material != nullptr) { out << *_material; diff --git a/panda/src/pgraph/materialCollection.cxx b/panda/src/pgraph/materialCollection.cxx index 386758f1c5..37fbd79c80 100644 --- a/panda/src/pgraph/materialCollection.cxx +++ b/panda/src/pgraph/materialCollection.cxx @@ -173,7 +173,7 @@ clear() { * NULL if no material has that name. */ Material *MaterialCollection:: -find_material(const string &name) const { +find_material(const std::string &name) const { int num_materials = get_num_materials(); for (int i = 0; i < num_materials; i++) { Material *material = get_material(i); @@ -227,7 +227,7 @@ size() const { * indicated output stream. */ void MaterialCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_materials() == 1) { out << "1 Material"; } else { @@ -240,7 +240,7 @@ output(ostream &out) const { * indicated output stream. */ void MaterialCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_materials(); i++) { indent(out, indent_level) << *get_material(i) << "\n"; } diff --git a/panda/src/pgraph/modelLoadRequest.cxx b/panda/src/pgraph/modelLoadRequest.cxx index 4feba702ef..0bbec06161 100644 --- a/panda/src/pgraph/modelLoadRequest.cxx +++ b/panda/src/pgraph/modelLoadRequest.cxx @@ -22,7 +22,7 @@ TypeHandle ModelLoadRequest::_type_handle; * to begin an asynchronous load. */ ModelLoadRequest:: -ModelLoadRequest(const string &name, +ModelLoadRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader) : AsyncTask(name), diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index b5722f2271..c53e2b867f 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -25,7 +25,7 @@ ModelPool *ModelPool::_global_ptr = nullptr; * with debugging. */ void ModelPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -259,7 +259,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void ModelPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << "model pool contents:\n"; diff --git a/panda/src/pgraph/modelSaveRequest.cxx b/panda/src/pgraph/modelSaveRequest.cxx index 31c50cfdf6..eefca944d4 100644 --- a/panda/src/pgraph/modelSaveRequest.cxx +++ b/panda/src/pgraph/modelSaveRequest.cxx @@ -22,7 +22,7 @@ TypeHandle ModelSaveRequest::_type_handle; * to begin an asynchronous save. */ ModelSaveRequest:: -ModelSaveRequest(const string &name, +ModelSaveRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader) : AsyncTask(name), diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 065bef7424..a21df38d19 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -73,6 +73,12 @@ #include "datagramBuffer.h" #include "weakNodePath.h" +using std::max; +using std::move; +using std::ostream; +using std::ostringstream; +using std::string; + // stack seems to overflow on Intel C++ at 7000. If we need more than 7000, // need to increase stack size. int NodePath::_max_search_depth = 7000; @@ -5171,7 +5177,7 @@ get_stashed_ancestor(Thread *current_thread) const { */ bool NodePath:: operator == (const WeakNodePath &other) const { - return _head == other._head; + return (other == *this); } /** @@ -5179,7 +5185,7 @@ operator == (const WeakNodePath &other) const { */ bool NodePath:: operator != (const WeakNodePath &other) const { - return _head != other._head; + return (other != *this); } /** @@ -5190,7 +5196,7 @@ operator != (const WeakNodePath &other) const { */ bool NodePath:: operator < (const WeakNodePath &other) const { - return _head < other._head; + return other.compare_to(*this) > 0; } /** @@ -5205,13 +5211,7 @@ operator < (const WeakNodePath &other) const { */ int NodePath:: compare_to(const WeakNodePath &other) const { - // Nowadays, the NodePathComponents at the head are pointerwise equivalent - // if and only if the NodePaths are equivalent. So we only have to compare - // pointers. - if (_head != other._head) { - return _head < other._head ? -1 : 1; - } - return 0; + return -other.compare_to(*this); } /** diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 8f29f07f22..545691d0fc 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -19,6 +19,9 @@ #include "colorAttrib.h" #include "indent.h" +using std::max; +using std::min; + /** * Adds a new NodePath to the collection. */ @@ -208,7 +211,7 @@ size() const { * hierarchically. */ void NodePathCollection:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { NodePath path = get_path(i); indent(out, indent_level) << path << "\n"; @@ -223,7 +226,7 @@ ls(ostream &out, int indent_level) const { * listed first. */ NodePathCollection NodePathCollection:: -find_all_matches(const string &path) const { +find_all_matches(const std::string &path) const { NodePathCollection result; FindApproxPath approx_path; @@ -557,7 +560,7 @@ set_attrib(const RenderAttrib *attrib, int priority) { * indicated output stream. */ void NodePathCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_paths() == 1) { out << "1 NodePath"; } else { @@ -570,7 +573,7 @@ output(ostream &out) const { * indicated output stream. */ void NodePathCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { indent(out, indent_level) << get_path(i) << "\n"; } diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 1e2b13fe1e..836e2959e0 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -48,9 +48,9 @@ __init__(PyObject *self, PyObject *sequence) { NodePath *path; if (!DtoolInstance_GetPointer(item, path, Dtool_NodePath)) { // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; + std::ostringstream stream; stream << "Element " << i << " in sequence passed to NodePathCollection constructor is not a NodePath"; - string str = stream.str(); + std::string str = stream.str(); PyErr_SetString(PyExc_TypeError, str.c_str()); Py_DECREF(fast); return; diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index dd767cf172..fa578ba53f 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -121,7 +121,7 @@ fix_length(int pipeline_stage, Thread *current_thread) { * the end of the linked list and then outputting from there. */ void NodePathComponent:: -output(ostream &out) const { +output(std::ostream &out) const { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index f167d0c57a..4be58f3201 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -16,6 +16,8 @@ #include "shaderInput_ext.h" #include "shaderAttrib.h" +using std::move; + #ifdef HAVE_PYTHON #ifndef CPPPARSER @@ -123,9 +125,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { vector_uchar bam_stream; if (!_this->encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; + std::ostringstream stream; stream << "Could not bamify " << _this; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } @@ -294,7 +296,7 @@ set_shader_inputs(PyObject *args, PyObject *kwargs) { return; } - CPT_InternalName name(string(buffer, length)); + CPT_InternalName name(std::string(buffer, length)); ShaderInput &input = attrib->_inputs[name]; invoke_extension(&input).__init__(move(name), value); } diff --git a/panda/src/pgraph/occluderEffect.cxx b/panda/src/pgraph/occluderEffect.cxx index 9e81d4e52d..eceb1afd6e 100644 --- a/panda/src/pgraph/occluderEffect.cxx +++ b/panda/src/pgraph/occluderEffect.cxx @@ -66,7 +66,7 @@ remove_on_occluder(const NodePath &occluder) const { * */ void OccluderEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_on_occluders.empty()) { out << "identity"; diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index 3fc81bc944..09f8bbd038 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -51,7 +51,7 @@ PT(Texture) OccluderNode::_viz_tex; * vertices with set_vertices(). */ OccluderNode:: -OccluderNode(const string &name) : +OccluderNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -174,7 +174,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void OccluderNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index c6cc323d2a..6994e643f8 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -28,6 +28,10 @@ #include "lightReMutexHolder.h" #include "graphicsStateGuardianBase.h" +using std::ostream; +using std::ostringstream; +using std::string; + // This category is just temporary for debugging convenience. NotifyCategoryDecl(drawmask, EXPCL_PANDA_PGRAPH, EXPTP_PANDA_PGRAPH); NotifyCategoryDef(drawmask, ""); @@ -2118,7 +2122,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { TypedWritable *object; ReferenceCount *ref_ptr; - if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, move(data), reader)) { + if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, std::move(data), reader)) { return DCAST(PandaNode, object); } else { return nullptr; diff --git a/panda/src/pgraph/paramNodePath.cxx b/panda/src/pgraph/paramNodePath.cxx index 32d5aeb585..72a3563b22 100644 --- a/panda/src/pgraph/paramNodePath.cxx +++ b/panda/src/pgraph/paramNodePath.cxx @@ -21,7 +21,7 @@ TypeHandle ParamNodePath::_type_handle; * */ void ParamNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { out << "node path " << _node_path; } diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index 2af7609809..9513b23509 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -59,7 +59,7 @@ fillin(DatagramIterator &scan, BamReader *) { * */ PlaneNode:: -PlaneNode(const string &name, const LPlane &plane) : +PlaneNode(const std::string &name, const LPlane &plane) : PandaNode(name), _priority(0), _clip_effect(~0) @@ -88,7 +88,7 @@ PlaneNode(const PlaneNode ©) : * */ void PlaneNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " " << get_plane(); } diff --git a/panda/src/pgraph/polylightEffect.cxx b/panda/src/pgraph/polylightEffect.cxx index acbd41b18f..f940a62c8c 100644 --- a/panda/src/pgraph/polylightEffect.cxx +++ b/panda/src/pgraph/polylightEffect.cxx @@ -22,6 +22,8 @@ #include +using std::endl; + TypeHandle PolylightEffect::_type_handle; /** @@ -334,7 +336,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran * */ void PolylightEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; LightGroup::const_iterator li; @@ -461,8 +463,8 @@ has_light(const NodePath &light) const { return (li != _lightgroup.end()); } -ostream & -operator << (ostream &out, PolylightEffect::ContribType ct) { +std::ostream & +operator << (std::ostream &out, PolylightEffect::ContribType ct) { switch (ct) { case PolylightEffect::CT_proximal: return out << "proximal"; diff --git a/panda/src/pgraph/polylightNode.cxx b/panda/src/pgraph/polylightNode.cxx index e7b857367b..73242aab04 100644 --- a/panda/src/pgraph/polylightNode.cxx +++ b/panda/src/pgraph/polylightNode.cxx @@ -29,7 +29,7 @@ TypeHandle PolylightNode::_type_handle; * Use PolylightNode() to construct a new PolylightNode object. */ PolylightNode:: -PolylightNode(const string &name) : +PolylightNode(const std::string &name) : PandaNode(name) { _enabled = true; @@ -100,12 +100,12 @@ LColor PolylightNode::flicker() const { variation = (rand()%100); // a value between 0-99 variation /= 100.0; if (polylight_info) - pgraph_cat.info() << "Random Variation: " << variation << endl; + pgraph_cat.info() << "Random Variation: " << variation << std::endl; } else if (_flicker_type == FSIN) { double now = ClockObject::get_global_clock()->get_frame_time(); variation = sinf(now*_sin_freq); if (polylight_info) - pgraph_cat.info() << "Variation: " << variation << endl; + pgraph_cat.info() << "Variation: " << variation << std::endl; // can't use negative variation, so make it positive if (variation < 0.0) variation *= -1.0; @@ -134,7 +134,7 @@ LColor PolylightNode::flicker() const { b = color[2]; } */ - pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << endl; + pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << std::endl; return LColor(r,g,b,1.0); } @@ -277,7 +277,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ void PolylightNode:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; // out << "Position: " << get_x() << " " << get_y() << " " << get_z() << // "\n"; out << "Color: " << get_r() << " " << get_g() << " " << get_b() << diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index c0fe73f73f..d9d1af727d 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -30,6 +30,10 @@ #include "geomLinestrips.h" #include "geomPoints.h" +using std::endl; +using std::max; +using std::min; + TypeHandle PortalClipper::_type_handle; /** diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index 8ddb409f09..c7ad0444fe 100644 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -30,6 +30,8 @@ #include "plane.h" +using std::endl; + TypeHandle PortalNode::_type_handle; @@ -39,7 +41,7 @@ TypeHandle PortalNode::_type_handle; * Then you can set the vertices yourself, with addVertex. */ PortalNode:: -PortalNode(const string &name) : +PortalNode(const std::string &name) : PandaNode(name), _from_portal_mask(PortalMask::all_on()), _into_portal_mask(PortalMask::all_on()), @@ -58,7 +60,7 @@ PortalNode(const string &name) : * portal and setup from Python */ PortalNode:: -PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) : +PortalNode(const std::string &name, LPoint3 pos, PN_stdfloat scale) : PandaNode(name), _from_portal_mask(PortalMask::all_on()), _into_portal_mask(PortalMask::all_on()), @@ -323,7 +325,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void PortalNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 66c507c1c8..73b1e4b392 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -18,6 +18,8 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" +using std::ostream; + LightReMutex *RenderAttrib::_attribs_lock = nullptr; RenderAttrib::Attribs *RenderAttrib::_attribs = nullptr; TypeHandle RenderAttrib::_type_handle; @@ -198,7 +200,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return 0; } @@ -208,7 +210,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (_garbage_index + num_this_pass) % size; do { @@ -266,7 +268,7 @@ validate_attribs() { for (size_t si = 0; si < size; ++si) { const RenderAttrib *attrib = _attribs->get_key(si); //cerr << si << ": " << attrib << "\n"; - attrib->write(cerr, 2); + attrib->write(std::cerr, 2); } return false; diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 583c04d812..da052c0073 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -151,7 +151,7 @@ adjust_transform(CPT(TransformState) &, CPT(TransformState) &, * */ void RenderEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -159,7 +159,7 @@ output(ostream &out) const { * */ void RenderEffect:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } @@ -181,7 +181,7 @@ get_num_effects() { * prepared. */ void RenderEffect:: -list_effects(ostream &out) { +list_effects(std::ostream &out) { out << _effects->size() << " effects:\n"; Effects::const_iterator si; for (si = _effects->begin(); si != _effects->end(); ++si) { @@ -247,7 +247,7 @@ return_new(RenderEffect *effect) { // of this function if no one else uses it. CPT(RenderEffect) pt_effect = effect; - pair result = _effects->insert(effect); + std::pair result = _effects->insert(effect); if (result.second) { // The effect was inserted; save the iterator and return the input effect. effect->_saved_entry = result.first; diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 4ef038625d..3c1b1066bb 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -351,7 +351,7 @@ unref() const { * */ void RenderEffects:: -output(ostream &out) const { +output(std::ostream &out) const { out << "E:"; if (_effects.empty()) { out << "(empty)"; @@ -372,7 +372,7 @@ output(ostream &out) const { * */ void RenderEffects:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _effects.size() << " effects:\n"; Effects::const_iterator ai; for (ai = _effects.begin(); ai != _effects.end(); ++ai) { @@ -400,7 +400,7 @@ get_num_states() { * prepared. */ void RenderEffects:: -list_states(ostream &out) { +list_states(std::ostream &out) { out << _states->size() << " states:\n"; States::const_iterator si; for (si = _states->begin(); si != _states->end(); ++si) { @@ -538,7 +538,7 @@ return_new(RenderEffects *state) { // of this function if no one else uses it. CPT(RenderEffects) pt_state = state; - pair result = _states->insert(state); + std::pair result = _states->insert(state); if (result.second) { // The state was inserted; save the iterator and return the input state. state->_saved_entry = result.first; diff --git a/panda/src/pgraph/renderModeAttrib.cxx b/panda/src/pgraph/renderModeAttrib.cxx index efdf3e7434..1b2b41c9ad 100644 --- a/panda/src/pgraph/renderModeAttrib.cxx +++ b/panda/src/pgraph/renderModeAttrib.cxx @@ -60,7 +60,7 @@ make_default() { * */ void RenderModeAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_unchanged: diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index faf68f2fe2..d232ecb00a 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -483,7 +483,7 @@ flush_level() { #ifndef CPPPARSER /** - * Handy templated version of get_attrib that costs to the right type. + * Handy templated version of get_attrib that casts to the right type. * Returns true if the attribute was present, false otherwise. */ template @@ -492,15 +492,26 @@ get_attrib(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); return (attrib != nullptr); } +template +INLINE bool RenderState:: +get_attrib(CPT(AttribType) &attrib) const { + attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); + return (attrib != nullptr); +} /** - * Handy templated version of get_attrib_def that costs to the right type. + * Handy templated version of get_attrib_def that casts to the right type. */ template INLINE void RenderState:: get_attrib_def(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot()); } +template +INLINE void RenderState:: +get_attrib_def(CPT(AttribType) &attrib) const { + attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot()); +} #endif // CPPPARSER /** diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 1a8a3f0a56..927d1e7073 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -36,6 +36,8 @@ #include "thread.h" #include "renderAttribRegistry.h" +using std::ostream; + LightReMutex *RenderState::_states_lock = nullptr; RenderState::States *RenderState::_states = nullptr; const RenderState *RenderState::_empty_state = nullptr; @@ -590,7 +592,7 @@ adjust_all_priorities(int adjustment) const { while (slot >= 0) { Attribute &attrib = new_state->_attributes[slot]; nassertr(attrib._attrib != nullptr, this); - attrib._override = max(attrib._override + adjustment, 0); + attrib._override = std::max(attrib._override + adjustment, 0); mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); @@ -756,7 +758,7 @@ get_num_unused_states() { const RenderState *result = state->_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { // Here's a RenderState that's recorded in the cache. Count it. - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { // If the above insert operation fails, then it's already in the @@ -769,7 +771,7 @@ get_num_unused_states() { for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { (*(ir.first)).second++; @@ -904,7 +906,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return num_attribs; } @@ -916,7 +918,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (si + num_this_pass) % size; do { @@ -1733,7 +1735,7 @@ determine_bin_index() { return; } - string bin_name; + std::string bin_name; _draw_order = 0; const CullBinAttrib *bin; diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index ab59a6648d..c9e3719082 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -162,7 +162,11 @@ public: template INLINE bool get_attrib(const AttribType *&attrib) const; template + INLINE bool get_attrib(CPT(AttribType) &attrib) const; + template INLINE void get_attrib_def(const AttribType *&attrib) const; + template + INLINE void get_attrib_def(CPT(AttribType) &attrib) const; #endif // CPPPARSER private: diff --git a/panda/src/pgraph/rescaleNormalAttrib.cxx b/panda/src/pgraph/rescaleNormalAttrib.cxx index fbc4d59274..0b93da7a23 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.cxx +++ b/panda/src/pgraph/rescaleNormalAttrib.cxx @@ -22,6 +22,10 @@ #include "configVariableEnum.h" #include "config_pgraph.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle RescaleNormalAttrib::_type_handle; int RescaleNormalAttrib::_attrib_slot; CPT(RenderAttrib) RescaleNormalAttrib::_attribs[RescaleNormalAttrib::M_auto + 1]; diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index 3b1e075a90..03179d38dd 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -51,7 +51,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { int max_vertices = max_collect_vertices; if (_gsg != nullptr) { - max_vertices = min(max_vertices, _gsg->get_max_vertices_per_array()); + max_vertices = std::min(max_vertices, _gsg->get_max_vertices_per_array()); } _transformer.set_max_collect_vertices(max_vertices); @@ -181,7 +181,7 @@ unify(PandaNode *root, bool preserve_order) { int max_indices = max_collect_indices; if (_gsg != nullptr) { - max_indices = min(max_indices, _gsg->get_max_vertices_per_primitive()); + max_indices = std::min(max_indices, _gsg->get_max_vertices_per_primitive()); } r_unify(root, max_indices, preserve_order); } @@ -376,7 +376,7 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "SceneGraphReducer::r_flatten(" << *grandparent_node << ", " - << *parent_node << ", " << hex << combine_siblings_bits << dec + << *parent_node << ", " << std::hex << combine_siblings_bits << std::dec << ")\n"; } @@ -730,7 +730,7 @@ collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { */ void SceneGraphReducer:: choose_name(PandaNode *preserve, PandaNode *source1, PandaNode *source2) { - string name; + std::string name; bool got_name = false; name = source1->get_name(); diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index f6281cd083..4e137eec5b 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -19,6 +19,9 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; + TypeHandle ScissorAttrib::_type_handle; int ScissorAttrib::_attrib_slot; CPT(RenderAttrib) ScissorAttrib::_off_attrib; @@ -78,7 +81,7 @@ make_default() { * */ void ScissorAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":[" << _frame << "]"; } diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 8e0d47ca9e..dbfa96cf9e 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -23,6 +23,9 @@ #include "boundingHexahedron.h" #include "lens.h" +using std::max; +using std::min; + TypeHandle ScissorEffect::_type_handle; /** @@ -155,7 +158,7 @@ xform(const LMatrix4 &mat) const { * */ void ScissorEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_screen()) { out << "screen [" << _frame << "]"; diff --git a/panda/src/pgraph/shadeModelAttrib.cxx b/panda/src/pgraph/shadeModelAttrib.cxx index dea61a8521..26fac679b4 100644 --- a/panda/src/pgraph/shadeModelAttrib.cxx +++ b/panda/src/pgraph/shadeModelAttrib.cxx @@ -45,7 +45,7 @@ make_default() { * */ void ShadeModelAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_flat: diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 982497497e..e519289b28 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -29,6 +29,9 @@ #include "paramTexture.h" #include "shaderBuffer.h" +using std::ostream; +using std::ostringstream; + TypeHandle ShaderAttrib::_type_handle; int ShaderAttrib::_attrib_slot; @@ -214,9 +217,9 @@ set_shader_input(ShaderInput &&input) const { ShaderAttrib *result = new ShaderAttrib(*this); Inputs::iterator i = result->_inputs.find(input.get_name()); if (i == result->_inputs.end()) { - result->_inputs.insert(Inputs::value_type(input.get_name(), move(input))); + result->_inputs.insert(Inputs::value_type(input.get_name(), std::move(input))); } else { - i->second = move(input); + i->second = std::move(input); } return return_new(result); } @@ -247,7 +250,7 @@ clear_shader_input(const InternalName *id) const { * */ CPT(RenderAttrib) ShaderAttrib:: -clear_shader_input(const string &id) const { +clear_shader_input(const std::string &id) const { return clear_shader_input(InternalName::make(id)); } @@ -280,7 +283,7 @@ get_shader_input(const InternalName *id) const { * function does not return NULL --- it returns the "blank" ShaderInput. */ const ShaderInput &ShaderAttrib:: -get_shader_input(const string &id) const { +get_shader_input(const std::string &id) const { return get_shader_input(InternalName::make(id)); } diff --git a/panda/src/pgraph/shaderAttrib_ext.cxx b/panda/src/pgraph/shaderAttrib_ext.cxx index b98badf71b..54acefe0ec 100644 --- a/panda/src/pgraph/shaderAttrib_ext.cxx +++ b/panda/src/pgraph/shaderAttrib_ext.cxx @@ -24,7 +24,7 @@ set_shader_input(CPT_InternalName name, PyObject *value, int priority) const { ShaderAttrib *attrib = new ShaderAttrib(*_this); ShaderInput &input = attrib->_inputs[name]; - invoke_extension(&input).__init__(move(name), value); + invoke_extension(&input).__init__(std::move(name), value); return ShaderAttrib::return_new(attrib); } @@ -60,9 +60,9 @@ set_shader_inputs(PyObject *args, PyObject *kwargs) const { return nullptr; } - CPT_InternalName name(string(buffer, length)); + CPT_InternalName name(std::string(buffer, length)); ShaderInput &input = attrib->_inputs[name]; - invoke_extension(&input).__init__(move(name), value); + invoke_extension(&input).__init__(std::move(name), value); } return ShaderAttrib::return_new(attrib); diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index a1d698cce7..b017045b22 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -30,7 +30,7 @@ get_blank() { */ ShaderInput:: ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_nodepath), _priority(priority), _value(new ParamNodePath(np)) @@ -42,7 +42,7 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_texture_image), _priority(priority), _value(new ParamTextureImage(tex, read, write, z, n)) @@ -54,7 +54,7 @@ ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, i */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_texture_sampler), _priority(priority), _value(new ParamTextureSampler(tex, sampler)) diff --git a/panda/src/pgraph/shaderInput_ext.cxx b/panda/src/pgraph/shaderInput_ext.cxx index d09a971b46..72a4d74de3 100644 --- a/panda/src/pgraph/shaderInput_ext.cxx +++ b/panda/src/pgraph/shaderInput_ext.cxx @@ -58,7 +58,7 @@ extern struct Dtool_PyTypedObject Dtool_ParamValueBase; */ void Extension:: __init__(CPT_InternalName name, PyObject *value, int priority) { - _this->_name = move(name); + _this->_name = std::move(name); _this->_priority = priority; if (PyTuple_CheckExact(value) && PyTuple_GET_SIZE(value) <= 4) { diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index 87823b9e50..0806b5ed32 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -25,7 +25,7 @@ ShaderPool *ShaderPool::_global_ptr = nullptr; * Lists the contents of the shader pool to the indicated output stream. */ void ShaderPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -77,7 +77,7 @@ ns_load_shader(const Filename &orig_filename) { // the file extension. This is really just guesswork - there are no // standardized extensions for shaders, especially for GLSL. These are the // ones that appear to be closest to "standard". - string ext = downcase(filename.get_extension()); + std::string ext = downcase(filename.get_extension()); if (ext == "cg" || ext == "sha") { // "sha" is for historical reasons. lang = Shader::SL_Cg; @@ -182,7 +182,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void ShaderPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _shaders.size() << " shaders:\n"; diff --git a/panda/src/pgraph/stateMunger.cxx b/panda/src/pgraph/stateMunger.cxx index 8eba900f70..5b52442db0 100644 --- a/panda/src/pgraph/stateMunger.cxx +++ b/panda/src/pgraph/stateMunger.cxx @@ -40,7 +40,7 @@ munge_state(const RenderState *state) { } CPT(RenderState) result = munge_state_impl(state); - munged_states.store(id, result.p()); + munged_states.store(id, result); return result; } diff --git a/panda/src/pgraph/stencilAttrib.cxx b/panda/src/pgraph/stencilAttrib.cxx index 13a00165ed..52b047652b 100644 --- a/panda/src/pgraph/stencilAttrib.cxx +++ b/panda/src/pgraph/stencilAttrib.cxx @@ -264,7 +264,7 @@ make_2_sided_with_clear( * */ void StencilAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { int index; for (index = 0; index < SRS_total; index++) { diff --git a/panda/src/pgraph/test_pgraph.cxx b/panda/src/pgraph/test_pgraph.cxx index 45df2fe578..cb2e3a4dde 100644 --- a/panda/src/pgraph/test_pgraph.cxx +++ b/panda/src/pgraph/test_pgraph.cxx @@ -17,13 +17,15 @@ #include "findApproxLevelEntry.h" #include "clockObject.h" +using std::cerr; + NodePath -build_tree(const string &name, int depth) { +build_tree(const std::string &name, int depth) { NodePath node(name); if (depth > 1) { for (int i = 0; i < 3; i++) { char letter = 'a' + i; - string child_name = name + string(1, letter); + std::string child_name = name + std::string(1, letter); NodePath child = build_tree(child_name, depth - 1); child.reparent_to(node); } diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 9842d1158f..32216dab88 100644 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -190,7 +190,7 @@ get_constant_value(TextureStage *stage) const { * */ void TexGenAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index a228b79072..f32e0a8b97 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -179,7 +179,7 @@ get_transform(TextureStage *stage) const { * */ void TexMatrixAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index 5d850ab0f5..456c6556e2 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -142,7 +142,7 @@ get_lens_index(TextureStage *stage) const { * */ void TexProjectorEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index 49bf20f5b9..7f9c6ff8b8 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -345,7 +345,7 @@ lower_attrib_can_override() const { * */ void TextureAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { check_sorted(); out << get_type() << ":"; @@ -891,7 +891,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { override = scan.get_int32(); } - _next_implicit_sort = max(_next_implicit_sort, implicit_sort + 1); + _next_implicit_sort = std::max(_next_implicit_sort, implicit_sort + 1); Stages::iterator si = _on_stages.insert_nonunique(StageNode(nullptr, _next_implicit_sort, override)); ++_next_implicit_sort; diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index 33e3ce00a6..b7fe96d885 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -176,7 +176,7 @@ clear() { * any, or NULL if no texture_stage has that name. */ TextureStage *TextureStageCollection:: -find_texture_stage(const string &name) const { +find_texture_stage(const std::string &name) const { int num_texture_stages = get_num_texture_stages(); for (int i = 0; i < num_texture_stages; i++) { TextureStage *texture_stage = get_texture_stage(i); @@ -240,7 +240,7 @@ sort() { * indicated output stream. */ void TextureStageCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_texture_stages() == 1) { out << "1 TextureStage"; } else { @@ -253,7 +253,7 @@ output(ostream &out) const { * the indicated output stream. */ void TextureStageCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_texture_stages(); i++) { indent(out, indent_level) << *get_texture_stage(i) << "\n"; } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index a58bd78510..453fb505b4 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -24,6 +24,8 @@ #include "lightMutexHolder.h" #include "thread.h" +using std::ostream; + LightReMutex *TransformState::_states_lock = nullptr; TransformState::States *TransformState::_states = nullptr; CPT(TransformState) TransformState::_identity_state; @@ -1025,7 +1027,7 @@ get_num_unused_states() { const TransformState *result = state->_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { // Here's a TransformState that's recorded in the cache. Count it. - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { // If the above insert operation fails, then it's already in the @@ -1038,7 +1040,7 @@ get_num_unused_states() { for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { (*(ir.first)).second++; @@ -1170,7 +1172,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return 0; } @@ -1182,7 +1184,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (si + num_this_pass) % size; do { diff --git a/panda/src/pgraph/transparencyAttrib.cxx b/panda/src/pgraph/transparencyAttrib.cxx index ad105f3214..146e0aa5b4 100644 --- a/panda/src/pgraph/transparencyAttrib.cxx +++ b/panda/src/pgraph/transparencyAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void TransparencyAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_none: diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index c2d4b0a523..3096f99c41 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -124,7 +124,7 @@ node() const { */ INLINE bool WeakNodePath:: operator == (const NodePath &other) const { - return _head == other._head; + return _head.get_orig() == other._head && !_head.was_deleted(); } /** @@ -132,7 +132,7 @@ operator == (const NodePath &other) const { */ INLINE bool WeakNodePath:: operator != (const NodePath &other) const { - return _head != other._head; + return !operator == (other); } /** @@ -143,7 +143,7 @@ operator != (const NodePath &other) const { */ INLINE bool WeakNodePath:: operator < (const NodePath &other) const { - return _head < other._head; + return _head.owner_before(other._head); } /** @@ -158,8 +158,8 @@ operator < (const NodePath &other) const { */ INLINE int WeakNodePath:: compare_to(const NodePath &other) const { - if (_head != other._head) { - return _head < other._head ? -1 : 1; + if (operator != (other)) { + return _head.owner_before(other._head) ? -1 : 1; } return 0; } @@ -170,7 +170,7 @@ compare_to(const NodePath &other) const { */ INLINE bool WeakNodePath:: operator == (const WeakNodePath &other) const { - return _head == other._head; + return !_head.owner_before(other._head) && !other._head.owner_before(_head); } /** @@ -178,7 +178,7 @@ operator == (const WeakNodePath &other) const { */ INLINE bool WeakNodePath:: operator != (const WeakNodePath &other) const { - return _head != other._head; + return _head.owner_before(other._head) || other._head.owner_before(_head); } /** @@ -189,7 +189,7 @@ operator != (const WeakNodePath &other) const { */ INLINE bool WeakNodePath:: operator < (const WeakNodePath &other) const { - return _head < other._head; + return _head.owner_before(other._head); } /** @@ -204,10 +204,7 @@ operator < (const WeakNodePath &other) const { */ INLINE int WeakNodePath:: compare_to(const WeakNodePath &other) const { - if (_head != other._head) { - return _head < other._head ? -1 : 1; - } - return 0; + return other._head.owner_before(_head) - _head.owner_before(other._head); } /** diff --git a/panda/src/pgraph/weakNodePath.cxx b/panda/src/pgraph/weakNodePath.cxx index a83d797cc9..c4d75aad5e 100644 --- a/panda/src/pgraph/weakNodePath.cxx +++ b/panda/src/pgraph/weakNodePath.cxx @@ -17,7 +17,7 @@ * */ void WeakNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { if (was_deleted()) { out << "deleted"; } else { diff --git a/panda/src/pgraph/workingNodePath.cxx b/panda/src/pgraph/workingNodePath.cxx index af9a1fb8e8..0431a1fb85 100644 --- a/panda/src/pgraph/workingNodePath.cxx +++ b/panda/src/pgraph/workingNodePath.cxx @@ -71,7 +71,7 @@ get_node(int index) const { * */ void WorkingNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { // Cheesy and slow, but when you're outputting the thing, presumably you're // not in a hurry. get_node_path().output(out); diff --git a/panda/src/pgraphnodes/ambientLight.cxx b/panda/src/pgraphnodes/ambientLight.cxx index d3aae3fb54..deb6eed6cc 100644 --- a/panda/src/pgraphnodes/ambientLight.cxx +++ b/panda/src/pgraphnodes/ambientLight.cxx @@ -23,7 +23,7 @@ TypeHandle AmbientLight::_type_handle; * */ AmbientLight:: -AmbientLight(const string &name) : +AmbientLight(const std::string &name) : LightNode(name) { } @@ -63,7 +63,7 @@ make_copy() const { * */ void AmbientLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/callbackNode.cxx b/panda/src/pgraphnodes/callbackNode.cxx index 12018de8da..bf0a233f3c 100644 --- a/panda/src/pgraphnodes/callbackNode.cxx +++ b/panda/src/pgraphnodes/callbackNode.cxx @@ -26,7 +26,7 @@ TypeHandle CallbackNode::_type_handle; * */ CallbackNode:: -CallbackNode(const string &name) : +CallbackNode(const std::string &name) : PandaNode(name) { PandaNode::set_cull_callback(); @@ -145,7 +145,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { * classes to include some information relevant to the class. */ void CallbackNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraphnodes/computeNode.cxx b/panda/src/pgraphnodes/computeNode.cxx index 0a55d988ef..560e1a8365 100644 --- a/panda/src/pgraphnodes/computeNode.cxx +++ b/panda/src/pgraphnodes/computeNode.cxx @@ -27,7 +27,7 @@ TypeHandle ComputeNode::_type_handle; * assign a shader using a ShaderAttrib. */ ComputeNode:: -ComputeNode(const string &name) : +ComputeNode(const std::string &name) : PandaNode(name), _dispatcher(new ComputeNode::Dispatcher) { @@ -105,7 +105,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { * classes to include some information relevant to the class. */ void ComputeNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraphnodes/directionalLight.cxx b/panda/src/pgraphnodes/directionalLight.cxx index 9d198fac6f..062d2d364d 100644 --- a/panda/src/pgraphnodes/directionalLight.cxx +++ b/panda/src/pgraphnodes/directionalLight.cxx @@ -55,7 +55,7 @@ fillin(DatagramIterator &scan, BamReader *) { * */ DirectionalLight:: -DirectionalLight(const string &name) : +DirectionalLight(const std::string &name) : LightLensNode(name, new OrthographicLens()) { _lenses[0]._lens->set_interocular_distance(0); } @@ -98,7 +98,7 @@ xform(const LMatrix4 &mat) { * */ void DirectionalLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index 92141d7f2d..f523d01795 100644 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -28,7 +28,7 @@ TypeHandle FadeLODNode::_type_handle; * */ FadeLODNode:: -FadeLODNode(const string &name) : +FadeLODNode(const std::string &name) : LODNode(name) { set_cull_callback(); @@ -241,7 +241,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { * */ void FadeLODNode:: -output(ostream &out) const { +output(std::ostream &out) const { LODNode::output(out); out << " fade time: " << _fade_time; } @@ -251,7 +251,7 @@ output(ostream &out) const { * of the geometry during a transition. */ void FadeLODNode:: -set_fade_bin(const string &name, int draw_order) { +set_fade_bin(const std::string &name, int draw_order) { _fade_bin_name = name; _fade_bin_draw_order = draw_order; _fade_1_new_state.clear(); diff --git a/panda/src/pgraphnodes/fadeLodNodeData.cxx b/panda/src/pgraphnodes/fadeLodNodeData.cxx index d0f0d09987..5e15112fd3 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.cxx +++ b/panda/src/pgraphnodes/fadeLodNodeData.cxx @@ -20,7 +20,7 @@ TypeHandle FadeLODNodeData::_type_handle; * */ void FadeLODNodeData:: -output(ostream &out) const { +output(std::ostream &out) const { AuxSceneData::output(out); if (_fade_mode != FM_solid) { out << " fading " << _fade_out << " to " << _fade_in << " since " diff --git a/panda/src/pgraphnodes/lightLensNode.cxx b/panda/src/pgraphnodes/lightLensNode.cxx index b79b5e8dc0..87f9a5bca8 100644 --- a/panda/src/pgraphnodes/lightLensNode.cxx +++ b/panda/src/pgraphnodes/lightLensNode.cxx @@ -26,7 +26,7 @@ TypeHandle LightLensNode::_type_handle; * */ LightLensNode:: -LightLensNode(const string &name, Lens *lens) : +LightLensNode(const std::string &name, Lens *lens) : Camera(name, lens), _has_specular_color(false), _attrib_count(0) @@ -158,7 +158,7 @@ as_light() { * */ void LightLensNode:: -output(ostream &out) const { +output(std::ostream &out) const { LensNode::output(out); } @@ -166,7 +166,7 @@ output(ostream &out) const { * */ void LightLensNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LensNode::write(out, indent_level); } diff --git a/panda/src/pgraphnodes/lightNode.cxx b/panda/src/pgraphnodes/lightNode.cxx index 13eae68d6d..cffcb05a2f 100644 --- a/panda/src/pgraphnodes/lightNode.cxx +++ b/panda/src/pgraphnodes/lightNode.cxx @@ -23,7 +23,7 @@ TypeHandle LightNode::_type_handle; * */ LightNode:: -LightNode(const string &name) : +LightNode(const std::string &name) : PandaNode(name) { } @@ -59,7 +59,7 @@ as_light() { * */ void LightNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } @@ -67,7 +67,7 @@ output(ostream &out) const { * */ void LightNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); } diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index e39f0d0c97..060adac699 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -45,7 +45,7 @@ TypeHandle LODNode::_type_handle; * variable. */ PT(LODNode) LODNode:: -make_default_lod(const string &name) { +make_default_lod(const std::string &name) { switch (default_lod_type.get_value()) { case LNT_pop: return new LODNode(name); @@ -146,7 +146,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { LPoint3 center = cdata->_center * rel_transform->get_mat(); PN_stdfloat dist2 = center.dot(center); - int num_children = min(get_num_children(), (int)cdata->_switch_vector.size()); + int num_children = std::min(get_num_children(), (int)cdata->_switch_vector.size()); for (int index = 0; index < num_children; ++index) { const Switch &sw = cdata->_switch_vector[index]; bool in_range; @@ -176,7 +176,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { * */ void LODNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); CDReader cdata(_cycler); out << " center(" << cdata->_center << ") "; @@ -593,7 +593,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, // should definitely fit entirely within a bounding sphere that contains // all the points of the child. LPoint3 box_center = (min_point + max_point) / 2.0f; - PN_stdfloat box_radius = min(min(max_point[0] - box_center[0], + PN_stdfloat box_radius = std::min(std::min(max_point[0] - box_center[0], max_point[1] - box_center[1]), max_point[2] - box_center[2]); @@ -642,7 +642,7 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { PN_stdfloat suggested_radius; if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; - ostringstream strm; + std::ostringstream strm; strm << "Level " << index << " geometry of " << data.get_node_path() << " is larger than its switch radius; suggest radius of " diff --git a/panda/src/pgraphnodes/lodNodeType.cxx b/panda/src/pgraphnodes/lodNodeType.cxx index 2798cdd0f4..5c37066cf5 100644 --- a/panda/src/pgraphnodes/lodNodeType.cxx +++ b/panda/src/pgraphnodes/lodNodeType.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_pgraph.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, LODNodeType lnt) { switch (lnt) { diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index e4ee2acdb1..5a9dbc9e0a 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -24,7 +24,7 @@ TypeHandle NodeCullCallbackData::_type_handle; * */ void NodeCullCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")"; } diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 02cc33fda9..8a132515aa 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -61,7 +61,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ PointLight:: -PointLight(const string &name) : +PointLight(const std::string &name) : LightLensNode(name) { PT(Lens) lens; lens = new PerspectiveLens(90, 90); @@ -127,7 +127,7 @@ xform(const LMatrix4 &mat) { * */ void PointLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/rectangleLight.cxx b/panda/src/pgraphnodes/rectangleLight.cxx index 187d35cd2d..1af641788c 100644 --- a/panda/src/pgraphnodes/rectangleLight.cxx +++ b/panda/src/pgraphnodes/rectangleLight.cxx @@ -50,7 +50,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ RectangleLight:: -RectangleLight(const string &name) : +RectangleLight(const std::string &name) : LightLensNode(name) { } @@ -80,7 +80,7 @@ make_copy() const { * */ void RectangleLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LightLensNode::write(out, indent_level); indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index 7e374721f6..915845af86 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -111,7 +111,7 @@ add_node(PandaNode *node) { * Describes all the data collected. */ void SceneGraphAnalyzer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _num_nodes << " total nodes (including " << _num_instances << " instances); " << _num_lod_nodes << " LODNodes.\n"; @@ -366,7 +366,7 @@ collect_statistics(GeomNode *geom_node) { void SceneGraphAnalyzer:: collect_statistics(const Geom *geom) { CPT(GeomVertexData) vdata = geom->get_vertex_data(); - pair result = _vdatas.insert(VDatas::value_type(vdata, VDataTracker())); + std::pair result = _vdatas.insert(VDatas::value_type(vdata, VDataTracker())); if (result.second) { // This is the first time we've encountered this vertex data. ++_num_geom_vertex_datas; diff --git a/panda/src/pgraphnodes/sequenceNode.cxx b/panda/src/pgraphnodes/sequenceNode.cxx index b8f3ffb8e0..06f0019e6d 100644 --- a/panda/src/pgraphnodes/sequenceNode.cxx +++ b/panda/src/pgraphnodes/sequenceNode.cxx @@ -134,7 +134,7 @@ get_visible_child() const { * */ void SequenceNode:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << ": "; AnimInterface::output(out); } diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index bdca5406ce..f52d0f4579 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -47,6 +47,8 @@ #include "config_pgraphnodes.h" #include "pStatTimer.h" +using std::string; + TypeHandle ShaderGenerator::_type_handle; #ifdef HAVE_CG @@ -75,7 +77,7 @@ ShaderGenerator(const GraphicsStateGuardianBase *gsg) { #ifdef _WIN32 _use_generic_attr = !gsg->get_supports_hlsl(); #else - _use_generic_attr = false; + _use_generic_attr = true; #endif // Do we want to use the ARB_shadow extension? This also allows us to use @@ -250,8 +252,12 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { // Store the material flags (not the material values itself). const MaterialAttrib *material; rs->get_attrib_def(material); - if (material->get_material() != nullptr) { - key._material_flags = material->get_material()->get_flags(); + Material *mat = material->get_material(); + if (mat != nullptr) { + // The next time the Material flags change, the Material should cause the + // states to be rehashed. + mat->mark_used_by_auto_shader(); + key._material_flags = mat->get_flags(); } // Break out the lights by type. @@ -259,7 +265,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { rs->get_attrib_def(la); bool have_ambient = false; - for (int i = 0; i < la->get_num_on_lights(); ++i) { + for (size_t i = 0; i < la->get_num_on_lights(); ++i) { NodePath np = la->get_on_light(i); nassertv(!np.is_empty()); PandaNode *node = np.node(); @@ -703,7 +709,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { // Generate the shader's text. - ostringstream text; + std::ostringstream text; text << "//Cg\n"; @@ -729,6 +735,19 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } } + bool need_color = false; + if (key._color_type != ColorAttrib::T_off) { + if (key._lighting) { + if (((key._material_flags & Material::F_ambient) == 0 && key._have_separate_ambient) || + (key._material_flags & Material::F_diffuse) == 0 || + key._calc_primary_alpha) { + need_color = true; + } + } else { + need_color = true; + } + } + text << "void vshader(\n"; for (size_t i = 0; i < key._textures.size(); ++i) { const ShaderKey::TextureInfo &tex = key._textures[i]; @@ -792,7 +811,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t out float4 l_tangent : " << tangent_freg << ",\n"; text << "\t out float4 l_binormal : " << binormal_freg << ",\n"; } - if (key._color_type == ColorAttrib::T_vertex) { + if (need_color && key._color_type == ColorAttrib::T_vertex) { text << "\t in float4 vtx_color : " << color_vreg << ",\n"; text << "\t out float4 l_color : COLOR0,\n"; } @@ -913,7 +932,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { string tcname = it->first->join("_"); text << "\t l_" << tcname << " = vtx_" << tcname << ";\n"; } - if (key._color_type == ColorAttrib::T_vertex) { + if (need_color && key._color_type == ColorAttrib::T_vertex) { text << "\t l_color = vtx_color;\n"; } if (key._texture_flags & ShaderKey::TF_map_normal) { @@ -1013,10 +1032,12 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } text << "\t out float4 o_color : COLOR0,\n"; - if (key._color_type == ColorAttrib::T_vertex) { - text << "\t in float4 l_color : COLOR0,\n"; - } else if (key._color_type == ColorAttrib::T_flat) { - text << "\t uniform float4 attr_color,\n"; + if (need_color) { + if (key._color_type == ColorAttrib::T_vertex) { + text << "\t in float4 l_color : COLOR0,\n"; + } else if (key._color_type == ColorAttrib::T_flat) { + text << "\t uniform float4 attr_color,\n"; + } } for (int i = 0; i < key._num_clip_planes; ++i) { @@ -1622,7 +1643,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { */ string ShaderGenerator:: combine_mode_as_string(const ShaderKey::TextureInfo &info, TextureStage::CombineMode c_mode, bool alpha, short texindex) { - ostringstream text; + std::ostringstream text; switch (c_mode) { case TextureStage::CM_modulate: text << combine_source_as_string(info, 0, alpha, texindex); @@ -1688,7 +1709,7 @@ combine_source_as_string(const ShaderKey::TextureInfo &info, short num, bool alp c_src = UNPACK_COMBINE_SRC(info._combine_alpha, num); c_op = UNPACK_COMBINE_OP(info._combine_alpha, num); } - ostringstream csource; + std::ostringstream csource; if (c_op == TextureStage::CO_one_minus_src_color || c_op == TextureStage::CO_one_minus_src_alpha) { csource << "saturate(1.0f - "; diff --git a/panda/src/pgraphnodes/sphereLight.cxx b/panda/src/pgraphnodes/sphereLight.cxx index c4cf01be5a..6cd70c2fbb 100644 --- a/panda/src/pgraphnodes/sphereLight.cxx +++ b/panda/src/pgraphnodes/sphereLight.cxx @@ -50,7 +50,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ SphereLight:: -SphereLight(const string &name) : +SphereLight(const std::string &name) : PointLight(name) { } @@ -92,7 +92,7 @@ xform(const LMatrix4 &mat) { * */ void SphereLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PointLight::write(out, indent_level); indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index 5935485ceb..a7d334e721 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -64,7 +64,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ Spotlight:: -Spotlight(const string &name) : +Spotlight(const std::string &name) : LightLensNode(name) { _lenses[0]._lens->set_interocular_distance(0); } @@ -104,7 +104,7 @@ xform(const LMatrix4 &mat) { * */ void Spotlight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index 14821b017e..d1eba186c0 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -26,7 +26,7 @@ TypeHandle PGButton::_type_handle; * */ PGButton:: -PGButton(const string &name) : PGItem(name) +PGButton(const std::string &name) : PGItem(name) { _button_down = false; _click_buttons.insert(MouseButton::one()); @@ -134,7 +134,7 @@ void PGButton:: click(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); - string event = get_click_event(param.get_button()); + std::string event = get_click_event(param.get_button()); play_sound(event); throw_event(event, EventParameter(ep)); @@ -150,7 +150,7 @@ click(const MouseWatcherParameter ¶m) { * to the size of the text. */ void PGButton:: -setup(const string &label, PN_stdfloat bevel) { +setup(const std::string &label, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); clear_state_def(S_ready); clear_state_def(S_depressed); diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index bc8fb204c7..b6a86754d7 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -27,6 +27,11 @@ #include +using std::max; +using std::min; +using std::string; +using std::wstring; + TypeHandle PGEntry::_type_handle; /** diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index 0f0458265c..a8f53478cb 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -25,13 +25,16 @@ #include "geomTristrips.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + // Specifies the UV range of textures applied to the frame. Maybe we'll have // a reason to make this a parameter of the frame style one day, but for now // it's hardcoded to fit the entire texture over the rectangular frame. static const LVecBase4 uv_range = LVecBase4(0.0f, 1.0f, 0.0f, 1.0f); -ostream & -operator << (ostream &out, PGFrameStyle::Type type) { +std::ostream & +operator << (std::ostream &out, PGFrameStyle::Type type) { switch (type) { case PGFrameStyle::T_none: return out << "none"; @@ -92,7 +95,7 @@ get_internal_frame(const LVecBase4 &frame) const { * */ void PGFrameStyle:: -output(ostream &out) const { +output(std::ostream &out) const { out << _type << " color = " << _color << " width = " << _width; if (_visible_scale != LVecBase2(1.0f, 1.0f)) { out << "visible_scale = " << get_visible_scale(); @@ -254,7 +257,7 @@ generate_flat_geom(const LVecBase4 &frame) { geom->add_primitive(strip); gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -428,7 +431,7 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { } gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -660,7 +663,7 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { } gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -800,5 +803,5 @@ generate_texture_border_geom(const LVecBase4 &frame) { geom->add_primitive(strip); gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index f60e4a256c..cfbf10f6b0 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -202,6 +202,19 @@ get_suppress_flags() const { return _region->get_suppress_flags(); } +/** + * Returns the Node that is the root of the subgraph that will be drawn when + * the PGItem is in the indicated state. The first time this is called for a + * particular state index, it may create the Node. + */ +INLINE NodePath &PGItem:: +get_state_def(int state) { + nassertr(state >= 0 && state < 1000, get_state_def(0)); // Sanity check. + + LightReMutexHolder holder(_lock); + return do_get_state_def(state); +} + /** * Returns the unique ID assigned to this PGItem. This will be assigned to * the region created with the MouseWatcher, and will thus be used to generate diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index da3dfe86ba..a266547ced 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -35,6 +35,8 @@ #include "audioSound.h" #endif +using std::string; + TypeHandle PGItem::_type_handle; PT(TextNode) PGItem::_text_node; PGItem *PGItem::_focus_item = nullptr; @@ -55,16 +57,15 @@ is_right(const LVector2 &v1, const LVector2 &v2) { PGItem:: PGItem(const string &name) : PandaNode(name), - _lock(name) + _lock(name), + _notify(nullptr), + _has_frame(false), + _frame(0, 0, 0, 0), + _region(new PGMouseWatcherRegion(this)), + _state(0), + _flags(0) { set_cull_callback(); - - _notify = nullptr; - _has_frame = false; - _frame.set(0, 0, 0, 0); - _region = new PGMouseWatcherRegion(this); - _state = 0; - _flags = 0; } /** @@ -92,17 +93,16 @@ PGItem:: PGItem:: PGItem(const PGItem ©) : PandaNode(copy), + _notify(nullptr), _has_frame(copy._has_frame), _frame(copy._frame), _state(copy._state), - _flags(copy._flags) + _flags(copy._flags), + _region(new PGMouseWatcherRegion(this)) #ifdef HAVE_AUDIO , _sounds(copy._sounds) #endif { - _notify = nullptr; - _region = new PGMouseWatcherRegion(this); - // We give our region the same name as the region for the PGItem we're // copying--so that this PGItem will generate the same event names when the // user interacts with it. @@ -186,9 +186,29 @@ draw_mask_changed() { */ bool PGItem:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - LightReMutexHolder holder(_lock); - bool this_node_hidden = data.is_this_node_hidden(trav->get_camera_mask()); - if (!this_node_hidden && has_frame() && get_active()) { + // We try not to hold the lock for longer than necessary. + PT(PandaNode) state_def_root; + bool has_frame; + PGMouseWatcherRegion *region; + { + LightReMutexHolder holder(_lock); + has_frame = _has_frame && ((_flags & F_active) != 0); + region = _region; + + int state = _state; + if (state >= 0 && (size_t)state < _state_defs.size()) { + StateDef &state_def = _state_defs[state]; + if (!state_def._root.is_empty()) { + if (state_def._frame_stale) { + update_frame(state); + } + + state_def_root = state_def._root.node(); + } + } + } + + if (has_frame && !data.is_this_node_hidden(trav->get_camera_mask())) { // The item has a frame, so we want to generate a region for it and update // the MouseWatcher. @@ -198,8 +218,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PGCullTraverser *pg_trav; DCAST_INTO_R(pg_trav, trav, true); - CPT(TransformState) net_transform = data.get_net_transform(trav); - const LMatrix4 &transform = net_transform->get_mat(); + const LMatrix4 &transform = data.get_net_transform(trav)->get_mat(); // Consider the cull bin this object is in. Since the binning affects // the render order, we want bins that render later to get higher sort @@ -236,19 +255,20 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // the existing interface which only provides one. sort = (bin_sort << 16) | ((sort + 0x8000) & 0xffff); - if (activate_region(transform, sort, - DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())), - DCAST(ScissorAttrib, data._state->get_attrib(ScissorAttrib::get_class_slot())))) { - pg_trav->_top->add_region(get_region()); + const ClipPlaneAttrib *clip = nullptr; + const ScissorAttrib *scissor = nullptr; + data._state->get_attrib(clip); + data._state->get_attrib(scissor); + if (activate_region(transform, sort, clip, scissor)) { + pg_trav->_top->add_region(region); } } } - if (has_state_def(get_state())) { + if (state_def_root != nullptr) { // This item has a current state definition that we should use to render // the item. - NodePath &root = get_state_def(get_state()); - CullTraverserData next_data(data, root.node()); + CullTraverserData next_data(data, state_def_root); trav->traverse(next_data); } @@ -302,7 +322,7 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // get_state_def() on each one, to ensure that the frames are updated // correctly before we measure their bounding volumes. for (int i = 0; i < (int)_state_defs.size(); i++) { - NodePath &root = ((PGItem *)this)->get_state_def(i); + NodePath &root = ((PGItem *)this)->do_get_state_def(i); if (!root.is_empty()) { PandaNode *node = root.node(); child_volumes.push_back(node->get_bounds(current_thread)); @@ -384,6 +404,9 @@ bool PGItem:: activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa) { + using std::min; + using std::max; + LightReMutexHolder holder(_lock); // Transform all four vertices, and get the new bounding box. This way the // region works (mostly) even if has been rotated. @@ -931,30 +954,6 @@ clear_state_def(int state) { mark_internal_bounds_stale(); } -/** - * Returns the Node that is the root of the subgraph that will be drawn when - * the PGItem is in the indicated state. The first time this is called for a - * particular state index, it may create the Node. - */ -NodePath &PGItem:: -get_state_def(int state) { - LightReMutexHolder holder(_lock); - nassertr(state >= 0 && state < 1000, get_state_def(0)); // Sanity check. - slot_state_def(state); - - if (_state_defs[state]._root.is_empty()) { - // Create a new node. - _state_defs[state]._root = NodePath("state_" + format_string(state)); - _state_defs[state]._frame_stale = true; - } - - if (_state_defs[state]._frame_stale) { - update_frame(state); - } - - return _state_defs[state]._root; -} - /** * Parents an instance of the bottom node of the indicated NodePath to the * indicated state index. @@ -969,7 +968,7 @@ instance_to_state_def(int state, const NodePath &path) { mark_internal_bounds_stale(); - return path.instance_to(get_state_def(state)); + return path.instance_to(do_get_state_def(state)); } /** @@ -994,7 +993,7 @@ set_frame_style(int state, const PGFrameStyle &style) { LightReMutexHolder holder(_lock); // Get the state def node, mainly to ensure that this state is slotted and // listed as having been defined. - NodePath &root = get_state_def(state); + NodePath &root = do_get_state_def(state); nassertv(!root.is_empty()); _state_defs[state]._frame_style = style; @@ -1093,6 +1092,9 @@ play_sound(const string &event) { */ void PGItem:: reduce_region(LVecBase4 &frame, PGItem *obscurer) const { + using std::min; + using std::max; + if (obscurer != nullptr && !obscurer->is_overall_hidden()) { LVecBase4 oframe = get_relative_frame(obscurer); @@ -1120,6 +1122,9 @@ reduce_region(LVecBase4 &frame, PGItem *obscurer) const { */ LVecBase4 PGItem:: get_relative_frame(PGItem *item) const { + using std::min; + using std::max; + NodePath this_np = NodePath::any_path((PGItem *)this); NodePath item_np = this_np.find_path_to(item); if (item_np.is_empty()) { @@ -1170,6 +1175,30 @@ frame_changed() { } } +/** + * Returns the Node that is the root of the subgraph that will be drawn when + * the PGItem is in the indicated state. The first time this is called for a + * particular state index, it may create the Node. + * + * Assumes the lock is already held. + */ +NodePath &PGItem:: +do_get_state_def(int state) { + slot_state_def(state); + + if (_state_defs[state]._root.is_empty()) { + // Create a new node. + _state_defs[state]._root = NodePath("state_" + format_string(state)); + _state_defs[state]._frame_stale = true; + } + + if (_state_defs[state]._frame_stale) { + update_frame(state); + } + + return _state_defs[state]._root; +} + /** * Ensures there is a slot in the array for the given state definition. */ @@ -1196,7 +1225,7 @@ update_frame(int state) { // Now create new frame geometry. if (has_frame()) { - NodePath &root = get_state_def(state); + NodePath &root = do_get_state_def(state); _state_defs[state]._frame = _state_defs[state]._frame_style.generate_into(root, _frame); } diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index fc7f8ff6d4..2c26f91602 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -77,11 +77,12 @@ protected: GeomTransformer &transformer, Thread *current_thread); -public: virtual void xform(const LMatrix4 &mat); bool activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa); + +public: INLINE PGMouseWatcherRegion *get_region() const; virtual void enter_region(const MouseWatcherParameter ¶m); @@ -130,7 +131,7 @@ PUBLISHED: int get_num_state_defs() const; void clear_state_def(int state); bool has_state_def(int state) const; - NodePath &get_state_def(int state); + INLINE NodePath &get_state_def(int state); MAKE_SEQ(get_state_defs, get_num_state_defs, get_state_def); NodePath instance_to_state_def(int state, const NodePath &path); @@ -187,6 +188,7 @@ protected: virtual void frame_changed(); private: + NodePath &do_get_state_def(int state); void slot_state_def(int state); void update_frame(int state); void mark_frames_stale(); @@ -215,7 +217,7 @@ private: }; int _flags; - PT(PGMouseWatcherRegion) _region; + PT(PGMouseWatcherRegion) const _region; LMatrix4 _frame_inv_xform; diff --git a/panda/src/pgui/pgMouseWatcherParameter.cxx b/panda/src/pgui/pgMouseWatcherParameter.cxx index 52844f5e23..732d5f01a4 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.cxx +++ b/panda/src/pgui/pgMouseWatcherParameter.cxx @@ -26,6 +26,6 @@ PGMouseWatcherParameter:: * */ void PGMouseWatcherParameter:: -output(ostream &out) const { +output(std::ostream &out) const { MouseWatcherParameter::output(out); } diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index c35ea7b395..a41916d3c9 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -19,7 +19,7 @@ TypeHandle PGScrollFrame::_type_handle; * */ PGScrollFrame:: -PGScrollFrame(const string &name) : PGVirtualFrame(name) +PGScrollFrame(const std::string &name) : PGVirtualFrame(name) { set_cull_callback(); diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index ae7720140a..e085f0f91d 100644 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -20,13 +20,16 @@ #include "transformState.h" #include "mouseButton.h" +using std::max; +using std::min; + TypeHandle PGSliderBar::_type_handle; /** * */ PGSliderBar:: -PGSliderBar(const string &name) +PGSliderBar(const std::string &name) : PGItem(name) { set_cull_callback(); @@ -224,7 +227,7 @@ xform(const LMatrix4 &mat) { void PGSliderBar:: adjust() { LightReMutexHolder holder(_lock); - string event = get_adjust_event(); + std::string event = get_adjust_event(); play_sound(event); throw_event(event); diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index 172f62123c..3c0948ebda 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -24,7 +24,7 @@ TypeHandle PGTop::_type_handle; * */ PGTop:: -PGTop(const string &name) : +PGTop(const std::string &name) : PandaNode(name) { set_cull_callback(); diff --git a/panda/src/pgui/pgVirtualFrame.cxx b/panda/src/pgui/pgVirtualFrame.cxx index b6a6d195b0..01013fd87f 100644 --- a/panda/src/pgui/pgVirtualFrame.cxx +++ b/panda/src/pgui/pgVirtualFrame.cxx @@ -21,7 +21,7 @@ TypeHandle PGVirtualFrame::_type_handle; * */ PGVirtualFrame:: -PGVirtualFrame(const string &name) : PGItem(name) +PGVirtualFrame(const std::string &name) : PGItem(name) { _has_clip_frame = false; _clip_frame.set(0.0f, 0.0f, 0.0f, 0.0f); diff --git a/panda/src/pgui/pgWaitBar.cxx b/panda/src/pgui/pgWaitBar.cxx index 2f6f50a557..8348b692dc 100644 --- a/panda/src/pgui/pgWaitBar.cxx +++ b/panda/src/pgui/pgWaitBar.cxx @@ -22,7 +22,7 @@ TypeHandle PGWaitBar::_type_handle; * */ PGWaitBar:: -PGWaitBar(const string &name) : PGItem(name) +PGWaitBar(const std::string &name) : PGItem(name) { set_cull_callback(); @@ -147,7 +147,7 @@ update() { // And scale the bar according to our value. PN_stdfloat frac = _value / _range; - frac = max(min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); + frac = std::max(std::min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); bar_frame[1] = bar_frame[0] + frac * (bar_frame[1] - bar_frame[0]); _bar = _bar_style.generate_into(root, bar_frame, 1); diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index b216036009..ac9a03a69d 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -23,7 +23,7 @@ TypeHandle ActorNode::_type_handle; * Constructor */ ActorNode:: -ActorNode(const string &name) : +ActorNode(const std::string &name) : PhysicalNode(name) { _contact_vector = LVector3::zero(); add_physical(new Physical(1, true)); @@ -120,7 +120,7 @@ transform_changed() { * Write a string representation of this instance to . */ void ActorNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ActorNode:\n"; out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 1ca581eaf6..642c2c6b8b 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -142,7 +142,7 @@ child_integrate(Physical *physical, * Write a string representation of this instance to . */ void AngularEulerIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularEulerIntegrator (id "<. */ void AngularEulerIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; AngularIntegrator::write(out, indent+2); diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 06c71289ae..3be7eafff5 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -59,7 +59,7 @@ is_linear() const { * Write a string representation of this instance to . */ void AngularForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularForce (id "<. */ void AngularForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularForce (id "<. */ void AngularIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularIntegrator"; #endif //] NDEBUG @@ -59,7 +59,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_angular_dt "<<_max_angular_dt<<" (class const)\n"; diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index 736deec04f..f917eaaba7 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -68,7 +68,7 @@ get_child_quat(const PhysicsObject *) { * Write a string representation of this instance to . */ void AngularVectorForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularVectorForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularVectorForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index c06ba12180..18bc3ef5e1 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -48,7 +48,7 @@ BaseForce:: * Write a string representation of this instance to . */ void BaseForce:: -output(ostream &out) const { +output(std::ostream &out) const { out << "BaseForce (id " << this << ")"; } @@ -56,7 +56,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseForce:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BaseForce (id " << this << "):\n"; diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index ca5ec4faad..33bc0b72cb 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -16,6 +16,8 @@ #include "forceNode.h" #include "nodePath.h" +using std::ostream; + /** * constructor */ diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index 326962b7c1..c8f744f777 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -20,7 +20,7 @@ TypeHandle ForceNode::_type_handle; * default constructor */ ForceNode:: -ForceNode(const string &name) : +ForceNode(const std::string &name) : PandaNode(name) { } @@ -124,7 +124,7 @@ remove_force(size_t index) { * Write a string representation of this instance to . */ void ForceNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out<<" ("<<_forces.size()<<" forces)"; } @@ -133,7 +133,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ForceNode:: -write_forces(ostream &out, int indent) const { +write_forces(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_forces ("<<_forces.size()<<" forces)"<<"\n"; for (ForceVector::const_iterator i=_forces.begin(); @@ -149,7 +149,7 @@ write_forces(ostream &out, int indent) const { * Write a string representation of this instance to . */ void ForceNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ForceNode (id "<. */ void LinearControlForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearControlForce"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearControlForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearControlForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index ab91296af0..c1abcc6c4d 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -117,7 +117,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearCylinderVortexForce"; #endif //] NDEBUG @@ -127,7 +127,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index b48907feeb..3a7349f094 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -47,7 +47,7 @@ LinearDistanceForce:: * Write a string representation of this instance to . */ void LinearDistanceForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearDistanceForce"; #endif //] NDEBUG @@ -57,7 +57,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearDistanceForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; out.width(indent+2); out<<""; out<<"_force_center "<<_force_center<<"\n"; diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 5095937a48..f9801e3405 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -189,7 +189,7 @@ child_integrate(Physical *physical, * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearEulerIntegrator"; #endif //] NDEBUG @@ -199,7 +199,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearEulerIntegrator:\n"; diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index e7481a2703..cef7f1e543 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -82,7 +82,7 @@ is_linear() const { * Write a string representation of this instance to . */ void LinearForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearForce (id "<. */ void LinearForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearForce (id "<. */ void LinearFrictionForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearFrictionForce"; #endif //] NDEBUG @@ -83,7 +83,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearFrictionForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; out.width(indent+2); out<<""; out<<"_coef "<<_coef<<":\n"; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index 9efd0a3c1b..d8841cee9c 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -68,7 +68,7 @@ integrate(Physical *physical, LinearForceVector &forces, * Write a string representation of this instance to . */ void LinearIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearIntegrator"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n"; diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index 80809a0f28..397092a807 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -58,7 +58,7 @@ get_child_vector(const PhysicsObject *) { * Write a string representation of this instance to . */ void LinearJitterForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearJitterForce"; #endif //] NDEBUG @@ -68,7 +68,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearJitterForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearJitterForce:\n"; LinearRandomForce::write(out, indent+2); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index b86754b8fe..9873494480 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -136,7 +136,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearNoiseForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"LinearNoiseForce"; #endif //] NDEBUG @@ -146,7 +146,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearNoiseForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearNoiseForce:"; diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index f961fdba4e..f234b174bd 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -50,7 +50,7 @@ bounded_rand() { * Write a string representation of this instance to . */ void LinearRandomForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearRandomForce"; #endif //] NDEBUG @@ -60,7 +60,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearRandomForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearRandomForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index 066fc64bef..ab1268cd5c 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -68,7 +68,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearSinkForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearSinkForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSinkForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSinkForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 87e8d4e6ef..4bb674dbad 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -68,7 +68,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearSourceForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearSourceForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSourceForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSourceForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index 8e009aa6d9..2bab34805a 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -62,7 +62,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearUserDefinedForce"; #endif //] NDEBUG @@ -72,7 +72,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index ed2012dccf..3247bb5ad5 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -74,7 +74,7 @@ get_child_vector(const PhysicsObject *) { * Write a string representation of this instance to . */ void LinearVectorForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearVectorForce"; #endif //] NDEBUG @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearVectorForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index 1cad199507..afd158ec14 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -16,6 +16,8 @@ #include "physical.h" #include "physicsManager.h" +using std::ostream; + TypeHandle Physical::_type_handle; /** diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 0166b81ade..0fcabeeb8a 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -21,7 +21,7 @@ TypeHandle PhysicalNode::_type_handle; * default constructor */ PhysicalNode:: -PhysicalNode(const string &name) : +PhysicalNode(const std::string &name) : PandaNode(name) { } @@ -133,7 +133,7 @@ remove_physical(size_t index) { * Write a string representation of this instance to . */ void PhysicalNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PhysicalNode:\n"; // PandaNode::write(out, indent+2); diff --git a/panda/src/physics/physicsCollisionHandler.cxx b/panda/src/physics/physicsCollisionHandler.cxx index f3be69e927..7fe69cd997 100644 --- a/panda/src/physics/physicsCollisionHandler.cxx +++ b/panda/src/physics/physicsCollisionHandler.cxx @@ -20,6 +20,9 @@ #include "actorNode.h" #include "dcast.h" +using std::cerr; +using std::endl; + TypeHandle PhysicsCollisionHandler::_type_handle; /** diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 510d61abce..3286e73539 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -17,6 +17,8 @@ #include #include "pvector.h" +using std::ostream; + ConfigVariableInt PhysicsManager::_random_seed ("physics_manager_random_seed", 139); diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 96651949d5..9cca9f6d2f 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -112,7 +112,7 @@ add_impact(const LPoint3 &offset, a = a.cross(b); PN_stdfloat angle = a.length(); if (angle) { - LRotation torque; + LRotation torque(0, 0, 0, 0); PN_stdfloat spin = force.length()*0.1; // todo: this should account for // impact distance and mass. a.normalize(); @@ -150,7 +150,7 @@ get_inertial_tensor() const { * Write a string representation of this instance to . */ void PhysicsObject:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PhysicsObject"; #endif //] NDEBUG @@ -160,7 +160,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsObject:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsObject "<<_name<<"\n"; diff --git a/panda/src/physics/physicsObjectCollection.cxx b/panda/src/physics/physicsObjectCollection.cxx index 17ce51158d..2b810ef8be 100644 --- a/panda/src/physics/physicsObjectCollection.cxx +++ b/panda/src/physics/physicsObjectCollection.cxx @@ -221,7 +221,7 @@ size() const { * indicated output stream. */ void PhysicsObjectCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_physics_objects() == 1) { out << "1 PhysicsObject"; } else { @@ -234,7 +234,7 @@ output(ostream &out) const { * the indicated output stream. */ void PhysicsObjectCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_physics_objects(); i++) { indent(out, indent_level) << get_physics_object(i) << "\n"; } diff --git a/panda/src/physics/test_physics.cxx b/panda/src/physics/test_physics.cxx index cb2e2f0c9d..21d248575f 100644 --- a/panda/src/physics/test_physics.cxx +++ b/panda/src/physics/test_physics.cxx @@ -16,6 +16,9 @@ #include "physicsManager.h" #include "forces.h" +using std::cout; +using std::endl; + class Baseball : public Physical { public: int ttl_balls; diff --git a/panda/src/physx/physxContactPair.cxx b/panda/src/physx/physxContactPair.cxx index 3e8d69e34f..fdaf22889c 100644 --- a/panda/src/physx/physxContactPair.cxx +++ b/panda/src/physx/physxContactPair.cxx @@ -25,7 +25,7 @@ PhysxActor *PhysxContactPair:: get_actor_a() const { if (_pair.isDeletedActor[0]) { - physx_cat.warning() << "actor A has been deleted" << endl; + physx_cat.warning() << "actor A has been deleted" << std::endl; return nullptr; } @@ -40,7 +40,7 @@ PhysxActor *PhysxContactPair:: get_actor_b() const { if (_pair.isDeletedActor[1]) { - physx_cat.warning() << "actor B has been deleted" << endl; + physx_cat.warning() << "actor B has been deleted" << std::endl; return nullptr; } diff --git a/panda/src/physx/physxDebugGeomNode.cxx b/panda/src/physx/physxDebugGeomNode.cxx index a609fb2f3c..8b3bd2a1ca 100644 --- a/panda/src/physx/physxDebugGeomNode.cxx +++ b/panda/src/physx/physxDebugGeomNode.cxx @@ -31,7 +31,7 @@ update(NxScene *scenePtr) { const NxDebugRenderable *renderable = scenePtr->getDebugRenderable(); if (!renderable) { remove_all_geoms(); - physx_cat.warning() << "Could no get debug renderable." << endl; + physx_cat.warning() << "Could no get debug renderable." << std::endl; return; } diff --git a/panda/src/physx/physxEnums.cxx b/panda/src/physx/physxEnums.cxx index 172e6013b3..87a0222bc3 100644 --- a/panda/src/physx/physxEnums.cxx +++ b/panda/src/physx/physxEnums.cxx @@ -16,8 +16,8 @@ #include "string_utils.h" #include "config_putil.h" -ostream & -operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { +std::ostream & +operator << (std::ostream &out, PhysxEnums::PhysxUpAxis axis) { switch (axis) { case PhysxEnums::X_up: @@ -33,10 +33,10 @@ operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { return out << "**invalid PhysxEnums::PhysxUpAxis value: (" << (int)axis << ")**"; } -istream & -operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) { +std::istream & +operator >> (std::istream &in, PhysxEnums::PhysxUpAxis &axis) { - string word; + std::string word; in >> word; if (cmp_nocase(word, "x") == 0) { diff --git a/panda/src/physx/physxGroupsMask.cxx b/panda/src/physx/physxGroupsMask.cxx index e16497350e..6591ab2583 100644 --- a/panda/src/physx/physxGroupsMask.cxx +++ b/panda/src/physx/physxGroupsMask.cxx @@ -13,6 +13,8 @@ #include "physxGroupsMask.h" +using std::string; + /** * Returns a PhysxGroupsMask whose bits are all on. */ @@ -120,7 +122,7 @@ get_bit(unsigned int idx) const { * Writes the PhysxGroupsMask out as a list of ones and zeros. */ void PhysxGroupsMask:: -output(ostream &out) const { +output(std::ostream &out) const { string name0; string name1; diff --git a/panda/src/physx/physxLinearInterpolationValues.cxx b/panda/src/physx/physxLinearInterpolationValues.cxx index 346d30508f..45cd603c64 100644 --- a/panda/src/physx/physxLinearInterpolationValues.cxx +++ b/panda/src/physx/physxLinearInterpolationValues.cxx @@ -32,8 +32,8 @@ insert(float index, float value) { _min = _max = index; } else { - _min = min(_min, index); - _max = max(_max, index); + _min = std::min(_min, index); + _max = std::max(_max, index); } _map[index] = value; } @@ -106,11 +106,11 @@ get_value_at_index(int index) const { * */ void PhysxLinearInterpolationValues:: -output(ostream &out) const { +output(std::ostream &out) const { MapType::const_iterator it = _map.begin(); for (; it != _map.end(); ++it) { - cout << it->first << " -> " << it->second << "\n"; + std::cout << it->first << " -> " << it->second << "\n"; } } diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index 56f63149c8..1bba65c280 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -15,6 +15,8 @@ #include "physxScene.h" #include "physxSceneDesc.h" +using std::endl; + PhysxManager *PhysxManager::_global_ptr; PhysxManager::PhysxOutputStream PhysxManager::_outputStream; @@ -364,7 +366,7 @@ get_internal_version() { v = _sdk->getInternalVersion(apiRev, descRev, branchId); - stringstream version; + std::stringstream version; version << "version:" << (unsigned int)v << " apiRef:" << (unsigned int)apiRev << " descRev:" << (unsigned int)descRev diff --git a/panda/src/physx/physxMask.cxx b/panda/src/physx/physxMask.cxx index f1e31437ea..b9f3437634 100644 --- a/panda/src/physx/physxMask.cxx +++ b/panda/src/physx/physxMask.cxx @@ -70,9 +70,9 @@ get_bit(unsigned int idx) const { * Writes the PhysxMask out as a list of ones and zeros. */ void PhysxMask:: -output(ostream &out) const { +output(std::ostream &out) const { - string name; + std::string name; for (int i=0; i<32; i++) { name += (_mask & (1 << i)) ? '1' : '0'; diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 4bf65576e2..155707cccb 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -32,12 +32,12 @@ bool PhysxMeshPool:: check_filename(const Filename &fn) { if (!(VirtualFileSystem::get_global_ptr()->exists(fn))) { - physx_cat.error() << "File does not exists: " << fn << endl; + physx_cat.error() << "File does not exists: " << fn << std::endl; return false; } if (!(VirtualFileSystem::get_global_ptr()->is_regular_file(fn))) { - physx_cat.error() << "Not a regular file: " << fn << endl; + physx_cat.error() << "Not a regular file: " << fn << std::endl; return false; } @@ -272,7 +272,7 @@ list_contents() { * */ void PhysxMeshPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { out << "PhysX mesh pool contents:\n"; @@ -285,7 +285,7 @@ list_contents(ostream &out) { out << " " << fn.get_fullpath() << " (convex mesh, " << mesh->ptr()->getReferenceCount() - << " references)" << endl; + << " references)" << std::endl; } } diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index fb67e7d3c9..bbf9ce0d22 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + /** * You must pass in a Mutex to the condition variable constructor. This mutex * may be shared by other condition variables, if desired. It is the caller's diff --git a/panda/src/pipeline/conditionVarDirect.cxx b/panda/src/pipeline/conditionVarDirect.cxx index b3f18f1c0c..c9337e8d9c 100644 --- a/panda/src/pipeline/conditionVarDirect.cxx +++ b/panda/src/pipeline/conditionVarDirect.cxx @@ -20,7 +20,7 @@ * ConditionVarDirect. */ void ConditionVarDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConditionVar " << (void *)this << " on " << _mutex; } diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index 24f9d1cdc3..746991e79c 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + /** * You must pass in a Mutex to the condition variable constructor. This mutex * may be shared by other condition variables, if desired. It is the caller's diff --git a/panda/src/pipeline/conditionVarFullDirect.cxx b/panda/src/pipeline/conditionVarFullDirect.cxx index 10c30d57c9..04f9c647ed 100644 --- a/panda/src/pipeline/conditionVarFullDirect.cxx +++ b/panda/src/pipeline/conditionVarFullDirect.cxx @@ -20,7 +20,7 @@ * in ConditionVarFullDirect. */ void ConditionVarFullDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConditionVarFull " << (void *)this << " on " << _mutex; } diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 8f82307c86..60f077688f 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -12,6 +12,7 @@ */ #include "config_pipeline.h" +#include "cycleData.h" #include "mainThread.h" #include "externalThread.h" #include "genericThread.h" @@ -70,6 +71,7 @@ init_libpipeline() { } initialized = true; + CycleData::init_type(); MainThread::init_type(); ExternalThread::init_type(); GenericThread::init_type(); diff --git a/panda/src/pipeline/cycleData.cxx b/panda/src/pipeline/cycleData.cxx index 7570aabbf8..346a6e8042 100644 --- a/panda/src/pipeline/cycleData.cxx +++ b/panda/src/pipeline/cycleData.cxx @@ -13,6 +13,9 @@ #include "cycleData.h" +#ifdef DO_PIPELINING +TypeHandle CycleData::_type_handle; +#endif /** * @@ -79,6 +82,6 @@ get_parent_type() const { * This is useful mainly for debugging. */ void CycleData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_parent_type() << "::CData"; } diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index bd28d4bc60..de90bdf226 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -65,6 +65,22 @@ public: virtual TypeHandle get_parent_type() const; virtual void output(std::ostream &out) const; + +#ifdef DO_PIPELINING +public: + static TypeHandle get_class_type() { + return _type_handle; + } + + static void init_type() { + NodeReferenceCount::init_type(); + register_type(_type_handle, "CycleData", + NodeReferenceCount::get_class_type()); + } + +private: + static TypeHandle _type_handle; +#endif }; INLINE std::ostream & diff --git a/panda/src/pipeline/externalThread.cxx b/panda/src/pipeline/externalThread.cxx index 411c4f2062..d77fc194ea 100644 --- a/panda/src/pipeline/externalThread.cxx +++ b/panda/src/pipeline/externalThread.cxx @@ -31,7 +31,7 @@ ExternalThread() : Thread("External", "External") { * external thread that is bound via Thread::bind_thread(). */ ExternalThread:: -ExternalThread(const string &name, const string &sync_name) : +ExternalThread(const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _started = true; diff --git a/panda/src/pipeline/genericThread.cxx b/panda/src/pipeline/genericThread.cxx index b91819f61f..64eb0b4814 100644 --- a/panda/src/pipeline/genericThread.cxx +++ b/panda/src/pipeline/genericThread.cxx @@ -20,7 +20,7 @@ TypeHandle GenericThread::_type_handle; * */ GenericThread:: -GenericThread(const string &name, const string &sync_name) : +GenericThread(const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _function = nullptr; @@ -31,7 +31,7 @@ GenericThread(const string &name, const string &sync_name) : * */ GenericThread:: -GenericThread(const string &name, const string &sync_name, GenericThread::ThreadFunc *function, void *user_data) : +GenericThread(const std::string &name, const std::string &sync_name, GenericThread::ThreadFunc *function, void *user_data) : Thread(name, sync_name), _function(function), _user_data(user_data) diff --git a/panda/src/pipeline/lightMutexDirect.cxx b/panda/src/pipeline/lightMutexDirect.cxx index ed5d1a30ff..522d361032 100644 --- a/panda/src/pipeline/lightMutexDirect.cxx +++ b/panda/src/pipeline/lightMutexDirect.cxx @@ -20,7 +20,7 @@ * LightMutexDirect. */ void LightMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LightMutex " << (void *)this; } diff --git a/panda/src/pipeline/lightReMutexDirect.cxx b/panda/src/pipeline/lightReMutexDirect.cxx index fdfcc71cd2..9166f87867 100644 --- a/panda/src/pipeline/lightReMutexDirect.cxx +++ b/panda/src/pipeline/lightReMutexDirect.cxx @@ -21,7 +21,7 @@ * LightReMutexDirect. */ void LightReMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LightReMutex " << (void *)this; } diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index a73e1257bc..d1e0194e6f 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + int MutexDebug::_pstats_count = 0; MutexTrueImpl *MutexDebug::_global_lock; @@ -24,7 +27,7 @@ MutexTrueImpl *MutexDebug::_global_lock; * */ MutexDebug:: -MutexDebug(const string &name, bool allow_recursion, bool lightweight) : +MutexDebug(const std::string &name, bool allow_recursion, bool lightweight) : Namable(name), _allow_recursion(allow_recursion), _lightweight(lightweight), @@ -53,7 +56,7 @@ MutexDebug:: if (name_deleted_mutexes) { ostringstream strm; strm << *this; - string name = strm.str(); + std::string name = strm.str(); _deleted_name = strdup((char *)name.c_str()); } diff --git a/panda/src/pipeline/mutexDirect.cxx b/panda/src/pipeline/mutexDirect.cxx index 5f74c67c93..29c0beb9b4 100644 --- a/panda/src/pipeline/mutexDirect.cxx +++ b/panda/src/pipeline/mutexDirect.cxx @@ -20,7 +20,7 @@ * MutexDirect. */ void MutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Mutex " << (void *)this; } diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index c12e72114b..a3633226bc 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -22,7 +22,7 @@ Pipeline *Pipeline::_render_pipeline = nullptr; * */ Pipeline:: -Pipeline(const string &name, int num_stages) : +Pipeline(const std::string &name, int num_stages) : Namable(name), #ifdef THREADED_PIPELINE _num_stages(num_stages), @@ -94,7 +94,7 @@ cycle() { pvector< PT(CycleData) > saved_cdatas; { ReMutexHolder cycle_holder(_cycle_lock); - int prev_seq, next_seq; + unsigned int prev_seq, next_seq; PipelineCyclerLinks prev_dirty; { // We can't hold the lock protecting the linked lists during the cycling diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index fb31088501..714e61c0e4 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -324,7 +324,7 @@ set_num_stages(int num_stages) { * */ void PipelineCyclerTrueImpl::CyclerMutex:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CyclerMutex "; _cycler->cheat()->output(out); } diff --git a/panda/src/pipeline/psemaphore.cxx b/panda/src/pipeline/psemaphore.cxx index 1142930e3a..9a1e453819 100644 --- a/panda/src/pipeline/psemaphore.cxx +++ b/panda/src/pipeline/psemaphore.cxx @@ -17,7 +17,7 @@ * */ void Semaphore:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "Semaphore, count = " << _count; } diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index ae64aba2a4..ab41070fb8 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -24,7 +24,7 @@ TypeHandle PythonThread::_type_handle; */ PythonThread:: PythonThread(PyObject *function, PyObject *args, - const string &name, const string &sync_name) : + const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _function = function; diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index b83a2f30a6..7bfdcb8f8d 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -21,7 +21,7 @@ * ReMutexDirect. */ void ReMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ReMutex " << (void *)this; } @@ -146,7 +146,7 @@ do_unlock() { #ifdef _DEBUG if (_locking_thread != Thread::get_current_thread()) { - ostringstream ostr; + std::ostringstream ostr; ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; nassert_raise(ostr.str()); diff --git a/panda/src/pipeline/test_atomic.cxx b/panda/src/pipeline/test_atomic.cxx index ae371114e4..66ab6c5a14 100644 --- a/panda/src/pipeline/test_atomic.cxx +++ b/panda/src/pipeline/test_atomic.cxx @@ -35,7 +35,7 @@ AtomicAdjust::Integer _num_net_count_incremented = 0; class MyThread : public Thread { public: - MyThread(const string &name) : Thread(name, name) + MyThread(const std::string &name) : Thread(name, name) { } @@ -73,7 +73,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; - PT(MyThread) thread = new MyThread(string(1, name)); + PT(MyThread) thread = new MyThread(std::string(1, name)); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_concurrency.cxx b/panda/src/pipeline/test_concurrency.cxx index 9d092d08c8..6f59a025b1 100644 --- a/panda/src/pipeline/test_concurrency.cxx +++ b/panda/src/pipeline/test_concurrency.cxx @@ -50,7 +50,7 @@ volatile MemBlock memblock[number_of_threads]; class MyThread : public Thread { public: - MyThread(const string &name, int index) : + MyThread(const std::string &name, int index) : Thread(name, name), _index(index) { @@ -101,7 +101,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; Thread::sleep(delay_between_threads); - PT(MyThread) thread = new MyThread(string(1, name), i); + PT(MyThread) thread = new MyThread(std::string(1, name), i); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_delete.cxx b/panda/src/pipeline/test_delete.cxx index f49606a6f1..3ea431f77b 100644 --- a/panda/src/pipeline/test_delete.cxx +++ b/panda/src/pipeline/test_delete.cxx @@ -80,7 +80,7 @@ TypeHandle Doober::_type_handle; class MyThread : public Thread { public: - MyThread(const string &name) : Thread(name, name) + MyThread(const std::string &name) : Thread(name, name) { } @@ -106,7 +106,7 @@ public: doobers.push_back(new Doober(++counter)); } int num_del = (int)random_f(max_doobers_per_chunk); - num_del = min(num_del, (int)doobers.size()); + num_del = std::min(num_del, (int)doobers.size()); for (int j = 0; j < num_del; ++j) { assert(!doobers.empty()); @@ -137,7 +137,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; - PT(MyThread) thread = new MyThread(string(1, name)); + PT(MyThread) thread = new MyThread(std::string(1, name)); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index 27976e3ea5..a5ff82e446 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -24,6 +24,8 @@ #include "trueClock.h" #include "pstrtod.h" +using std::cerr; + #ifdef WIN32_VC // Under Windows, the rand() function seems to return a sequence per-thread, // so we use this trick to set each thread to a different seed. @@ -50,7 +52,7 @@ static double random_f(double max) class ChopstickMutex : public Mutex { public: - void output(ostream &out) const { + void output(std::ostream &out) const { out << "chopstick " << _n; } int _n; @@ -121,7 +123,7 @@ public: _id = id; } - virtual void output(ostream &out) const { + virtual void output(std::ostream &out) const { out << "philosopher " << _id; } }; diff --git a/panda/src/pipeline/test_mutex.cxx b/panda/src/pipeline/test_mutex.cxx index f02ccd1434..a0a4dd49c6 100644 --- a/panda/src/pipeline/test_mutex.cxx +++ b/panda/src/pipeline/test_mutex.cxx @@ -22,7 +22,7 @@ static const double thread_duration = 5.0; class MyThread : public Thread { public: - MyThread(const string &name, MutexImpl &m1, double period) : + MyThread(const std::string &name, MutexImpl &m1, double period) : Thread(name, name), _m1(m1), _period(period) { @@ -50,11 +50,11 @@ main(int argc, char *argv[]) { _m1.lock(); _m1.unlock(); - cerr << "Making threads.\n"; + std::cerr << "Making threads.\n"; MyThread *a = new MyThread("a", _m1, 1.0); MyThread *b = new MyThread("b", _m1, 0.9); - cerr << "Starting threads.\n"; + std::cerr << "Starting threads.\n"; a->start(TP_normal, true); b->start(TP_normal, true); diff --git a/panda/src/pipeline/test_setjmp.cxx b/panda/src/pipeline/test_setjmp.cxx index 3ce1bcf075..4803ff3fee 100644 --- a/panda/src/pipeline/test_setjmp.cxx +++ b/panda/src/pipeline/test_setjmp.cxx @@ -15,6 +15,8 @@ #include +using std::cerr; + int main(int argc, char *argv[]) { diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index 2e347823c9..b3d919a827 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -17,12 +17,14 @@ #include "mutexHolder.h" #include "pointerTo.h" +using std::cout; + Mutex *cout_mutex = nullptr; // Test forking a thread with some private data. class ThreadWithData : public Thread { public: - ThreadWithData(const string &name, int parameter); + ThreadWithData(const std::string &name, int parameter); virtual void thread_main(); @@ -32,7 +34,7 @@ private: ThreadWithData:: -ThreadWithData(const string &name, int parameter) : +ThreadWithData(const std::string &name, int parameter) : Thread(name, name), _parameter(parameter) { @@ -60,7 +62,7 @@ int main() { cout << "main beginning.\n"; for (int i = 0; i < 10; i++) { - string name = string("thread_") + (char)(i + 'a'); + std::string name = std::string("thread_") + (char)(i + 'a'); PT(Thread) thread = new ThreadWithData(name, i); if (!thread->start(TP_low, true)) { MutexHolder holder(cout_mutex); diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 3dc5994282..351e316033 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -36,7 +36,7 @@ TypeHandle Thread::_type_handle; * given the same sync_name, for the benefit of PStats. */ Thread:: -Thread(const string &name, const string &sync_name) : +Thread(const std::string &name, const std::string &sync_name) : Namable(name), _sync_name(sync_name), _impl(this) @@ -87,7 +87,7 @@ Thread:: * case the same pointer will be returned each time). */ PT(Thread) Thread:: -bind_thread(const string &name, const string &sync_name) { +bind_thread(const std::string &name, const std::string &sync_name) { Thread *current_thread = get_current_thread(); if (current_thread != get_external_thread()) { // This thread already has an associated thread. @@ -129,7 +129,7 @@ set_pipeline_stage(int pipeline_stage) { * */ void Thread:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } @@ -139,7 +139,7 @@ output(ostream &out) const { * DEBUG_THREADS mode. */ void Thread:: -output_blocker(ostream &out) const { +output_blocker(std::ostream &out) const { #ifdef DEBUG_THREADS if (_blocked_on_mutex != nullptr) { _blocked_on_mutex->output_with_holder(out); @@ -155,7 +155,7 @@ output_blocker(ostream &out) const { * */ void Thread:: -write_status(ostream &out) { +write_status(std::ostream &out) { #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) ThreadImpl::write_status(out); #endif diff --git a/panda/src/pipeline/threadDummyImpl.cxx b/panda/src/pipeline/threadDummyImpl.cxx index 419744a4b5..2d30630d98 100644 --- a/panda/src/pipeline/threadDummyImpl.cxx +++ b/panda/src/pipeline/threadDummyImpl.cxx @@ -28,10 +28,10 @@ /** * */ -string ThreadDummyImpl:: +std::string ThreadDummyImpl:: get_unique_id() const { // In a single-threaded application, this is just the unique process ID. - ostringstream strm; + std::ostringstream strm; #ifdef WIN32 strm << GetCurrentProcessId(); #else diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index dcae44e721..0d88c5ebe8 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -177,9 +177,9 @@ join() { /** * */ -string ThreadPosixImpl:: +std::string ThreadPosixImpl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; strm << getpid() << "." << _thread; return strm.str(); @@ -193,7 +193,7 @@ get_unique_id() const { bool ThreadPosixImpl:: attach_java_vm() { JNIEnv *env; - string thread_name = _parent_obj->get_name(); + std::string thread_name = _parent_obj->get_name(); JavaVMAttachArgs args; args.version = JNI_VERSION_1_2; args.name = thread_name.c_str(); diff --git a/panda/src/pipeline/threadPriority.cxx b/panda/src/pipeline/threadPriority.cxx index 0402273099..3d9c55fe21 100644 --- a/panda/src/pipeline/threadPriority.cxx +++ b/panda/src/pipeline/threadPriority.cxx @@ -15,6 +15,10 @@ #include "pnotify.h" // nassertr #include "pipeline.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, ThreadPriority pri) { switch (pri) { diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index 1bde4c7ca0..a631421503 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -178,9 +178,9 @@ preempt() { /** * */ -string ThreadSimpleImpl:: +std::string ThreadSimpleImpl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; #ifdef WIN32 strm << GetCurrentProcessId(); #else diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 8b58579642..4d9890dfd4 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -377,7 +377,7 @@ system_sleep(double seconds) { * Writes a list of threads running and threads blocked. */ void ThreadSimpleManager:: -write_status(ostream &out) const { +write_status(std::ostream &out) const { out << "Currently running: " << *_current_thread->_parent_obj << "\n"; out << "Ready:"; @@ -663,7 +663,7 @@ do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { // Clamp the elapsed time at 0. (If it's less than 0, the clock is running // backwards, ick.) - elapsed = max(elapsed, 0.0); + elapsed = std::max(elapsed, 0.0); unsigned int ticks = (unsigned int)(elapsed * _tick_scale + 0.5); thread->_run_ticks += ticks; diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 998dc44b8c..4671787918 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -125,9 +125,9 @@ join() { /** * */ -string ThreadWin32Impl:: +std::string ThreadWin32Impl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; strm << GetCurrentProcessId() << "." << _thread_id; return strm.str(); diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index 97a151f324..57b9671d1a 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -24,6 +24,11 @@ #include "string_utils.h" #include "look_at.h" +using std::istream; +using std::max; +using std::min; +using std::ostream; + /** * */ @@ -1721,35 +1726,32 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 // Now determine the minmax. PN_float32 min_x, min_y, min_z, max_x, max_y, max_z; - bool got_point = false; if (points_only) { - LPoint3f points[4] = { + const LPoint3f points[4] = { p0 * rinv, p1 * rinv, p2 * rinv, p3 * rinv, }; - for (int i = 0; i < 4; ++i) { - const LPoint3f &point = points[i]; - if (!got_point) { - min_x = point[0]; - min_y = point[1]; - min_z = point[2]; - max_x = point[0]; - max_y = point[1]; - max_z = point[2]; - got_point = true; - } else { - min_x = min(min_x, point[0]); - min_y = min(min_y, point[1]); - min_z = min(min_z, point[2]); - max_x = max(max_x, point[0]); - max_y = max(max_y, point[1]); - max_z = max(max_z, point[2]); - } - } + const LPoint3f &point = points[0]; + min_x = point[0]; + min_y = point[1]; + min_z = point[2]; + max_x = point[0]; + max_y = point[1]; + max_z = point[2]; + for (int i = 1; i < 4; ++i) { + const LPoint3f &point = points[i]; + min_x = min(min_x, point[0]); + min_y = min(min_y, point[1]); + min_z = min(min_z, point[2]); + max_x = max(max_x, point[0]); + max_y = max(max_y, point[1]); + max_z = max(max_z, point[2]); + } } else { + bool got_point = false; for (int yi = 0; yi < _y_size; ++yi) { for (int xi = 0; xi < _x_size; ++xi) { if (!has_point(xi, yi)) { @@ -1775,6 +1777,14 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 } } } + if (!got_point) { + min_x = 0.0f; + min_y = 0.0f; + min_z = 0.0f; + max_x = 0.0f; + max_y = 0.0f; + max_z = 0.0f; + } } PT(BoundingHexahedron) bounds; diff --git a/panda/src/pnmimage/pnm-image-filter.cxx b/panda/src/pnmimage/pnm-image-filter.cxx index 63398ad3c1..6ca6a145d6 100644 --- a/panda/src/pnmimage/pnm-image-filter.cxx +++ b/panda/src/pnmimage/pnm-image-filter.cxx @@ -37,6 +37,9 @@ #include "pnmImage.h" #include "pfmFile.h" +using std::max; +using std::min; + // WorkType is an abstraction that allows the filtering process to be // recompiled to use either floating-point or integer arithmetic. On SGI // machines, there doesn't seem to be much of a performance difference-- if diff --git a/panda/src/pnmimage/pnmBrush.cxx b/panda/src/pnmimage/pnmBrush.cxx index 64dffab3cb..94d1799fe7 100644 --- a/panda/src/pnmimage/pnmBrush.cxx +++ b/panda/src/pnmimage/pnmBrush.cxx @@ -16,6 +16,9 @@ #include "config_pnmimage.h" #include "cmath.h" +using std::max; +using std::min; + // A PNMTransparentBrush doesn't draw or fill anything. class EXPCL_PANDA_PNMIMAGE PNMTransparentBrush : public PNMBrush { public: diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 80fae2784a..c400db9d53 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -18,6 +18,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::string; + bool PNMFileType::_did_init_pnm = false; TypeHandle PNMFileType::_type_handle; @@ -91,7 +93,7 @@ matches_magic_number(const string &) const { * returns NULL. */ PNMReader *PNMFileType:: -make_reader(istream *, bool, const string &) { +make_reader(std::istream *, bool, const string &) { return nullptr; } @@ -101,7 +103,7 @@ make_reader(istream *, bool, const string &) { * NULL. */ PNMWriter *PNMFileType:: -make_writer(ostream *, bool) { +make_writer(std::ostream *, bool) { return nullptr; } diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index c1dd16f211..d290f52bdc 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -21,6 +21,8 @@ #include +using std::string; + PNMFileTypeRegistry *PNMFileTypeRegistry::_global_ptr; /** @@ -243,7 +245,7 @@ get_type_by_handle(TypeHandle handle) const { * one per line. */ void PNMFileTypeRegistry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_types.empty()) { indent(out, indent_level) << "(No image types are known).\n"; } else { @@ -252,7 +254,7 @@ write(ostream &out, int indent_level) const { PNMFileType *type = (*ti); string name = type->get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) << " "; + indent(out, std::max(30 - (int)name.length(), 0)) << " "; int num_extensions = type->get_num_extensions(); if (num_extensions == 1) { diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index ce9871d6f0..9c6c3a68d9 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -21,6 +21,9 @@ #include "stackedPerlinNoise2.h" #include +using std::max; +using std::min; + /** * */ @@ -295,10 +298,10 @@ read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { * Returns true if successful, false on error. */ bool PNMImage:: -read(istream &data, const string &filename, PNMFileType *type, +read(std::istream &data, const std::string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader - (&data, false, filename, string(), type, report_unknown_type); + (&data, false, filename, std::string(), type, report_unknown_type); if (reader == nullptr) { clear(); return false; @@ -402,7 +405,7 @@ write(const Filename &filename, PNMFileType *type) const { * write. */ bool PNMImage:: -write(ostream &data, const string &filename, PNMFileType *type) const { +write(std::ostream &data, const std::string &filename, PNMFileType *type) const { if (!is_valid()) { return false; } diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index b51e2d8c4d..c7a6129bd7 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -20,6 +20,10 @@ #include "virtualFileSystem.h" #include "zStream.h" +using std::istream; +using std::ostream; +using std::string; + /** * Opens up the image file and tries to read its header information to * determine its size, number of channels, etc. If successful, updates the @@ -84,7 +88,7 @@ make_reader(const Filename &filename, PNMFileType *type, if (filename == "-") { owns_file = false; - file = &cin; + file = &std::cin; if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() @@ -251,7 +255,7 @@ make_writer(const Filename &filename, PNMFileType *type) const { if (filename == "-") { owns_file = false; - file = &cout; + file = &std::cout; if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index b40bf3ce40..938648e0a1 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -249,7 +249,7 @@ get_reduction_shift(int orig_size, int new_size) { return 0; } - int reduction = max(orig_size / new_size, 1); + int reduction = std::max(orig_size / new_size, 1); int shift = 0; diff --git a/panda/src/pnmimage/pnmbitio.cxx b/panda/src/pnmimage/pnmbitio.cxx index 2dcbfbfacc..fbd9bff5d4 100644 --- a/panda/src/pnmimage/pnmbitio.cxx +++ b/panda/src/pnmimage/pnmbitio.cxx @@ -15,6 +15,10 @@ #include "pnmbitio.h" #include + +using std::istream; +using std::ostream; + struct bitstream { istream *inf; diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx index 075b45dcd2..0fb9bedfc6 100644 --- a/panda/src/pnmimage/pnmimage_base.cxx +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -19,6 +19,9 @@ #include #include // for sprintf() +using std::istream; +using std::ostream; + /** * Outputs the given printf-style message to the user and returns. diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index a332d693dc..ca1f356c48 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -40,7 +40,7 @@ typedef unsigned char gray; struct pixel { PUBLISHED: - pixel() { } + pixel() = default; pixel(gray fill) : r(fill), g(fill), b(fill) { } pixel(gray r, gray g, gray b) : r(r), g(g), b(b) { } diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 7661696980..551c351c43 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -36,6 +36,10 @@ #error Buildsystem error: BUILDING_PANDA_PNMIMAGETYPES not defined #endif +using std::istream; +using std::ostream; +using std::string; + Configure(config_pnmimagetypes); NotifyCategoryDefName(pnmimage_sgi, "sgi", pnmimage_cat); NotifyCategoryDefName(pnmimage_tga, "tga", pnmimage_cat); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx index 9ff4240ecf..688275edf7 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx @@ -20,6 +20,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char * const extensions_bmp[] = { "bmp" }; @@ -96,7 +98,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeBMP:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -107,7 +109,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeBMP:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 394445f257..7b2fc6e18c 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -19,6 +19,9 @@ #include "bmp.h" #include "pnmbitio.h" +using std::istream; +using std::string; + // Much code in this file is borrowed from Netpbm, specifically bmptoppm.c. /* * bmptoppm.c - Converts from a Microsoft Windows or OS/2 .BMP file to a diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index b624314b6b..2c592afa9d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -45,6 +45,8 @@ #define MAXCOLORS 256 +using std::ostream; + /* * Utilities */ diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx index 157bd716be..83d7cf5bb4 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx @@ -30,6 +30,10 @@ #define IMATH_NAMESPACE Imath #endif +using std::istream; +using std::ostream; +using std::string; + TypeHandle PNMFileTypeEXR::_type_handle; static const char * const extensions_exr[] = { diff --git a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx index 477f921bd2..3e20f41a87 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx @@ -25,6 +25,10 @@ // than this, it must be bogus. #define INSANE_SIZE 20000 +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_img[] = { "img" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx index 555fe29074..d7793be7fe 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx @@ -20,6 +20,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char *const extensions_jpg[] = { "jpg", "jpeg" }; @@ -97,7 +99,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeJPG:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -108,7 +110,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeJPG:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx index 4525dda22a..2789583e7f 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx @@ -49,7 +49,7 @@ extern "C" { typedef struct { struct jpeg_source_mgr pub; /* public fields */ - istream * infile; /* source stream */ + std::istream * infile; /* source stream */ JOCTET * buffer; /* start of buffer */ boolean start_of_file; /* have we gotten any data yet? */ } my_source_mgr; @@ -205,7 +205,7 @@ term_source (j_decompress_ptr cinfo) */ GLOBAL(void) -jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) +jpeg_istream_src (j_decompress_ptr cinfo, std::istream * infile) { my_src_ptr src; @@ -245,11 +245,11 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) * */ PNMFileTypeJPG::Reader:: -Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : +Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number) : PNMReader(type, file, owns_file) { // Hope we can putback() more than one character. - for (string::reverse_iterator mi = magic_number.rbegin(); + for (std::string::reverse_iterator mi = magic_number.rbegin(); mi != magic_number.rend(); ++mi) { _file->putback(*mi); @@ -308,7 +308,7 @@ prepare_read() { // Attempt to get the scale close to our target scale. int x_reduction = _cinfo.image_width / _read_x_size; int y_reduction = _cinfo.image_height / _read_y_size; - _cinfo.scale_denom = max(min(x_reduction, y_reduction), 1); + _cinfo.scale_denom = std::max(std::min(x_reduction, y_reduction), 1); } /* Step 7: Start decompressor */ @@ -413,7 +413,7 @@ read_data(xel *array, xelval *) { */ if (_jerr.pub.num_warnings) { pnmimage_jpg_cat.warning() - << "Jpeg data may be corrupt" << endl; + << "Jpeg data may be corrupt" << std::endl; } return _y_size; diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index 5308a3417e..6f0285a841 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -53,7 +53,7 @@ extern "C" { typedef struct { struct jpeg_destination_mgr pub; /* public fields */ - ostream * outfile; /* target stream */ + std::ostream * outfile; /* target stream */ JOCTET * buffer; /* start of buffer */ } my_destination_mgr; @@ -156,7 +156,7 @@ term_destination (j_compress_ptr cinfo) */ GLOBAL(void) -jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) +jpeg_ostream_dest (j_compress_ptr cinfo, std::ostream * outfile) { my_dest_ptr dest; @@ -187,7 +187,7 @@ jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) * */ PNMFileTypeJPG::Writer:: -Writer(PNMFileType *type, ostream *file, bool owns_file) : +Writer(PNMFileType *type, std::ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index 3c2bb2b1d0..799f4d1dce 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -21,6 +21,10 @@ #include "bamReader.h" #include "thread.h" +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_png[] = { "png" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index 7fd918aa73..cdc1e62f93 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -20,6 +20,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_PNM[] = { "pbm", "pgm", "ppm", "pnm" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx index 71652689ec..89324f3c61 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx @@ -18,6 +18,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle PNMFileTypePfm::_type_handle; /** diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx index e35880daa3..e2a99eb378 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx @@ -21,6 +21,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char * const extensions_sgi[] = { "rgb", "rgba", "sgi" }; @@ -100,7 +102,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeSGI:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -111,7 +113,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeSGI:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index 2f56552d18..fafb625fac 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -23,6 +23,9 @@ #include "pnotify.h" +using std::istream; +using std::string; + // Much code in this file is borrowed from Netpbm, specifically sgitopnm.c. /* sgitopnm.c - read an SGI image and and produce a portable anymap @@ -121,7 +124,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : _x_size = head.xsize; _y_size = head.ysize; - _num_channels = min((int)head.zsize, 4); + _num_channels = std::min((int)head.zsize, 4); bpc = head.bpc; current_row = _y_size - 1; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index faf45cc093..f5b143e867 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -49,6 +49,8 @@ #define MAXVAL_BYTE 255 #define MAXVAL_WORD 65535 +using std::ostream; + inline void put_byte(ostream *out_file, unsigned char b) { out_file->put(b); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx index e2d12c3e33..d67a22fa53 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx @@ -20,6 +20,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + static const float imageVersionNumber = 3.0; static const int imageCommentLength = 80; static const char imageComment[imageCommentLength+1] = @@ -322,7 +326,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : read_float(_file); // Skip comment - _file->seekg(imageCommentLength, ios::cur); + _file->seekg(imageCommentLength, std::ios::cur); char pict_id[4]; _file->read(pict_id, 4); diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx index 93599cac83..96610157a4 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx @@ -60,6 +60,10 @@ #include "stb_image.h" +using std::ios; +using std::istream; +using std::string; + static const char *const stb_extensions[] = { // Expose the extensions that we don't already expose through other loaders. #if !defined(HAVE_JPEG) && !defined(ANDROID) @@ -300,7 +304,7 @@ read_pfm(PfmFile &pfm) { } else { // We need to reinitialize the context. _file->seekg(0, ios::beg); - if (_file->tellg() != (streampos)0) { + if (_file->tellg() != (std::streampos)0) { pnmimage_cat.error() << "Could not reposition file pointer to the beginning.\n"; return false; @@ -482,7 +486,7 @@ read_data(xel *array, xelval *alpha) { } else { // We need to reinitialize the context. _file->seekg(0, ios::beg); - if (_file->tellg() != (streampos)0) { + if (_file->tellg() != (std::streampos)0) { pnmimage_cat.error() << "Could not reposition file pointer to the beginning.\n"; return false; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 3be6bd1ff0..a50ae370ae 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -52,6 +52,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_tga[] = { "tga" }; @@ -717,8 +721,8 @@ get_pixel( istream *ifp, pixel *dest, int Size, gray *alpha_p) { Red = getbyte( ifp ); if ( Size == 32 ) Alpha = getbyte( ifp ); - else - Alpha = 0; + else + Alpha = 0; l = 0; break; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index e2d5cf0fa1..3c4634055d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -28,6 +28,11 @@ #define int32 tiff_int32 #define uint32 tiff_uint32 +using std::ios; +using std::istream; +using std::ostream; +using std::string; + extern "C" { #include #include @@ -1046,13 +1051,13 @@ write_data(xel *array, xelval *alpha) { bytesperrow = _x_size * samplesperpixel; } else if ( grayscale ) { samplesperpixel = 1; - bitspersample = min(8, pm_maxvaltobits(_maxval)); + bitspersample = std::min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_MINISBLACK; i = 8 / bitspersample; bytesperrow = ( _x_size + i - 1 ) / i; } else { samplesperpixel = 1; - bitspersample = min(8, pm_maxvaltobits(_maxval)); + bitspersample = std::min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_PALETTE; bytesperrow = _x_size; } diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index 78a7455b96..f922943b7f 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -25,6 +25,10 @@ #undef interface // I don't know where this symbol is defined, but it interferes with FreeType. #include FT_OUTLINE_H +using std::istream; +using std::ostream; +using std::string; + // This constant determines how big a particular point size font appears to // be. By convention, 10 points is 1 unit (e.g. 1 foot) high. const PN_stdfloat FreetypeFont::_points_per_unit = 10.0f; @@ -461,7 +465,7 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { } } else { - dist_sq = min((p - begin).length_squared(), (p - end).length_squared()); + dist_sq = std::min((p - begin).length_squared(), (p - end).length_squared()); if (begin[1] <= p[1]) { if (end[1] > p[1]) { if ((v[0] * (p[1] - begin[1]) > v[1] * (p[0] - begin[0]))) { @@ -503,7 +507,7 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { } } - min_dist_sq = min(min_dist_sq, dist_sq); + min_dist_sq = std::min(min_dist_sq, dist_sq); } } // Determine the sign based on whether we're inside the contour. diff --git a/panda/src/pnmtext/pnmTextGlyph.cxx b/panda/src/pnmtext/pnmTextGlyph.cxx index 833febd98c..d52e415c02 100644 --- a/panda/src/pnmtext/pnmTextGlyph.cxx +++ b/panda/src/pnmtext/pnmTextGlyph.cxx @@ -14,6 +14,9 @@ #include "pnmTextGlyph.h" #include "indent.h" +using std::max; +using std::min; + /** * */ diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index 1cf2c92a75..8a22fff510 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -18,6 +18,8 @@ #include FT_OUTLINE_H +using std::wstring; + /** * The constructor expects the name of some font file that FreeType can read, * along with face_index, indicating which font within the file to load diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 8a4a9fc288..c69e1ea032 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -27,6 +27,8 @@ #include "clockObject.h" #include "neverFreeMemory.h" +using std::string; + PStatCollector PStatClient::_heap_total_size_pcollector("System memory:Heap"); PStatCollector PStatClient::_heap_overhead_size_pcollector("System memory:Heap:Overhead"); PStatCollector PStatClient::_heap_single_size_pcollector("System memory:Heap:Single"); @@ -334,7 +336,7 @@ main_tick() { // Not used. break; } - ostringstream strm; + std::ostringstream strm; strm << "System memory:" << category << ":" << type; col = PStatCollector(strm.str()); } diff --git a/panda/src/pstatclient/pStatClientImpl.cxx b/panda/src/pstatclient/pStatClientImpl.cxx index d126c6c753..d607a53bd9 100644 --- a/panda/src/pstatclient/pStatClientImpl.cxx +++ b/panda/src/pstatclient/pStatClientImpl.cxx @@ -85,7 +85,7 @@ PStatClientImpl:: * Called only by PStatClient::client_connect(). */ bool PStatClientImpl:: -client_connect(string hostname, int port) { +client_connect(std::string hostname, int port) { nassertr(!_is_connected, true); if (hostname.empty()) { @@ -372,7 +372,7 @@ transmit_control_data() { /** * Returns the current machine's hostname. */ -string PStatClientImpl:: +std::string PStatClientImpl:: get_hostname() { if (_hostname.empty()) { char temp_buff[1024]; diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index a729a22fa8..710d803e3e 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -25,20 +25,6 @@ PStatCollector(PStatClient *client, int index) : { } -/** - * Creates an invalid PStatCollector. Any attempt to use this collector will - * crash messily. - * - * You can reassign it to a different, valid one later. - */ -INLINE PStatCollector:: -PStatCollector() : - _client(nullptr), - _index(0), - _level(0.0f) -{ -} - /** * Creates a new PStatCollector, ready to start accumulating data. The name * of the collector uniquely identifies it among the other collectors; if two diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index a007faa61c..aeb74f7cdb 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -47,7 +47,7 @@ private: INLINE PStatCollector(PStatClient *client, int index); public: - INLINE PStatCollector(); + PStatCollector() = default; PUBLISHED: INLINE explicit PStatCollector(const std::string &name, @@ -99,9 +99,9 @@ PUBLISHED: INLINE int get_index() const; private: - PStatClient *_client; - int _index; - double _level; + PStatClient *_client = nullptr; + int _index = 0; + double _level = 0.0; friend class PStatClient; diff --git a/panda/src/pstatclient/pStatCollectorDef.cxx b/panda/src/pstatclient/pStatCollectorDef.cxx index 13070343e0..bdd0035bba 100644 --- a/panda/src/pstatclient/pStatCollectorDef.cxx +++ b/panda/src/pstatclient/pStatCollectorDef.cxx @@ -38,7 +38,7 @@ PStatCollectorDef() { * */ PStatCollectorDef:: -PStatCollectorDef(int index, const string &name) : +PStatCollectorDef(int index, const std::string &name) : _index(index), _name(name) { diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 32db833ed5..cce31e693f 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -23,6 +23,8 @@ #include +using std::string; + static const int current_pstat_major_version = 3; static const int current_pstat_minor_version = 0; // Initialized at 2.0 on 51801, when version numbers were first added. diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index b60aa6c625..8151b808d2 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -85,7 +85,7 @@ public: int main(int argc, char *argv[]) { - string hostname = "localhost"; + std::string hostname = "localhost"; int port = pstats_port; if (argc > 1) { diff --git a/panda/src/putil/animInterface.cxx b/panda/src/putil/animInterface.cxx index 4727b4f907..304e4f95af 100644 --- a/panda/src/putil/animInterface.cxx +++ b/panda/src/putil/animInterface.cxx @@ -18,6 +18,9 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; + TypeHandle AnimInterface::_type_handle; /** @@ -61,7 +64,7 @@ get_num_frames() const { * */ void AnimInterface:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); cdata->output(out); } @@ -375,7 +378,7 @@ is_playing() const { * */ void AnimInterface::CData:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_play_mode) { case PM_pose: out << "pose, frame " << get_full_fframe(); diff --git a/panda/src/putil/autoTextureScale.cxx b/panda/src/putil/autoTextureScale.cxx index ea17b6f08b..f9c27128ce 100644 --- a/panda/src/putil/autoTextureScale.cxx +++ b/panda/src/putil/autoTextureScale.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_putil.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, AutoTextureScale ats) { switch (ats) { diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 385079d7ee..4dbcf06966 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -27,6 +27,11 @@ #include "configVariableFilename.h" #include "virtualFileSystem.h" +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + BamCache *BamCache::_global_ptr = nullptr; /** @@ -966,7 +971,7 @@ hash_filename(const string &filename) { } ostringstream strm; - strm << hex << setw(8) << setfill('0') << hash; + strm << std::hex << std::setw(8) << std::setfill('0') << hash; return strm.str(); #endif // HAVE_OPENSSL diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 889bb2a8ab..4455d5362d 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -37,7 +37,7 @@ BamCacheIndex:: * */ void BamCacheIndex:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BamCacheIndex, " << _records.size() << " records:\n"; @@ -45,13 +45,13 @@ write(ostream &out, int indent_level) const { for (ri = _records.begin(); ri != _records.end(); ++ri) { BamCacheRecord *record = (*ri).second; indent(out, indent_level + 2) - << setw(10) << record->_record_size << " " + << std::setw(10) << record->_record_size << " " << record->get_cache_filename() << " " << record->get_source_pathname() << "\n"; } out << "\n"; indent(out, indent_level) - << setw(12) << _cache_size << " bytes total\n"; + << std::setw(12) << _cache_size << " bytes total\n"; } /** @@ -129,7 +129,7 @@ evict_old_file() { */ bool BamCacheIndex:: add_record(BamCacheRecord *record) { - pair result = + std::pair result = _records.insert(Records::value_type(record->get_source_pathname(), record)); if (!result.second) { // We already had a record for this filename; it gets replaced. diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index f732dbcb9e..65a3c650f1 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -190,7 +190,7 @@ add_dependent_file(const VirtualFile *file) { * */ void BamCacheRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << "BamCacheRecord " << get_source_pathname(); } @@ -198,7 +198,7 @@ output(ostream &out) const { * */ void BamCacheRecord:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BamCacheRecord " << get_source_pathname() << "\n"; indent(out, indent_level) @@ -212,7 +212,7 @@ write(ostream &out, int indent_level) const { for (fi = _files.begin(); fi != _files.end(); ++fi) { const DependentFile &dfile = (*fi); indent(out, indent_level + 2) - << setw(10) << dfile._size << " " + << std::setw(10) << dfile._size << " " << format_timestamp(dfile._timestamp) << " " << dfile._pathname << "\n"; } @@ -221,7 +221,7 @@ write(ostream &out, int indent_level) const { /** * Returns a timestamp value formatted nicely for output. */ -string BamCacheRecord:: +std::string BamCacheRecord:: format_timestamp(time_t timestamp) { static const size_t buffer_size = 512; char buffer[buffer_size]; diff --git a/panda/src/putil/bamEnums.cxx b/panda/src/putil/bamEnums.cxx index ed1b18ac58..88d21cecf8 100644 --- a/panda/src/putil/bamEnums.cxx +++ b/panda/src/putil/bamEnums.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_putil.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, BamEnums::BamEndian be) { switch (be) { diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index a1b6641148..db360ae249 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -20,6 +20,8 @@ #include "config_putil.h" #include "pipelineCyclerBase.h" +using std::string; + TypeHandle BamReaderAuxData::_type_handle; WritableFactory *BamReader::_factory = nullptr; @@ -1111,7 +1113,7 @@ p_read_object() { default: bam_cat.error() - << "Encountered invalid BamObjectCode 0x" << hex << (int)boc << dec << ".\n"; + << "Encountered invalid BamObjectCode 0x" << std::hex << (int)boc << std::dec << ".\n"; return 0; } @@ -1251,7 +1253,7 @@ p_read_object() { if (object == nullptr) { if (bam_cat.is_debug()) { bam_cat.debug() - << "Unable to create an object of type " << type << endl; + << "Unable to create an object of type " << type << std::endl; } } else if (object->get_type() != type) { @@ -1263,7 +1265,7 @@ p_read_object() { bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ - << " was created instead." << endl; + << " was created instead." << std::endl; } } else { @@ -1272,7 +1274,7 @@ p_read_object() { bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ - << " was created instead." << endl; + << " was created instead." << std::endl; } } else { diff --git a/panda/src/putil/bitArray.cxx b/panda/src/putil/bitArray.cxx index f91c16d573..2ba077e0c1 100644 --- a/panda/src/putil/bitArray.cxx +++ b/panda/src/putil/bitArray.cxx @@ -16,6 +16,10 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; +using std::ostream; + TypeHandle BitArray::_type_handle; /** @@ -83,7 +87,7 @@ is_all_on() const { */ bool BitArray:: has_any_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (_highest_bits) { return true; @@ -93,7 +97,7 @@ has_any_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -122,7 +126,7 @@ has_any_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -136,7 +140,7 @@ has_any_of(int low_bit, int size) const { */ bool BitArray:: has_all_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (!_highest_bits) { return false; @@ -146,7 +150,7 @@ has_all_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -175,7 +179,7 @@ has_all_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -192,7 +196,7 @@ set_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. return; } @@ -225,7 +229,7 @@ set_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. normalize(); return; @@ -242,7 +246,7 @@ clear_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. return; } @@ -275,7 +279,7 @@ clear_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. normalize(); return; diff --git a/panda/src/putil/buttonHandle.cxx b/panda/src/putil/buttonHandle.cxx index 5495b7ce18..831a3daddd 100644 --- a/panda/src/putil/buttonHandle.cxx +++ b/panda/src/putil/buttonHandle.cxx @@ -27,14 +27,14 @@ TypeHandle ButtonHandle::_type_handle; * ButtonRegistry::register_button(). */ ButtonHandle:: -ButtonHandle(const string &name) { +ButtonHandle(const std::string &name) { _index = ButtonRegistry::ptr()->get_button(name)._index; } /** * Returns the name of the button. */ -string ButtonHandle:: +std::string ButtonHandle:: get_name() const { if ((*this) == ButtonHandle::none()) { return "none"; diff --git a/panda/src/putil/buttonMap.cxx b/panda/src/putil/buttonMap.cxx index 7fcc0fa516..2e74d929ce 100644 --- a/panda/src/putil/buttonMap.cxx +++ b/panda/src/putil/buttonMap.cxx @@ -20,7 +20,7 @@ TypeHandle ButtonMap::_type_handle; * Registers a new button mapping. */ void ButtonMap:: -map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { +map_button(ButtonHandle raw_button, ButtonHandle button, const std::string &label) { int index = raw_button.get_index(); if (_button_map.find(index) != _button_map.end()) { // A button with this index was already mapped. @@ -39,7 +39,7 @@ map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { * */ void ButtonMap:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ButtonMap (" << get_num_buttons() << " buttons)"; } @@ -47,7 +47,7 @@ output(ostream &out) const { * */ void ButtonMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "ButtonMap, " << get_num_buttons() << " buttons:\n"; diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index 2537dcc0dc..1800d9e88a 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -41,7 +41,7 @@ ButtonRegistry *ButtonRegistry::_global_pointer = nullptr; * right. */ bool ButtonRegistry:: -register_button(ButtonHandle &button_handle, const string &name, +register_button(ButtonHandle &button_handle, const std::string &name, ButtonHandle alias, char ascii_equivalent) { NameRegistry::iterator ri; ri = _name_registry.find(name); @@ -109,7 +109,7 @@ register_button(ButtonHandle &button_handle, const string &name, * is no such ButtonHandle, registers a new one and returns it. */ ButtonHandle ButtonRegistry:: -get_button(const string &name) { +get_button(const std::string &name) { NameRegistry::const_iterator ri; ri = _name_registry.find(name); @@ -127,7 +127,7 @@ get_button(const string &name) { * is no such ButtonHandle, returns ButtonHandle::none(). */ ButtonHandle ButtonRegistry:: -find_button(const string &name) { +find_button(const std::string &name) { NameRegistry::const_iterator ri; ri = _name_registry.find(name); @@ -155,7 +155,7 @@ find_ascii_button(char ascii_equivalent) const { * */ void ButtonRegistry:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ASCII equivalents:\n"; for (int i = 1; i < 128; i++) { if (_handle_registry[i] != nullptr) { diff --git a/panda/src/putil/callbackData.cxx b/panda/src/putil/callbackData.cxx index de7eac9678..1a3f15672b 100644 --- a/panda/src/putil/callbackData.cxx +++ b/panda/src/putil/callbackData.cxx @@ -20,7 +20,7 @@ TypeHandle CallbackData::_type_handle; * */ void CallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/putil/callbackObject.cxx b/panda/src/putil/callbackObject.cxx index 9f1ce360ac..579b0299b7 100644 --- a/panda/src/putil/callbackObject.cxx +++ b/panda/src/putil/callbackObject.cxx @@ -20,7 +20,7 @@ TypeHandle CallbackObject::_type_handle; * */ void CallbackObject:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/putil/clockObject.cxx b/panda/src/putil/clockObject.cxx index 341a11374a..0eb72647e4 100644 --- a/panda/src/putil/clockObject.cxx +++ b/panda/src/putil/clockObject.cxx @@ -17,6 +17,10 @@ #include "string_utils.h" #include "thread.h" +using std::istream; +using std::ostream; +using std::string; + void (*ClockObject::_start_clock_wait)() = ClockObject::dummy_clock_wait; void (*ClockObject::_start_clock_busy_wait)() = ClockObject::dummy_clock_wait; void (*ClockObject::_stop_clock_wait)() = ClockObject::dummy_clock_wait; @@ -351,7 +355,7 @@ tick(Thread *current_thread) { // In case someone munged the clock last frame and sent us backward in // time, clamp the previous time to the current time to make sure we don't // report anything strange (or wait interminably). - old_time = min(old_time, _actual_frame_time); + old_time = std::min(old_time, _actual_frame_time); ++cdata->_frame_count; @@ -375,7 +379,7 @@ tick(Thread *current_thread) { double wait_until_time = old_time + 1.0 / _user_frame_rate; wait_until(wait_until_time); cdata->_dt = _actual_frame_time - old_time; - cdata->_reported_frame_time = max(_actual_frame_time, wait_until_time); + cdata->_reported_frame_time = std::max(_actual_frame_time, wait_until_time); } break; diff --git a/panda/src/putil/colorSpace.cxx b/panda/src/putil/colorSpace.cxx index 075eb438a1..3a244a68eb 100644 --- a/panda/src/putil/colorSpace.cxx +++ b/panda/src/putil/colorSpace.cxx @@ -21,6 +21,11 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + ColorSpace parse_color_space_string(const string &str) { if (cmp_nocase_uh(str, "linear") == 0 || diff --git a/panda/src/putil/datagramBuffer.cxx b/panda/src/putil/datagramBuffer.cxx index c9831a4f82..7b1acb4ba1 100644 --- a/panda/src/putil/datagramBuffer.cxx +++ b/panda/src/putil/datagramBuffer.cxx @@ -20,7 +20,7 @@ * written. */ bool DatagramBuffer:: -write_header(const string &header) { +write_header(const std::string &header) { nassertr(!_wrote_first_datagram, false); _data.insert(_data.end(), header.begin(), header.end()); @@ -78,13 +78,13 @@ flush() { * has been read. */ bool DatagramBuffer:: -read_header(string &header, size_t num_bytes) { +read_header(std::string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); if (_read_offset + num_bytes > _data.size()) { return false; } - header = string((char *)&_data[_read_offset], num_bytes); + header = std::string((char *)&_data[_read_offset], num_bytes); _read_offset += num_bytes; return true; } diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 466d78006b..c4802ceed2 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -22,6 +22,9 @@ #include "streamReader.h" #include "thread.h" +using std::streampos; +using std::streamsize; + /** * Opens the indicated filename for reading. Returns true on success, false * on failure. @@ -54,7 +57,7 @@ open(const FileReference *file) { * you are responsible for closing or deleting it when you are done. */ bool DatagramInputFile:: -open(istream &in, const Filename &filename) { +open(std::istream &in, const Filename &filename) { close(); _in = ∈ @@ -98,7 +101,7 @@ close() { * has been read. */ bool DatagramInputFile:: -read_header(string &header, size_t num_bytes) { +read_header(std::string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); nassertr(_in != nullptr, false); @@ -110,7 +113,7 @@ read_header(string &header, size_t num_bytes) { return false; } - header = string(buffer, num_bytes); + header = std::string(buffer, num_bytes); Thread::consider_yield(); return true; } @@ -170,7 +173,7 @@ get_datagram(Datagram &data) { // standards. Let's take it 4MB at a time just in case the length is // corrupt, so we don't allocate potentially a few GBs of RAM only to // find a truncated file. - bytes_left = min(bytes_left, (size_t)4*1024*1024); + bytes_left = std::min(bytes_left, (size_t)4*1024*1024); PTA_uchar buffer = data.modify_array(); buffer.resize(buffer.size() + bytes_left); @@ -221,7 +224,7 @@ save_datagram(SubfileInfo &info) { // into this file. if (_file != nullptr) { info = SubfileInfo(_file, _in->tellg(), num_bytes); - _in->seekg(num_bytes, ios::cur); + _in->seekg(num_bytes, std::ios::cur); return true; } @@ -245,7 +248,7 @@ save_datagram(SubfileInfo &info) { static const size_t buffer_size = 4096; char buffer[buffer_size]; - _in->read(buffer, min((streamsize)buffer_size, num_remaining)); + _in->read(buffer, std::min((streamsize)buffer_size, num_remaining)); streamsize count = _in->gcount(); while (count != 0) { out.write(buffer, count); @@ -259,7 +262,7 @@ save_datagram(SubfileInfo &info) { if (num_remaining == 0) { break; } - _in->read(buffer, min((streamsize)buffer_size, num_remaining)); + _in->read(buffer, std::min((streamsize)buffer_size, num_remaining)); count = _in->gcount(); } diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index 24533ad8b0..407e1adfec 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -16,6 +16,10 @@ #include "zStream.h" #include +using std::min; +using std::streampos; +using std::streamsize; + /** * Opens the indicated filename for writing. Returns true if successful, * false on failure. @@ -47,7 +51,7 @@ open(const FileReference *file) { * are responsible for closing or deleting it when you are done. */ bool DatagramOutputFile:: -open(ostream &out, const Filename &filename) { +open(std::ostream &out, const Filename &filename) { close(); _out = &out; @@ -89,7 +93,7 @@ close() { * written. */ bool DatagramOutputFile:: -write_header(const string &header) { +write_header(const std::string &header) { nassertr(_out != nullptr, false); nassertr(!_wrote_first_datagram, false); @@ -145,7 +149,7 @@ copy_datagram(SubfileInfo &result, const Filename &filename) { if (vfile == nullptr) { return false; } - istream *in = vfile->open_read_file(true); + std::istream *in = vfile->open_read_file(true); if (in == nullptr) { return false; } diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 35ede588a4..cc400a14fb 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -214,8 +214,8 @@ has_any_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_any_of(0, hi_portion) << lo_portion) || - _lo.has_any_of(low_bit, lo_portion); + return _hi.has_any_of(0, hi_portion) + || _lo.has_any_of(low_bit, lo_portion); } } @@ -232,8 +232,8 @@ has_all_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_all_of(0, hi_portion) << lo_portion) && - _lo.has_all_of(low_bit, lo_portion); + return _hi.has_all_of(0, hi_portion) + && _lo.has_all_of(low_bit, lo_portion); } } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index bfb803da39..341028d068 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -15,20 +15,6 @@ #include "indent.h" #include "config_putil.h" -/** - * - */ -FactoryBase:: -FactoryBase() { -} - -/** - * - */ -FactoryBase:: -~FactoryBase() { -} - /** * Attempts to create a new instance of some class of the indicated type, or * some derivative if necessary. If an instance of the exact type cannot be @@ -145,7 +131,7 @@ register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) { /** * Returns the number of different types the Factory knows how to create. */ -int FactoryBase:: +size_t FactoryBase:: get_num_types() const { return _creators.size(); } @@ -156,8 +142,8 @@ get_num_types() const { * Normally you wouldn't need to traverse the list of the Factory's types. */ TypeHandle FactoryBase:: -get_type(int n) const { - nassertr(n >= 0 && n < get_num_types(), TypeHandle::none()); +get_type(size_t n) const { + nassertr(n < get_num_types(), TypeHandle::none()); Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { if (n == 0) { @@ -193,7 +179,7 @@ add_preferred(TypeHandle handle) { /** * Returns the number of types added to the preferred-type list. */ -int FactoryBase:: +size_t FactoryBase:: get_num_preferred() const { return _preferred.size(); } @@ -202,8 +188,8 @@ get_num_preferred() const { * Returns the nth type added to the preferred-type list. */ TypeHandle FactoryBase:: -get_preferred(int n) const { - nassertr(n >= 0 && n < get_num_preferred(), TypeHandle::none()); +get_preferred(size_t n) const { + nassertr(n < get_num_preferred(), TypeHandle::none()); return _preferred[n]; } @@ -212,28 +198,13 @@ get_preferred(int n) const { * output stream, one per line. */ void FactoryBase:: -write_types(ostream &out, int indent_level) const { +write_types(std::ostream &out, int indent_level) const { Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { indent(out, indent_level) << (*ci).first << "\n"; } } - -/** - * Don't copy Factories. - */ -FactoryBase:: -FactoryBase(const FactoryBase &) { -} - -/** - * Don't copy Factories. - */ -void FactoryBase:: -operator = (const FactoryBase &) { -} - /** * Attempts to create an instance of the exact type requested by the given * handle. Returns the new instance created, or NULL if the instance could @@ -262,9 +233,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { // First, walk through the established preferred list. Maybe one of these // qualifies. - Preferred::const_iterator pi; - for (pi = _preferred.begin(); pi != _preferred.end(); ++pi) { - TypeHandle ptype = (*pi); + for (TypeHandle ptype : _preferred) { if (ptype.is_derived_from(handle)) { TypedObject *object = make_instance_exact(ptype, params); if (object != nullptr) { diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 7ef256f1a8..65617f254b 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -39,8 +39,11 @@ public: // public interface public: - FactoryBase(); - ~FactoryBase(); + FactoryBase() = default; + FactoryBase(const FactoryBase ©) = delete; + ~FactoryBase() = default; + + FactoryBase &operator = (const FactoryBase ©) = delete; TypedObject *make_instance(TypeHandle handle, const FactoryParams ¶ms); @@ -58,21 +61,17 @@ public: void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr); - int get_num_types() const; - TypeHandle get_type(int n) const; + size_t get_num_types() const; + TypeHandle get_type(size_t n) const; void clear_preferred(); void add_preferred(TypeHandle handle); - int get_num_preferred() const; - TypeHandle get_preferred(int n) const; + size_t get_num_preferred() const; + TypeHandle get_preferred(size_t n) const; void write_types(std::ostream &out, int indent_level = 0) const; private: - // These are private; we shouldn't be copy-constructing Factories. - FactoryBase(const FactoryBase ©); - void operator = (const FactoryBase ©); - // internal utility functions TypedObject *make_instance_exact(TypeHandle handle, FactoryParams params); TypedObject *make_instance_more_specific(TypeHandle handle, diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index b62406861a..0f71e62969 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -13,45 +13,6 @@ #include "pnotify.h" -/** - * - */ -INLINE FactoryParams:: -FactoryParams() : _user_data(nullptr) { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(const FactoryParams ©) : - _params(copy._params), - _user_data(copy._user_data) {} - -/** - * - */ -INLINE FactoryParams:: -~FactoryParams() { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(FactoryParams &&from) noexcept : - _params(std::move(from._params)), - _user_data(from._user_data) {} - -/** - * - */ -INLINE void FactoryParams:: -operator = (FactoryParams &&from) noexcept { - _params = std::move(from._params); - _user_data = from._user_data; -} - /** * Returns the custom pointer that was associated with the factory function. */ diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h index 3f987e7f66..b76dc81e84 100644 --- a/panda/src/putil/factoryParams.h +++ b/panda/src/putil/factoryParams.h @@ -35,12 +35,12 @@ */ class EXPCL_PANDA_PUTIL FactoryParams { public: - INLINE FactoryParams(); - INLINE FactoryParams(const FactoryParams ©); - INLINE FactoryParams(FactoryParams &&from) noexcept; - INLINE ~FactoryParams(); + FactoryParams() = default; + FactoryParams(const FactoryParams ©) = default; + FactoryParams(FactoryParams &&from) noexcept = default; + ~FactoryParams() = default; - INLINE void operator = (FactoryParams &&from) noexcept; + FactoryParams &operator = (FactoryParams &&from) noexcept = default; void add_param(FactoryParam *param); void clear(); @@ -56,7 +56,7 @@ private: typedef pvector< PT(TypedReferenceCount) > Params; Params _params; - void *_user_data; + void *_user_data = nullptr; friend class FactoryBase; }; diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index 622a666f6e..2f6f308baf 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -57,7 +57,7 @@ ns_store_pointer(TypeHandle type, void *ptr) { clear_pointer(type); return; } - pair result = + std::pair result = _pointers.insert(Pointers::value_type(type, ptr)); if (!result.second) { diff --git a/panda/src/putil/keyboardButton.cxx b/panda/src/putil/keyboardButton.cxx index e6d7162d50..3ab8e38265 100644 --- a/panda/src/putil/keyboardButton.cxx +++ b/panda/src/putil/keyboardButton.cxx @@ -155,7 +155,7 @@ init_keyboard_buttons() { for (int i = 32; i < 127; i++) { if (isgraph(i)) { ButtonHandle key; - ButtonRegistry::ptr()->register_button(key, string(1, (char)i), + ButtonRegistry::ptr()->register_button(key, std::string(1, (char)i), ButtonHandle::none(), i); } } diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index faed3b5c96..a61aaa854c 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -33,6 +33,25 @@ LinkedListNode(bool) { _prev = this; } +/** + * This move constructor replaces the other link with this one. + */ +INLINE LinkedListNode:: +LinkedListNode(LinkedListNode &&from) noexcept { + if (from._prev != nullptr) { + nassertv(from._prev->_next == &from); + from._prev->_next = this; + } + _prev = from._prev; + if (from._next != nullptr) { + nassertv(from._next->_prev == &from); + from._next->_prev = this; + } + _next = from._next; + from._next = nullptr; + from._prev = nullptr; +} + /** * */ @@ -41,6 +60,23 @@ INLINE LinkedListNode:: nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this)); } +/** + * Replaces the given other node with this node. + */ +INLINE LinkedListNode &LinkedListNode:: +operator = (LinkedListNode &&from) { + nassertr((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this), *this); + nassertr(from._prev != nullptr && from._next != nullptr, *this); + nassertr(from._prev->_next == &from && from._next->_prev == &from, *this); + from._prev->_next = this; + from._next->_prev = this; + _prev = from._prev; + _next = from._next; + from._next = nullptr; + from._prev = nullptr; + return *this; +} + /** * Returns true if the node is member of any list, false if it has been * removed or never added. The head of a list generally appears to to always diff --git a/panda/src/putil/linkedListNode.h b/panda/src/putil/linkedListNode.h index 9dedbe9e4d..5f8e6f1909 100644 --- a/panda/src/putil/linkedListNode.h +++ b/panda/src/putil/linkedListNode.h @@ -32,8 +32,11 @@ class EXPCL_PANDA_PUTIL LinkedListNode { protected: INLINE LinkedListNode(); INLINE LinkedListNode(bool); + INLINE LinkedListNode(LinkedListNode &&from) noexcept; INLINE ~LinkedListNode(); + INLINE LinkedListNode &operator = (LinkedListNode &&from); + INLINE bool is_on_list() const; INLINE void remove_from_list(); INLINE void insert_before(LinkedListNode *node); diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index 7da6526c9c..f40296b403 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -43,7 +43,7 @@ load_prc_file(const Filename &filename) { vfs->resolve_filename(path, cp_mgr->get_search_path()) || vfs->resolve_filename(path, get_model_path()); - istream *file = vfs->open_read_file(path, true); + std::istream *file = vfs->open_read_file(path, true); if (file == nullptr) { util_cat.error() << "Unable to open " << path << "\n"; @@ -78,8 +78,8 @@ load_prc_file(const Filename &filename) { * loaded prc files is listed. */ EXPCL_PANDA_PUTIL ConfigPage * -load_prc_file_data(const string &name, const string &data) { - istringstream strm(data); +load_prc_file_data(const std::string &name, const std::string &data) { + std::istringstream strm(data); ConfigPageManager *cp_mgr = ConfigPageManager::get_global_ptr(); @@ -121,7 +121,7 @@ unload_prc_file(ConfigPage *page) { */ void hash_prc_variables(HashVal &hash) { - ostringstream strm; + std::ostringstream strm; ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr(); cv_mgr->write_prc_variables(strm); hash.hash_string(strm.str()); diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 167d977cd7..508e22f23c 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -15,6 +15,8 @@ #include "config_putil.h" #include "indent.h" +using std::string; + /** * */ @@ -54,7 +56,7 @@ LoaderOptions(int flags) : * */ void LoaderOptions:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LoaderOptions("; string sep = ""; @@ -100,7 +102,7 @@ output(ostream &out) const { * Used to implement output(). */ void LoaderOptions:: -write_flag(ostream &out, string &sep, +write_flag(std::ostream &out, string &sep, const string &flag_name, int flag) const { if ((_flags & flag) == flag) { out << sep << flag_name; @@ -112,7 +114,7 @@ write_flag(ostream &out, string &sep, * Used to implement output(). */ void LoaderOptions:: -write_texture_flag(ostream &out, string &sep, +write_texture_flag(std::ostream &out, string &sep, const string &flag_name, int flag) const { if ((_texture_flags & flag) == flag) { out << sep << flag_name; diff --git a/panda/src/putil/modifierButtons.cxx b/panda/src/putil/modifierButtons.cxx index a0c4a79146..00a75fcdd9 100644 --- a/panda/src/putil/modifierButtons.cxx +++ b/panda/src/putil/modifierButtons.cxx @@ -302,9 +302,9 @@ is_down(ButtonHandle button) const { * Returns a string which can be used to prefix any button name or event name * with the unique set of modifier buttons currently being held. */ -string ModifierButtons:: +std::string ModifierButtons:: get_prefix() const { - string prefix; + std::string prefix; for (int i = 0; i < (int)_button_list.size(); i++) { if ((_state & ((BitmaskType)1 << i)) != 0) { prefix += _button_list[i].get_name(); @@ -319,7 +319,7 @@ get_prefix() const { * Writes a one-line summary of the buttons known to be down. */ void ModifierButtons:: -output(ostream &out) const { +output(std::ostream &out) const { out << "["; for (int i = 0; i < (int)_button_list.size(); i++) { if ((_state & ((BitmaskType)1 << i)) != 0) { @@ -334,7 +334,7 @@ output(ostream &out) const { * and which ones are known to be down. */ void ModifierButtons:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ModifierButtons:\n"; for (int i = 0; i < (int)_button_list.size(); i++) { out << " " << _button_list[i]; diff --git a/panda/src/putil/mouseData.cxx b/panda/src/putil/mouseData.cxx index 8149672c9b..de83bd1505 100644 --- a/panda/src/putil/mouseData.cxx +++ b/panda/src/putil/mouseData.cxx @@ -17,7 +17,7 @@ * */ void MouseData:: -output(ostream &out) const { +output(std::ostream &out) const { if (!_in_window) { out << "MouseData: Not in window"; } else { diff --git a/panda/src/putil/nameUniquifier.cxx b/panda/src/putil/nameUniquifier.cxx index 0629a58ac9..e6ab3f6917 100644 --- a/panda/src/putil/nameUniquifier.cxx +++ b/panda/src/putil/nameUniquifier.cxx @@ -17,6 +17,8 @@ #include +using std::string; + /** * Creates a new NameUniquifier. diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index 309f8885bd..5ffcf2807c 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -56,7 +56,7 @@ ParamTypedRefCount:: * */ void ParamTypedRefCount:: -output(ostream &out) const { +output(std::ostream &out) const { if (_value == nullptr) { out << "(empty)"; diff --git a/panda/src/putil/sparseArray.cxx b/panda/src/putil/sparseArray.cxx index 37940d1d10..6373e53039 100644 --- a/panda/src/putil/sparseArray.cxx +++ b/panda/src/putil/sparseArray.cxx @@ -214,7 +214,7 @@ has_bits_in_common(const SparseArray &other) const { * */ void SparseArray:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ "; if (_inverse) { out << "all except: "; @@ -442,7 +442,7 @@ do_remove_range(int begin, int end) { si = _subranges.begin() + _subranges.size() - 1; if ((*si)._end >= begin) { // The new range shortens the last element of the array on the right. - end = min(end, (*si)._begin); + end = std::min(end, (*si)._begin); (*si)._end = end; // It might also shorten it on the left; fall through. } else { @@ -465,7 +465,7 @@ do_remove_range(int begin, int end) { if ((*si2)._end >= begin) { // The new range shortens an element within the array on the right // (but does not intersect the next element). - end = min(end, (*si2)._begin); + end = std::min(end, (*si2)._begin); (*si2)._end = end; // It might also shorten it on the left; fall through. si = si2; @@ -499,7 +499,7 @@ do_remove_range(int begin, int end) { si = si2; } - (*si)._end = min((*si)._end, begin); + (*si)._end = std::min((*si)._end, begin); } /** diff --git a/panda/src/putil/test_bam.cxx b/panda/src/putil/test_bam.cxx index a6103d5c5f..bf6d862434 100644 --- a/panda/src/putil/test_bam.cxx +++ b/panda/src/putil/test_bam.cxx @@ -17,6 +17,8 @@ #include "test_bam.h" +using std::endl; + TypeHandle Person::_type_handle; TypeHandle Parent::_type_handle; diff --git a/panda/src/putil/test_bamRead.cxx b/panda/src/putil/test_bamRead.cxx index d49f49434b..50949f63eb 100644 --- a/panda/src/putil/test_bamRead.cxx +++ b/panda/src/putil/test_bamRead.cxx @@ -20,7 +20,7 @@ int main(int argc, char* argv[]) { - string test_file = "bamTest.out"; + std::string test_file = "bamTest.out"; DatagramInputFile stream; bool success = stream.open(test_file); nassertr(success, 1); @@ -37,11 +37,11 @@ int main(int argc, char* argv[]) manager.resolve(); dad->print_relationships(); - nout << endl; + nout << std::endl; mom->print_relationships(); - nout << endl; + nout << std::endl; bro->print_relationships(); - nout << endl; + nout << std::endl; sis->print_relationships(); return 0; diff --git a/panda/src/putil/test_bamWrite.cxx b/panda/src/putil/test_bamWrite.cxx index 59d56930ec..9469b8a6a3 100644 --- a/panda/src/putil/test_bamWrite.cxx +++ b/panda/src/putil/test_bamWrite.cxx @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) { - string test_file("bamTest.out"); + std::string test_file("bamTest.out"); DatagramOutputFile stream; bool success = stream.open(test_file); nassertr(success, 1); diff --git a/panda/src/putil/test_glob.cxx b/panda/src/putil/test_glob.cxx index 32ba0d1927..cc5141dcdd 100644 --- a/panda/src/putil/test_glob.cxx +++ b/panda/src/putil/test_glob.cxx @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { if (argc != 2 && argc != 3) { - cerr + std::cerr << "test_glob \"pattern\" [from-directory]\n\n" << "Attempts to match the pattern against each of the files in the\n" << "indicated directory if specified, or the current directory\n" @@ -36,10 +36,10 @@ main(int argc, char *argv[]) { vector_string results; int num_matched = pattern.match_files(results, from_directory); - cerr << num_matched << " results:\n"; + std::cerr << num_matched << " results:\n"; vector_string::const_iterator si; for (si = results.begin(); si != results.end(); ++si) { - cerr << " " << *si << "\n"; + std::cerr << " " << *si << "\n"; } return (0); diff --git a/panda/src/putil/test_uniqueIdAllocator.cxx b/panda/src/putil/test_uniqueIdAllocator.cxx index be39a01450..73c3c6b498 100644 --- a/panda/src/putil/test_uniqueIdAllocator.cxx +++ b/panda/src/putil/test_uniqueIdAllocator.cxx @@ -4,7 +4,9 @@ #include #include #include -using namespace std; + +using std::cout; +using std::endl; #include "uniqueIdAllocator.h" diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index d0e5058538..8ca4081c63 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -190,11 +190,11 @@ bool TypedWritable:: decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader) { - DatagramBuffer buffer(move(data)); + DatagramBuffer buffer(std::move(data)); if (reader == nullptr) { // Create a local reader. - string head; + std::string head; if (!buffer.read_header(head, _bam_header.size())) { return false; } diff --git a/panda/src/putil/typedWritableReferenceCount.cxx b/panda/src/putil/typedWritableReferenceCount.cxx index ba4e2c49e4..3ca6d27550 100644 --- a/panda/src/putil/typedWritableReferenceCount.cxx +++ b/panda/src/putil/typedWritableReferenceCount.cxx @@ -41,7 +41,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { TypedWritable *object; ReferenceCount *ref_ptr; - if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, move(data), reader)) { + if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, std::move(data), reader)) { return DCAST(TypedWritableReferenceCount, object); } else { return nullptr; diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index c736a6fa14..3db4b086c3 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -52,9 +52,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // can't use this interface. PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); if (method == nullptr) { - ostringstream stream; + std::ostringstream stream; stream << "Cannot pickle objects of type " << _this->get_type() << "\n"; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } @@ -75,9 +75,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // First, streamify the object, if possible. vector_uchar bam_stream; if (!_this->encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; + std::ostringstream stream; stream << "Could not bamify object of type " << _this->get_type() << "\n"; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index 0b3307a2af..6c4edd9795 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -17,6 +17,8 @@ #include "uniqueIdAllocator.h" +using std::endl; + NotifyCategoryDecl(uniqueIdAllocator, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDef(uniqueIdAllocator, ""); @@ -212,7 +214,7 @@ fraction_used() const { * ...intended for debugging only. */ void UniqueIdAllocator:: -output(ostream &out) const { +output(std::ostream &out) const { out << "UniqueIdAllocator(" << _min << ", " << _max << "), " << _free << " id's remaining of " << _size; } @@ -221,7 +223,7 @@ output(ostream &out) const { * ...intended for debugging only. */ void UniqueIdAllocator:: -write(ostream &out) const { +write(std::ostream &out) const { out << "_min: " << _min << "; _max: " << _max << ";\n_next_free: " << int32_t(_next_free) << "; _last_free: " << int32_t(_last_free) diff --git a/panda/src/recorder/mouseRecorder.cxx b/panda/src/recorder/mouseRecorder.cxx index a79c7dc49b..37a5a2a440 100644 --- a/panda/src/recorder/mouseRecorder.cxx +++ b/panda/src/recorder/mouseRecorder.cxx @@ -23,7 +23,7 @@ TypeHandle MouseRecorder::_type_handle; * */ MouseRecorder:: -MouseRecorder(const string &name) : +MouseRecorder(const std::string &name) : DataNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); @@ -88,7 +88,7 @@ play_frame(DatagramIterator &scan, BamReader *manager) { * */ void MouseRecorder:: -output(ostream &out) const { +output(std::ostream &out) const { DataNode::output(out); } @@ -96,7 +96,7 @@ output(ostream &out) const { * */ void MouseRecorder:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); } diff --git a/panda/src/recorder/recorderController.cxx b/panda/src/recorder/recorderController.cxx index b383402715..805ea5778a 100644 --- a/panda/src/recorder/recorderController.cxx +++ b/panda/src/recorder/recorderController.cxx @@ -113,7 +113,7 @@ begin_playback(const Filename &filename) { return false; } - string head; + std::string head; if (!_din.read_header(head, _bam_header.size()) || head != _bam_header) { recorder_cat.error() << "Unable to read " << _filename << "\n"; return false; diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 27fc5ed2c8..4db629865f 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -18,6 +18,8 @@ #include "recorderController.h" #include "indent.h" +using std::string; + TypeHandle RecorderTable::_type_handle; /** @@ -140,7 +142,7 @@ clear_flags(short flags) { * */ void RecorderTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "RecorderTable:\n"; diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 9c9d66b310..5ee6168d44 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -85,7 +85,7 @@ play_frame(DatagramIterator &scan, BamReader *manager) { size_t size = scan.get_uint16(); vector_uchar packet(size); scan.extract_bytes(&packet[0], size); - _data.push_back(Datagram(move(packet))); + _data.push_back(Datagram(std::move(packet))); } } diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 0c3a25fc29..5a54e31c8f 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -50,7 +50,7 @@ Open(const Rocket::Core::String& path) { } } - istream *str = file->open_read_file(true); + std::istream *str = file->open_read_file(true); if (str == nullptr) { rocket_cat.error() << "Failed to open " << fn << " for reading\n"; return (Rocket::Core::FileHandle) nullptr; @@ -104,13 +104,13 @@ Seek(Rocket::Core::FileHandle file, long offset, int origin) { switch(origin) { case SEEK_SET: - handle->_stream->seekg(offset, ios::beg); + handle->_stream->seekg(offset, std::ios::beg); break; case SEEK_CUR: - handle->_stream->seekg(offset, ios::cur); + handle->_stream->seekg(offset, std::ios::cur); break; case SEEK_END: - handle->_stream->seekg(offset, ios::end); + handle->_stream->seekg(offset, std::ios::end); }; return !handle->_stream->fail(); diff --git a/panda/src/rocket/rocketInputHandler.cxx b/panda/src/rocket/rocketInputHandler.cxx index fcfa6dc2cf..6b07e3a02b 100644 --- a/panda/src/rocket/rocketInputHandler.cxx +++ b/panda/src/rocket/rocketInputHandler.cxx @@ -31,7 +31,7 @@ TypeHandle RocketInputHandler::_type_handle; * */ RocketInputHandler:: -RocketInputHandler(const string &name) : +RocketInputHandler(const std::string &name) : DataNode(name), _mouse_xy(-1), _mouse_xy_changed(false), diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index fe21d5c6c2..17fdc8f55f 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -31,7 +31,7 @@ TypeHandle RocketRegion::_type_handle; */ RocketRegion:: RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, - const string &context_name) : + const std::string &context_name) : DisplayRegion(window, dr_dimensions) { // A hack I don't like. libRocket's decorator system has a bug somewhere, diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index 0f67d2fb96..a0fe4e3022 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -27,7 +27,7 @@ LoaderFileTypeSrt() { /** * */ -string LoaderFileTypeSrt:: +std::string LoaderFileTypeSrt:: get_name() const { return "SpeedTree compiled tree"; } @@ -35,7 +35,7 @@ get_name() const { /** * */ -string LoaderFileTypeSrt:: +std::string LoaderFileTypeSrt:: get_extension() const { return "srt"; } @@ -68,5 +68,5 @@ load_file(const Filename &path, const LoaderOptions &, PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); st->add_instance(tree, STTransform()); - return st.p(); + return st; } diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 2f568fae3c..9d83bddd3d 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -26,7 +26,7 @@ LoaderFileTypeStf() { /** * */ -string LoaderFileTypeStf:: +std::string LoaderFileTypeStf:: get_name() const { return "SpeedTree compiled tree"; } @@ -34,7 +34,7 @@ get_name() const { /** * */ -string LoaderFileTypeStf:: +std::string LoaderFileTypeStf:: get_extension() const { return "stf"; } @@ -62,5 +62,5 @@ load_file(const Filename &path, const LoaderOptions &options, PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); st->add_from_stf(path, options); - return st.p(); + return st; } diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index da8c036d8e..48cda1204b 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -42,6 +42,10 @@ #include "dxGraphicsStateGuardian9.h" #endif +using std::istream; +using std::ostream; +using std::string; + double SpeedTreeNode::_global_time_delta = 0.0; bool SpeedTreeNode::_authorized; bool SpeedTreeNode::_done_first_init; @@ -155,7 +159,7 @@ add_tree(const STTree *tree) { if (ti == _trees.end()) { // This is the first time that this particular tree has been added. InstanceList *instance_list = new InstanceList(tree); - pair result = _trees.insert(instance_list); + std::pair result = _trees.insert(instance_list); ti = result.first; bool inserted = result.second; nassertr(inserted, *(*ti)); @@ -1245,10 +1249,10 @@ repopulate() { SpeedTree::CMap::const_iterator si; si = _population_stats.m_mMaxNumInstancesPerCellPerBase.find(tree->get_tree()); if (si != _population_stats.m_mMaxNumInstancesPerCellPerBase.end()) { - max_instances = max(max_instances, (int)si->second); + max_instances = std::max(max_instances, (int)si->second); } - max_instances_by_cell = max(max_instances_by_cell, max_instances); + max_instances_by_cell = std::max(max_instances_by_cell, max_instances); } _visible_trees.Reserve(_forest_render.GetBaseTrees(), @@ -1547,7 +1551,7 @@ setup_for_render(GraphicsStateGuardian *gsg) { SpeedTree::CMap::const_iterator si; si = _population_stats.m_mMaxNumInstancesPerCellPerBase.find(tree->get_tree()); if (si != _population_stats.m_mMaxNumInstancesPerCellPerBase.end()) { - max_instances = max(max_instances, (int)si->second); + max_instances = std::max(max_instances, (int)si->second); } // Get the speedtree-textures-dir to pass for initialization. diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 2a6dba22f4..1c32cfe02f 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -16,6 +16,10 @@ #include "pnmImage.h" #include "indent.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle STBasicTerrain::_type_handle; // VERTEX_ATTRIB_END is defined as a macro that must be evaluated within the @@ -345,8 +349,8 @@ read_height_map() { v *= scalar; _height_data._data[pi] = v; ++pi; - _min_height = min(_min_height, v); - _max_height = max(_max_height, v); + _min_height = std::min(_min_height, v); + _max_height = std::max(_max_height, v); } } diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index fef97b9d0d..9215a5dd26 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -149,7 +149,7 @@ fill_vertices(GeomVertexData *data, * */ void STTerrain:: -output(ostream &out) const { +output(std::ostream &out) const { Namable::output(out); } @@ -157,7 +157,7 @@ output(ostream &out) const { * */ void STTerrain:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/speedtree/stTransform.cxx b/panda/src/speedtree/stTransform.cxx index aab4be7e93..dfdb586a6c 100644 --- a/panda/src/speedtree/stTransform.cxx +++ b/panda/src/speedtree/stTransform.cxx @@ -44,7 +44,7 @@ STTransform(const TransformState *trans) { * */ void STTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << "STTransform(" << _pos << ", " << _rotate << ", " << _scale << ")"; } diff --git a/panda/src/speedtree/stTree.cxx b/panda/src/speedtree/stTree.cxx index 7a09205d6e..a34b36e7a4 100644 --- a/panda/src/speedtree/stTree.cxx +++ b/panda/src/speedtree/stTree.cxx @@ -48,7 +48,7 @@ STTree(const Filename &fullpath) : } */ - string os_fullpath = _fullpath.to_os_specific(); + std::string os_fullpath = _fullpath.to_os_specific(); if (!_tree.LoadTree(os_fullpath.c_str())) { speedtree_cat.warning() << "Couldn't read: " << _fullpath << "\n"; @@ -65,7 +65,7 @@ STTree(const Filename &fullpath) : * */ void STTree:: -output(ostream &out) const { +output(std::ostream &out) const { if (!is_valid()) { out << "(invalid STTree)"; } else { diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index d93cf64382..6858165bdf 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -22,6 +22,8 @@ #define RANDFRAC (rand()/(PN_stdfloat)(RAND_MAX)) +using std::string; + class GriddedFilename { public: Filename _filename; @@ -244,7 +246,7 @@ load_gridded_models(WindowFramework *window, } grid_pos_offset = -gridwidth*GRIDCELLSIZE/2.0; - wander_area_pos_offset = -max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); + wander_area_pos_offset = -std::max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); // Now walk through the list again, copying models into the scene graph as // we go. diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 8d39104d64..73e71a358d 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -29,6 +29,9 @@ #include "asyncTask.h" #include "boundingSphere.h" +using std::cerr; +using std::endl; + PandaFramework framework; ConfigVariableBool pview_test_hack @@ -237,7 +240,7 @@ report_version() { // class AdjustCameraClipPlanesTask : public AsyncTask { public: - AdjustCameraClipPlanesTask(const string &name, Camera *camera) : + AdjustCameraClipPlanesTask(const std::string &name, Camera *camera) : AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(nullptr) { NodePath np = framework.get_models(); @@ -317,12 +320,12 @@ public: // Ensure the far plane is far enough back to see the entire object. PN_stdfloat ideal_far_plane = distance + radius * 1.5; - _lens->set_far(max(_lens->get_default_far(), ideal_far_plane)); + _lens->set_far(std::max(_lens->get_default_far(), ideal_far_plane)); // And that the near plane is far enough forward, but if inside // the sphere, keep above 0. - PN_stdfloat ideal_near_plane = max(min_distance * 10, distance - radius); - _lens->set_near(min(_lens->get_default_near(), ideal_near_plane)); + PN_stdfloat ideal_near_plane = std::max(min_distance * 10, distance - radius); + _lens->set_near(std::min(_lens->get_default_near(), ideal_near_plane)); return DS_cont; } diff --git a/panda/src/testbed/test_map.cxx b/panda/src/testbed/test_map.cxx index 2c85f2c11a..97c0176a9d 100644 --- a/panda/src/testbed/test_map.cxx +++ b/panda/src/testbed/test_map.cxx @@ -16,6 +16,10 @@ #include "memoryUsage.h" #include "clockObject.h" +using std::cerr; +using std::cout; +using std::string; + class Alpha { public: Alpha(const string &str) : _str(str) { } @@ -36,7 +40,7 @@ public: string _str; }; -ostream &operator << (ostream &out, const Alpha &alpha) { +std::ostream &operator << (std::ostream &out, const Alpha &alpha) { return out << alpha._str; } @@ -113,7 +117,7 @@ test_performance() { static const int num_cycles = 10000; static const int num_reps = 3; - vector samples; + std::vector samples; samples.reserve(sample_size); for (int s = 0; s < sample_size; s++) { string key; diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index 977c1b0209..fd26a11508 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -49,7 +49,7 @@ event_T(const Event *, void *data) { static const int tex_x_size = 256; static const int tex_y_size = 256; - cerr << "Loading " << num_quads_side * num_quads_side << " textures at " + std::cerr << "Loading " << num_quads_side * num_quads_side << " textures at " << tex_x_size << ", " << tex_y_size << "\n"; PNMImage white_center(tex_x_size / 4, tex_y_size / 4); @@ -92,7 +92,7 @@ event_T(const Event *, void *data) { card.set_texture(tex); } } - cerr << "Done.\n"; + std::cerr << "Done.\n"; } int diff --git a/panda/src/testbed/text_test.cxx b/panda/src/testbed/text_test.cxx deleted file mode 100644 index f0689940ad..0000000000 --- a/panda/src/testbed/text_test.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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." - * - * @file text_test.cxx - */ - -#include "eventHandler.h" -#include "chancfg.h" -#include "textNode.h" -#include "eggLoader.h" -#include "pnotify.h" -#include "pt_NamedNode.h" - -extern PT_NamedNode render; -extern PT_NamedNode egg_root; -extern EventHandler event_handler; - -extern int framework_main(int argc, char *argv[]); -extern void (*define_keys)(EventHandler&); - -PT(TextNode) text_node; -char *textStr; - -void event_p(CPT_Event) { - text_node->set_text("I'm a woo woo woo!"); - - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; -} - -void event_s(CPT_Event) { - text_node->set_wordwrap(5.0); - - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; -} - -void text_keys(EventHandler& eh) { - eh.add_hook("p", event_p); - eh.add_hook("s", event_s); - - text_node = new TextNode("text_node"); - PT_NamedNode font = loader.load_sync("cmr12"); - text_node->set_font(font.p()); - text_node->set_wordwrap(20.0); - text_node->set_card_as_margin(0.25, 0.25, 0.25, 0.25); - PT(Texture) tex = new Texture; - tex->set_name("genericButton.rgb"); - tex->set_minfilter(SamplerState::FT_linear); - tex->set_magfilter(SamplerState::FT_linear); - tex->read("/beta/toons/textures/smGreyButtonUp.rgb"); - text_node->set_card_texture( tex ); - text_node->set_card_border(0.1, 0.1); - text_node->set_text( textStr ); - text_node->set_text_color( 0.0, 0.0, 0.0, 1.0 ); - if (text_node->has_card_texture()) - nout << "I've got a texture!" << "\n"; - else - nout << "I don't have a texture..." << "\n"; - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; - - new RenderRelation(egg_root, text_node); -} - -int main(int argc, char *argv[]) { - define_keys = &text_keys; - if (argc > 1) - textStr = argv[1]; - else - textStr = argv[0]; - return framework_main(argc, argv); -} diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 1bdcafcf09..77dd27beba 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -31,6 +31,8 @@ #error Buildsystem error: BUILDING_PANDA_TEXT not defined #endif +using std::wstring; + Configure(config_text); NotifyCategoryDef(text, ""); diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 42c040c6ed..4eb4afc96a 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -226,7 +226,7 @@ clear() { * */ void DynamicTextFont:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { static const int max_glyph_name = 1024; char glyph_name[max_glyph_name]; @@ -972,7 +972,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { void DynamicTextFont:: render_wireframe_contours(TextGlyph *glyph) { PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3(), + (std::string(), GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); @@ -1003,7 +1003,7 @@ render_wireframe_contours(TextGlyph *glyph) { void DynamicTextFont:: render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3n3(), + (std::string(), GeomVertexFormat::get_v3n3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter normal(vdata, InternalName::get_normal()); diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index b48ba426db..7bfe582040 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -17,7 +17,6 @@ #ifdef HAVE_FREETYPE - TypeHandle DynamicTextPage::_type_handle; /** @@ -40,7 +39,7 @@ DynamicTextPage(DynamicTextFont *font, int page_number) : setup_2d_texture(_size[0], _size[1], T_unsigned_byte, font->get_tex_format()); // Assign a name to the Texture. - ostringstream strm; + std::ostringstream strm; strm << font->get_name() << "_" << page_number; set_name(strm.str()); @@ -215,7 +214,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { } next_x = overlap->_x + overlap->_x_size; - next_y = min(next_y, overlap->_y + overlap->_y_size); + next_y = std::min(next_y, overlap->_y + overlap->_y_size); nassertr(next_x > x, false); x = next_x; } diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index 6217be1bae..3f01243771 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -21,13 +21,15 @@ #include "loader.h" #include "lightMutexHolder.h" +using std::string; + FontPool *FontPool::_global_ptr = nullptr; /** * Lists the contents of the font pool to the indicated output stream. */ void FontPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -211,7 +213,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void FontPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _fonts.size() << " fonts:\n"; @@ -252,7 +254,7 @@ lookup_filename(const string &str, string &index_str, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(filename, get_model_path()); - ostringstream strm; + std::ostringstream strm; strm << filename << ":" << face_index; index_str = strm.str(); } diff --git a/panda/src/text/geomTextGlyph.cxx b/panda/src/text/geomTextGlyph.cxx index 6a02f2af16..ecd1a2173c 100644 --- a/panda/src/text/geomTextGlyph.cxx +++ b/panda/src/text/geomTextGlyph.cxx @@ -142,7 +142,7 @@ count_geom(const Geom *other) { * */ void GeomTextGlyph:: -output(ostream &out) const { +output(std::ostream &out) const { Geom::output(out); out << ", glyphs: ["; Glyphs::const_iterator gi; @@ -158,7 +158,7 @@ output(ostream &out) const { * */ void GeomTextGlyph:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Geom::write(out, indent_level); indent(out, indent_level) << "Glyphs: ["; diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 2f68c2dba8..c179120a14 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -114,7 +114,7 @@ make_copy() const { * */ void StaticTextFont:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "StaticTextFont " << get_name() << "; " << _glyphs.size() << " characters available in font:\n"; @@ -280,7 +280,7 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, void StaticTextFont:: find_characters(PandaNode *root, const RenderState *net_state) { CPT(RenderState) next_net_state = net_state->compose(root->get_state()); - string name = root->get_name(); + std::string name = root->get_name(); bool all_digits = !name.empty(); const char *p = name.c_str(); diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index e59b83a100..3925715c6d 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -40,6 +40,11 @@ #include #endif +using std::max; +using std::min; +using std::move; +using std::wstring; + // This is the factor by which CT_small scales the character down. static const PN_stdfloat small_accent_scale = 0.6f; @@ -827,7 +832,7 @@ scan_wtext(TextAssembler::TextString &output_string, // Now we have to encode the wstring into a string, for lookup in the // TextPropertiesManager. - string graphic_name = _encoder->encode_wtext(graphic_wname); + std::string graphic_name = _encoder->encode_wtext(graphic_wname); TextPropertiesManager *manager = TextPropertiesManager::get_global_ptr(); @@ -1132,52 +1137,30 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { GeomTextGlyph::Glyphs glyphs; glyphs.reserve(quads.size()); - static CPT(GeomVertexFormat) format; - if (format.is_null()) { - // The optimized code below assumes 32-bit floats, so let's make sure we - // got the right format by creating it ourselves. - format = GeomVertexFormat::register_format(new GeomVertexArrayFormat( - InternalName::get_vertex(), 3, GeomEnums::NT_float32, GeomEnums::C_point, - InternalName::get_texcoord(), 2, GeomEnums::NT_float32, GeomEnums::C_texcoord)); - } - + const GeomVertexFormat *format = GeomVertexFormat::get_v3t2(); PT(GeomVertexData) vdata = new GeomVertexData("text", format, Geom::UH_static); - PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); - if (quads.size() > 10922) { - tris->set_index_type(GeomEnums::NT_uint32); - } else { - tris->set_index_type(GeomEnums::NT_uint16); - } - - int i = 0; + Thread *current_thread = Thread::get_current_thread(); // This is quite a critical loop and GeomVertexWriter quickly becomes the // bottleneck. So, I've written this out the hard way instead. Two - // versions of the loop: one for 32-bit indices, one for 16-bit. + // versions of the loop: one for 32-bit floats, the other for 64-bit. { PT(GeomVertexArrayDataHandle) vtx_handle = vdata->modify_array_handle(0); vtx_handle->unclean_set_num_rows(quads.size() * 4); - Thread *current_thread = Thread::get_current_thread(); unsigned char *write_ptr = vtx_handle->get_write_pointer(); - size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float32); - PN_float32 *vtx_ptr = (PN_float32 *) - (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); - PN_float32 *tex_ptr = (PN_float32 *) - (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + if (format->get_vertex_column()->get_numeric_type() == GeomEnums::NT_float32) { + // 32-bit vertex case. + size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float32); - if (tris->get_index_type() == GeomEnums::NT_uint32) { - // 32-bit index case. - PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); - idx_handle->unclean_set_num_rows(quads.size() * 6); - uint32_t *idx_ptr = (uint32_t *)idx_handle->get_write_pointer(); - - QuadDefs::const_iterator qi; - for (qi = quads.begin(); qi != quads.end(); ++qi) { - const QuadDef &quad = (*qi); + PN_float32 *vtx_ptr = (PN_float32 *) + (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); + PN_float32 *tex_ptr = (PN_float32 *) + (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + for (const QuadDef &quad : quads) { vtx_ptr[0] = quad._dimensions[0] + quad._slanth; vtx_ptr[1] = 0; vtx_ptr[2] = quad._dimensions[3]; @@ -1214,26 +1197,18 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { tex_ptr[1] = quad._uvs[1]; tex_ptr += stride; - *(idx_ptr++) = i + 0; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 3; - i += 4; - glyphs.push_back(move(quad._glyph)); } } else { - // 16-bit index case. - PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); - idx_handle->unclean_set_num_rows(quads.size() * 6); - uint16_t *idx_ptr = (uint16_t *)idx_handle->get_write_pointer(); + // 64-bit vertex case. + size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float64); - QuadDefs::const_iterator qi; - for (qi = quads.begin(); qi != quads.end(); ++qi) { - const QuadDef &quad = (*qi); + PN_float64 *vtx_ptr = (PN_float64 *) + (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); + PN_float64 *tex_ptr = (PN_float64 *) + (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + for (const QuadDef &quad : quads) { vtx_ptr[0] = quad._dimensions[0] + quad._slanth; vtx_ptr[1] = 0; vtx_ptr[2] = quad._dimensions[3]; @@ -1270,21 +1245,51 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { tex_ptr[1] = quad._uvs[1]; tex_ptr += stride; - *(idx_ptr++) = i + 0; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 3; - i += 4; - glyphs.push_back(move(quad._glyph)); } } } + // Now write the indices. Two cases: 32-bit indices and 16-bit indices. + int vtx_count = quads.size() * 4; + PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); + if (vtx_count > 65535) { + tris->set_index_type(GeomEnums::NT_uint32); + } else { + tris->set_index_type(GeomEnums::NT_uint16); + } + { + PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); + idx_handle->unclean_set_num_rows(quads.size() * 6); + if (tris->get_index_type() == GeomEnums::NT_uint16) { + // 16-bit index case. + uint16_t *idx_ptr = (uint16_t *)idx_handle->get_write_pointer(); + + for (int i = 0; i < vtx_count; i += 4) { + *(idx_ptr++) = i + 0; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 3; + } + } else { + // 32-bit index case. + uint32_t *idx_ptr = (uint32_t *)idx_handle->get_write_pointer(); + + for (int i = 0; i < vtx_count; i += 4) { + *(idx_ptr++) = i + 0; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 3; + } + } + } + // We can compute this value much faster than GeomPrimitive can. - tris->set_minmax(0, i - 1, nullptr, nullptr); + tris->set_minmax(0, vtx_count - 1, nullptr, nullptr); PT(GeomTextGlyph) geom = new GeomTextGlyph(vdata); geom->_glyphs.swap(glyphs); @@ -1628,7 +1633,7 @@ assemble_row(TextAssembler::TextRow &row, if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; if (!first_glyph->is_whitespace()) { - swap(placement._glyph, first_glyph); + std::swap(placement._glyph, first_glyph); placed_glyphs.push_back(placement); } } @@ -1638,7 +1643,7 @@ assemble_row(TextAssembler::TextRow &row, if (second_glyph != nullptr) { placement._xpos += advance * glyph_scale; advance += second_glyph->get_advance(); - swap(placement._glyph, second_glyph); + std::swap(placement._glyph, second_glyph); placed_glyphs.push_back(placement); } @@ -2414,7 +2419,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, int vi = primitive->get_vertex(i); // Attempt to insert number "vi" into the map. - pair added = vimap.insert(VertexIndexMap::value_type(vi, 0)); + std::pair added = vimap.insert(VertexIndexMap::value_type(vi, 0)); int new_vertex; if (added.second) { // The insert succeeded. That means this is the first time we have diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index 866743a5e8..bf6e9c5397 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -21,6 +21,10 @@ #include "geom.h" #include +using std::istream; +using std::ostream; +using std::string; + TypeHandle TextFont::_type_handle; /** diff --git a/panda/src/text/textGlyph.cxx b/panda/src/text/textGlyph.cxx index d68dce6371..bb8d998175 100644 --- a/panda/src/text/textGlyph.cxx +++ b/panda/src/text/textGlyph.cxx @@ -17,6 +17,9 @@ #include "geomVertexReader.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + TypeHandle TextGlyph::_type_handle; /** @@ -252,7 +255,7 @@ make_quad_geom() { // rather than a single triangle strip, to avoid the bad vertex duplication // behavior with lots of two-triangle strips. PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3t2(), Geom::UH_static); + (std::string(), GeomVertexFormat::get_v3t2(), Geom::UH_static); vdata->unclean_set_num_rows(4); PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 7e0e687ada..92001d7b40 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -49,6 +49,8 @@ #include +using std::string; + TypeHandle TextNode::_type_handle; PStatCollector TextNode::_text_generate_pcollector("*:Generate Text"); @@ -252,10 +254,10 @@ is_whitespace(wchar_t character) const { * like \1 or \3. */ PN_stdfloat TextNode:: -calc_width(const wstring &line) const { +calc_width(const std::wstring &line) const { PN_stdfloat width = 0.0f; - wstring::const_iterator si; + std::wstring::const_iterator si; for (si = line.begin(); si != line.end(); ++si) { width += calc_width(*si); } @@ -267,7 +269,7 @@ calc_width(const wstring &line) const { * */ void TextNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); check_rebuild(); @@ -283,7 +285,7 @@ output(ostream &out) const { * */ void TextNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); TextProperties::write(out, indent_level + 2); indent(out, indent_level + 2) @@ -346,7 +348,7 @@ generate() { CPT(TransformState) transform = TransformState::make_mat(mat); root->set_transform(transform); - wstring wtext = get_wtext(); + std::wstring wtext = get_wtext(); // Assemble the text. TextAssembler assembler(this); @@ -753,7 +755,7 @@ make_frame() { frame_node->add_geom(geom2, state); } - return frame_node.p(); + return frame_node; } /** @@ -793,7 +795,7 @@ make_card() { card_node->add_geom(geom); - return card_node.p(); + return card_node; } @@ -894,7 +896,7 @@ make_card_with_border() { card_node->add_geom(geom); - return card_node.p(); + return card_node; } /** diff --git a/panda/src/text/textProperties.cxx b/panda/src/text/textProperties.cxx index dea089b612..42e7982638 100644 --- a/panda/src/text/textProperties.cxx +++ b/panda/src/text/textProperties.cxx @@ -253,7 +253,7 @@ add_properties(const TextProperties &other) { * */ void TextProperties:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (!is_any_specified()) { indent(out, indent_level) << "default properties\n"; @@ -408,7 +408,7 @@ get_text_state() const { state = state->add_attrib(CullBinAttrib::make(get_bin(), get_draw_order() + 2)); } - swap(_text_state, state); + std::swap(_text_state, state); return _text_state; } @@ -433,7 +433,7 @@ get_shadow_state() const { state = state->add_attrib(CullBinAttrib::make(get_bin(), get_draw_order() + 1)); } - swap(_shadow_state, state); + std::swap(_shadow_state, state); return _shadow_state; } @@ -466,16 +466,16 @@ load_default_font() { #else // The compiled-in Bam font requires creating a BamFile object to decode it. - string data((const char *)default_font_data, default_font_size); + std::string data((const char *)default_font_data, default_font_size); #ifdef HAVE_ZLIB // The font data is stored compressed; decompress it on-the-fly. - istringstream inz(data); + std::istringstream inz(data); IDecompressStream in(&inz, false); #else // The font data is stored uncompressed, so just load it. - istringstream in(data); + std::istringstream in(data); #endif // HAVE_ZLIB BamFile bam_file; diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index c057196e52..1c589499cc 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -14,6 +14,8 @@ #include "textPropertiesManager.h" #include "indent.h" +using std::string; + TextPropertiesManager *TextPropertiesManager::_global_ptr = nullptr; /** @@ -179,7 +181,7 @@ clear_graphic(const string &name) { * */ void TextPropertiesManager:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Properties::const_iterator pi; for (pi = _properties.begin(); pi != _properties.end(); ++pi) { indent(out, indent_level) diff --git a/panda/src/tform/buttonThrower.cxx b/panda/src/tform/buttonThrower.cxx index 33c7150fb1..2446c1929a 100644 --- a/panda/src/tform/buttonThrower.cxx +++ b/panda/src/tform/buttonThrower.cxx @@ -21,6 +21,8 @@ #include "indent.h" #include "dcast.h" +using std::string; + TypeHandle ButtonThrower::_type_handle; @@ -204,7 +206,7 @@ clear_throw_buttons() { * Throw all events for button events found in the data element. */ void ButtonThrower:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_throw_buttons_active) { indent(out, indent_level) @@ -310,7 +312,7 @@ do_general_event(const ButtonEvent &button_event, const string &button_name) { break; case ButtonEvent::T_keystroke: - event->add_parameter(wstring(1, button_event._keycode)); + event->add_parameter(std::wstring(1, button_event._keycode)); break; case ButtonEvent::T_candidate: diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index e9adfd8829..eb3433c557 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -25,6 +25,9 @@ #include "dataNodeTransmit.h" #include "dataGraphTraverser.h" +using std::max; +using std::min; + TypeHandle DriveInterface::_type_handle; const PN_stdfloat DriveInterface::_hpr_quantize = 0.001; @@ -95,7 +98,7 @@ operator < (const DriveInterface::KeyHeld &other) const { * */ DriveInterface:: -DriveInterface(const string &name) : +DriveInterface(const std::string &name) : MouseInterfaceNode(name) { _xy_input = define_input("xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/mouseInterfaceNode.cxx b/panda/src/tform/mouseInterfaceNode.cxx index 22031c4219..63c6c6cf87 100644 --- a/panda/src/tform/mouseInterfaceNode.cxx +++ b/panda/src/tform/mouseInterfaceNode.cxx @@ -23,7 +23,7 @@ TypeHandle MouseInterfaceNode::_type_handle; * */ MouseInterfaceNode:: -MouseInterfaceNode(const string &name) : +MouseInterfaceNode(const std::string &name) : DataNode(name) { _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); diff --git a/panda/src/tform/mouseSubregion.cxx b/panda/src/tform/mouseSubregion.cxx index f342db85fe..89a5fcca94 100644 --- a/panda/src/tform/mouseSubregion.cxx +++ b/panda/src/tform/mouseSubregion.cxx @@ -20,7 +20,7 @@ TypeHandle MouseSubregion::_type_handle; * */ MouseSubregion:: -MouseSubregion(const string &name) : +MouseSubregion(const std::string &name) : MouseInterfaceNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 67dbee8591..c4b5c0a6e7 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -35,6 +35,8 @@ #include +using std::string; + TypeHandle MouseWatcher::_type_handle; /** @@ -487,7 +489,7 @@ note_activity() { * */ void MouseWatcher:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(_lock); DataNode::output(out); @@ -507,7 +509,7 @@ output(ostream &out) const { * */ void MouseWatcher:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "MouseWatcher " << get_name() << ":\n"; MouseWatcherBase::write(out, indent_level + 2); @@ -625,7 +627,7 @@ set_current_regions(MouseWatcher::Regions ®ions) { // Queue up all the new regions so we can send the within patterns all at // once, after all of the without patterns have been thrown. - vector new_regions; + std::vector new_regions; bool any_changes = false; while (new_ri != regions.end() && old_ri != _current_regions.end()) { @@ -672,7 +674,7 @@ set_current_regions(MouseWatcher::Regions ®ions) { _current_regions.swap(regions); // And don't forget to throw all of the new regions' "within" events. - vector::const_iterator ri; + std::vector::const_iterator ri; for (ri = new_regions.begin(); ri != new_regions.end(); ++ri) { MouseWatcherRegion *new_region = (*ri); within_region(new_region, param); @@ -1059,7 +1061,7 @@ keystroke(int keycode) { * IME. */ void MouseWatcher:: -candidate(const wstring &candidate_string, size_t highlight_start, +candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { nassertv(_lock.debug_is_locked()); diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 46c1ae9743..6137ad9b3e 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -105,7 +105,7 @@ remove_region(MouseWatcherRegion *region) { * indeterminate. */ MouseWatcherRegion *MouseWatcherBase:: -find_region(const string &name) const { +find_region(const std::string &name) const { LightMutexHolder holder(_lock); for (MouseWatcherRegion *region : _regions) { @@ -169,7 +169,7 @@ get_region(size_t n) const { * */ void MouseWatcherBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << "MouseWatcherGroup (" << _regions.size() << " regions)"; } @@ -177,7 +177,7 @@ output(ostream &out) const { * */ void MouseWatcherBase:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LightMutexHolder holder(_lock); for (MouseWatcherRegion *region : _regions) { @@ -192,7 +192,7 @@ write(ostream &out, int indent_level) const { * scene graph for the window. */ void MouseWatcherBase:: -show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { +show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order) { LightMutexHolder holder(_lock); do_show_regions(render2d, bin_name, draw_order); } @@ -292,7 +292,7 @@ do_remove_region(MouseWatcherRegion *region) { * already held. */ void MouseWatcherBase:: -do_show_regions(const NodePath &render2d, const string &bin_name, +do_show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order) { do_hide_regions(); _show_regions = true; diff --git a/panda/src/tform/mouseWatcherParameter.cxx b/panda/src/tform/mouseWatcherParameter.cxx index c1a697375e..9cc502694a 100644 --- a/panda/src/tform/mouseWatcherParameter.cxx +++ b/panda/src/tform/mouseWatcherParameter.cxx @@ -17,7 +17,7 @@ * */ void MouseWatcherParameter:: -output(ostream &out) const { +output(std::ostream &out) const { bool output_anything = false; if (has_button()) { diff --git a/panda/src/tform/mouseWatcherRegion.cxx b/panda/src/tform/mouseWatcherRegion.cxx index b9905a4715..2b7465041c 100644 --- a/panda/src/tform/mouseWatcherRegion.cxx +++ b/panda/src/tform/mouseWatcherRegion.cxx @@ -22,7 +22,7 @@ TypeHandle MouseWatcherRegion::_type_handle; * */ void MouseWatcherRegion:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << " lrbt = " << _frame; } @@ -30,7 +30,7 @@ output(ostream &out) const { * */ void MouseWatcherRegion:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << " lrbt = " << _frame << ", sort = " << _sort << "\n"; diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index 620b52950b..b56e1d47fe 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -34,7 +34,7 @@ TypeHandle Trackball::_type_handle; * */ Trackball:: -Trackball(const string &name) : +Trackball(const std::string &name) : MouseInterfaceNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 3f7137af56..61f734521f 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -23,7 +23,7 @@ TypeHandle Transform2SG::_type_handle; * */ Transform2SG:: -Transform2SG(const string &name) : +Transform2SG(const std::string &name) : DataNode(name) { _transform_input = define_input("transform", TransformState::get_class_type()); diff --git a/panda/src/tinydisplay/clip.cxx b/panda/src/tinydisplay/clip.cxx index da20a86adc..f2c6baa4ba 100644 --- a/panda/src/tinydisplay/clip.cxx +++ b/panda/src/tinydisplay/clip.cxx @@ -11,6 +11,8 @@ #define CLIP_ZMIN (1<<4) #define CLIP_ZMAX (1<<5) +using std::min; + void gl_transform_to_viewport(GLContext *c,GLVertex *v) { PN_stdfloat winv; diff --git a/panda/src/tinydisplay/store_pixel.cxx b/panda/src/tinydisplay/store_pixel.cxx index 07d5e7bdf4..4ffd8dde30 100644 --- a/panda/src/tinydisplay/store_pixel.cxx +++ b/panda/src/tinydisplay/store_pixel.cxx @@ -17,7 +17,7 @@ /* Pick up all of the generated code references to store_pixel.h. */ -#define STORE_PIX_CLAMP(x) (min((x), (unsigned int)0xffff)) +#define STORE_PIX_CLAMP(x) (std::min((x), (unsigned int)0xffff)) #include "store_pixel_table.h" #include "store_pixel_code.h" diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index 95599e9b22..ea8e8241a6 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -25,7 +25,7 @@ TypeHandle TinyGraphicsBuffer::_type_handle; */ TinyGraphicsBuffer:: TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 782d461dc2..8f49433ebd 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -40,6 +40,9 @@ #include "store_pixel_table.h" #include "graphicsEngine.h" +using std::max; +using std::min; + TypeHandle TinyGraphicsStateGuardian::_type_handle; PStatCollector TinyGraphicsStateGuardian::_vertices_immediate_pcollector("Vertices:Immediate mode"); @@ -1790,7 +1793,7 @@ do_issue_light() { */ void TinyGraphicsStateGuardian:: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { - pair lookup = _plights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _plights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -1842,7 +1845,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { */ void TinyGraphicsStateGuardian:: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { - pair lookup = _dlights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _dlights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -1901,7 +1904,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { */ void TinyGraphicsStateGuardian:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { - pair lookup = _plights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _plights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -2010,7 +2013,7 @@ do_issue_render_mode() { default: tinydisplay_cat.error() - << "Unknown render mode " << (int)target_render_mode->get_mode() << endl; + << "Unknown render mode " << (int)target_render_mode->get_mode() << std::endl; } } @@ -2043,7 +2046,7 @@ do_issue_rescale_normal() { default: tinydisplay_cat.error() - << "Unknown rescale_normal mode " << (int)mode << endl; + << "Unknown rescale_normal mode " << (int)mode << std::endl; } } @@ -2089,7 +2092,7 @@ do_issue_cull_face() { break; default: tinydisplay_cat.error() - << "invalid cull face mode " << (int)mode << endl; + << "invalid cull face mode " << (int)mode << std::endl; break; } } @@ -2248,10 +2251,10 @@ do_issue_texture() { // The following special cases are handled inline, rather than relying // on the above wrap function pointers. - if (wrap_u && SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { + if (wrap_u == SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { texture_def->tex_minfilter_func = apply_wrap_border_color_minfilter; texture_def->tex_magfilter_func = apply_wrap_border_color_magfilter; - } else if (wrap_u && SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { + } else if (wrap_u == SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { texture_def->tex_minfilter_func = apply_wrap_clamp_minfilter; texture_def->tex_magfilter_func = apply_wrap_clamp_magfilter; } diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx index 2e2c517fee..901d874c6d 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -43,7 +43,7 @@ TinyOffscreenGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyOffscreenGraphicsPipe:: +std::string TinyOffscreenGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -61,7 +61,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinyOffscreenGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index 6a55f05b94..349fad4398 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -48,7 +48,7 @@ TinyOsxGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyOsxGraphicsPipe:: +std::string TinyOsxGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -181,7 +181,7 @@ release_data(void *info, const void *data, size_t size) { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) TinyOsxGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 7afe0953a4..8a8ef6c54b 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -55,7 +55,7 @@ TinySDLGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinySDLGraphicsPipe:: +std::string TinySDLGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -73,7 +73,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinySDLGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index d0fe649b79..640adf3d5d 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -30,7 +30,7 @@ TypeHandle TinySDLGraphicsWindow::_type_handle; */ TinySDLGraphicsWindow:: TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx index 6cfb2dc7c7..adc51e6c9f 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -43,7 +43,7 @@ TinyWinGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyWinGraphicsPipe:: +std::string TinyWinGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -62,7 +62,7 @@ pipe_constructor() { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) TinyWinGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index 85f1776ae5..ac16d45bf2 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -31,7 +31,7 @@ TypeHandle TinyWinGraphicsWindow::_type_handle; */ TinyWinGraphicsWindow:: TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index 7bbfbecf79..76cf30050e 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -27,7 +27,7 @@ TypeHandle TinyXGraphicsPipe::_type_handle; * */ TinyXGraphicsPipe:: -TinyXGraphicsPipe(const string &display) : x11GraphicsPipe(display) { +TinyXGraphicsPipe(const std::string &display) : x11GraphicsPipe(display) { } /** @@ -43,7 +43,7 @@ TinyXGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyXGraphicsPipe:: +std::string TinyXGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -61,7 +61,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinyXGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 64f1a7c809..e84fa4d834 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -37,7 +37,7 @@ TypeHandle TinyXGraphicsWindow::_type_handle; */ TinyXGraphicsWindow:: TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -334,7 +334,7 @@ process_events() { if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) { // This is a message from the window manager indicating that the user // has requested to close the window. - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the // request and process it directly. diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index 45dbe1b0a2..ceab7790d8 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -24,6 +24,9 @@ int pixel_count_smooth_multitex2; int pixel_count_smooth_multitex3; #endif // DO_PSTATS +using std::max; +using std::min; + ZBuffer * ZB_open(int xsize, int ysize, int mode, int nb_colors, diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index daa035dc75..72f3c1ae11 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -14,7 +14,7 @@ int error, derror; int x1, dxdy_min, dxdy_max; /* warning: x2 is multiplied by 2^16 */ - UNUSED int x2, dx2dy2; + int x2, dx2dy2; #ifdef INTERP_Z int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; @@ -348,10 +348,10 @@ int n; #ifdef INTERP_Z ZPOINT *pz; - UNUSED unsigned int z,zz; + unsigned int z,zz; #endif #ifdef INTERP_RGB - UNUSED unsigned int or1,og1,ob1,oa1; + unsigned int or1,og1,ob1,oa1; #endif #ifdef INTERP_ST unsigned int s,t; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 49c4550b4a..0d9db0df0f 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -1,3 +1,9 @@ +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + static void FNAME(white_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) @@ -229,7 +235,7 @@ FNAME(smooth_textured) (ZBuffer *zb, c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_textured)(zb, p0, p1, p2); \ return; \ @@ -537,13 +543,13 @@ FNAME(smooth_perspective) (ZBuffer *zb, #define EARLY_OUT() \ { \ - int c0, c1, c2; \ + unsigned int c0, c1, c2; \ c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \ c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \ c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_perspective)(zb, p0, p1, p2); \ return; \ @@ -1008,3 +1014,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, #undef INTERP_MIPMAP #undef CALC_MIPMAP_LEVEL #undef ZB_LOOKUP_TEXTURE + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 9d990cc26b..cb9a73508d 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -145,7 +145,7 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) { } ARParam wparam; - string fn = paramfile.to_os_specific(); + std::string fn = paramfile.to_os_specific(); if( arParamLoad(fn.c_str(), 1, &wparam) < 0 ) { vision_cat.error() << "Cannot load ARToolKit camera config\n"; return 0; @@ -206,7 +206,7 @@ get_pattern(const Filename &filename) { return (*ptf).second; } - string fn = filename.to_os_specific(); + std::string fn = filename.to_os_specific(); int id = arLoadPatt(fn.c_str()); if (id < 0) { vision_cat.error() << "Could not load AR ToolKit Pattern: " << fn << "\n"; diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index e6deea17ea..58c233232a 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -43,7 +43,7 @@ TypeHandle OpenCVTexture::_type_handle; * Sets up the texture to read frames from a camera */ OpenCVTexture:: -OpenCVTexture(const string &name) : +OpenCVTexture(const std::string &name) : VideoTexture(name) { } @@ -70,7 +70,7 @@ consider_update() { } else { // Loop through the pages to see if there's any camera stream to update. Texture::CDWriter cdata(Texture::_cycler, false); - int max_z = max(cdata->_z_size, (int)_pages.size()); + int max_z = std::max(cdata->_z_size, (int)_pages.size()); for (int z = 0; z < max_z; ++z) { VideoPage &page = _pages[z]; if (!page._color.is_from_file() || !page._alpha.is_from_file()) { @@ -98,7 +98,7 @@ make_copy_impl() const { Texture::CDWriter cdata_copy_tex(copy->Texture::_cycler, true); copy->do_assign(cdata_copy_tex, this, cdata_tex); - return copy.p(); + return copy; } /** @@ -258,7 +258,7 @@ make_texture() { */ void OpenCVTexture:: do_update_frame(Texture::CData *cdata, int frame) { - int max_z = max(cdata->_z_size, (int)_pages.size()); + int max_z = std::max(cdata->_z_size, (int)_pages.size()); for (int z = 0; z < max_z; ++z) { do_update_frame(cdata, frame, z); } @@ -446,7 +446,7 @@ do_read_one(Texture::CData *cdata, */ bool OpenCVTexture:: do_load_one(Texture::CData *cdata, - const PNMImage &pnmimage, const string &name, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options) { if (z <= (int)_pages.size()) { VideoPage &page = do_modify_page(cdata, z); @@ -581,7 +581,7 @@ bool OpenCVTexture::VideoStream:: read(const Filename &filename) { clear(); - string os_specific = filename.to_os_specific(); + std::string os_specific = filename.to_os_specific(); _capture = cvCaptureFromFile(os_specific.c_str()); if (_capture == nullptr) { return false; diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 853f3e070f..95565f9428 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -30,7 +30,7 @@ extern "C" { TypeHandle WebcamVideoCursorV4L::_type_handle; -#define clamp(x) min(max(x, 0.0), 255.0) +#define clamp(x) std::min(std::max(x, 0.0), 255.0) INLINE static void yuv_to_bgr(unsigned char *dest, const unsigned char *src) { double y1 = (255 / 219.0) * (src[0] - 16); diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 79510cf24d..531328b206 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -58,6 +58,9 @@ #include #include +using std::cerr; +using std::string; + /* * This used to work back when qedit.h still existed. The hacks served to * prevent it from including the defunct dxtrans.h. #pragma include_alias( diff --git a/panda/src/vision/webcamVideoOpenCV.cxx b/panda/src/vision/webcamVideoOpenCV.cxx index d4c68070fa..e7cadf8c69 100644 --- a/panda/src/vision/webcamVideoOpenCV.cxx +++ b/panda/src/vision/webcamVideoOpenCV.cxx @@ -46,7 +46,7 @@ WebcamVideoOpenCV:: WebcamVideoOpenCV(int camera_index) : _camera_index(camera_index) { - ostringstream strm; + std::ostringstream strm; strm << "OpenCV webcam " << _camera_index; set_name(strm.str()); } diff --git a/panda/src/vision/webcamVideoV4L.cxx b/panda/src/vision/webcamVideoV4L.cxx index 7d5636f4e0..bc6cad7a1b 100644 --- a/panda/src/vision/webcamVideoV4L.cxx +++ b/panda/src/vision/webcamVideoV4L.cxx @@ -94,7 +94,7 @@ TypeHandle WebcamVideoV4L::_type_handle; * */ void WebcamVideoV4L:: -add_options_for_size(int fd, const string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat) { +add_options_for_size(int fd, const std::string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat) { struct v4l2_frmivalenum frmivalenum; for (int k = 0;; k++) { memset(&frmivalenum, 0, sizeof frmivalenum); @@ -132,7 +132,7 @@ add_options_for_size(int fd, const string &dev, const char *name, unsigned width wc->_size_y = height; wc->_fps = fps; wc->_pformat = pixelformat; - wc->_pixel_format = string((char*) &pixelformat, 4); + wc->_pixel_format = std::string((char*) &pixelformat, 4); WebcamVideoV4L::_all_webcams.push_back(DCAST(WebcamVideo, wc)); } diff --git a/panda/src/vrpn/vrpnAnalog.cxx b/panda/src/vrpn/vrpnAnalog.cxx index 0934f7a8d8..d0d1b773ca 100644 --- a/panda/src/vrpn/vrpnAnalog.cxx +++ b/panda/src/vrpn/vrpnAnalog.cxx @@ -24,7 +24,7 @@ * */ VrpnAnalog:: -VrpnAnalog(const string &analog_name, vrpn_Connection *connection) : +VrpnAnalog(const std::string &analog_name, vrpn_Connection *connection) : _analog_name(analog_name) { _analog = new vrpn_Analog_Remote(_analog_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnAnalogDevice *device) { * */ void VrpnAnalog:: -output(ostream &out) const { +output(std::ostream &out) const { out << _analog_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnAnalog:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_analog_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnAnalogDevice.cxx b/panda/src/vrpn/vrpnAnalogDevice.cxx index 00da1a2240..101f097c52 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.cxx +++ b/panda/src/vrpn/vrpnAnalogDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnAnalogDevice::_type_handle; * */ VrpnAnalogDevice:: -VrpnAnalogDevice(VrpnClient *client, const string &device_name, +VrpnAnalogDevice(VrpnClient *client, const std::string &device_name, VrpnAnalog *vrpn_analog) : ClientAnalogDevice(client, device_name), _vrpn_analog(vrpn_analog) diff --git a/panda/src/vrpn/vrpnButton.cxx b/panda/src/vrpn/vrpnButton.cxx index cf17f6bade..71af239f88 100644 --- a/panda/src/vrpn/vrpnButton.cxx +++ b/panda/src/vrpn/vrpnButton.cxx @@ -24,7 +24,7 @@ * */ VrpnButton:: -VrpnButton(const string &button_name, vrpn_Connection *connection) : +VrpnButton(const std::string &button_name, vrpn_Connection *connection) : _button_name(button_name) { _button = new vrpn_Button_Remote(_button_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnButtonDevice *device) { * */ void VrpnButton:: -output(ostream &out) const { +output(std::ostream &out) const { out << _button_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnButton:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_button_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnButtonDevice.cxx b/panda/src/vrpn/vrpnButtonDevice.cxx index a392bbce49..eb287d2f5e 100644 --- a/panda/src/vrpn/vrpnButtonDevice.cxx +++ b/panda/src/vrpn/vrpnButtonDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnButtonDevice::_type_handle; * */ VrpnButtonDevice:: -VrpnButtonDevice(VrpnClient *client, const string &device_name, +VrpnButtonDevice(VrpnClient *client, const std::string &device_name, VrpnButton *vrpn_button) : ClientButtonDevice(client, device_name), _vrpn_button(vrpn_button) diff --git a/panda/src/vrpn/vrpnClient.cxx b/panda/src/vrpn/vrpnClient.cxx index 068d7614a0..1fb7fcb4ff 100644 --- a/panda/src/vrpn/vrpnClient.cxx +++ b/panda/src/vrpn/vrpnClient.cxx @@ -26,6 +26,8 @@ #include "string_utils.h" #include "indent.h" +using std::string; + TypeHandle VrpnClient::_type_handle; /** @@ -63,7 +65,7 @@ VrpnClient:: * polling each frame. */ void VrpnClient:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "VrpnClient, server " << _server_name << "\n"; diff --git a/panda/src/vrpn/vrpnDial.cxx b/panda/src/vrpn/vrpnDial.cxx index 57de1bd59c..5c06f797ee 100644 --- a/panda/src/vrpn/vrpnDial.cxx +++ b/panda/src/vrpn/vrpnDial.cxx @@ -24,7 +24,7 @@ * */ VrpnDial:: -VrpnDial(const string &dial_name, vrpn_Connection *connection) : +VrpnDial(const std::string &dial_name, vrpn_Connection *connection) : _dial_name(dial_name) { _dial = new vrpn_Dial_Remote(_dial_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnDialDevice *device) { * */ void VrpnDial:: -output(ostream &out) const { +output(std::ostream &out) const { out << _dial_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnDial:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_dial_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnDialDevice.cxx b/panda/src/vrpn/vrpnDialDevice.cxx index 77be871f73..6331fb8a02 100644 --- a/panda/src/vrpn/vrpnDialDevice.cxx +++ b/panda/src/vrpn/vrpnDialDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnDialDevice::_type_handle; * */ VrpnDialDevice:: -VrpnDialDevice(VrpnClient *client, const string &device_name, +VrpnDialDevice(VrpnClient *client, const std::string &device_name, VrpnDial *vrpn_dial) : ClientDialDevice(client, device_name), _vrpn_dial(vrpn_dial) diff --git a/panda/src/vrpn/vrpnTracker.cxx b/panda/src/vrpn/vrpnTracker.cxx index 6427c6c392..6e4e196769 100644 --- a/panda/src/vrpn/vrpnTracker.cxx +++ b/panda/src/vrpn/vrpnTracker.cxx @@ -24,7 +24,7 @@ * */ VrpnTracker:: -VrpnTracker(const string &tracker_name, vrpn_Connection *connection) : +VrpnTracker(const std::string &tracker_name, vrpn_Connection *connection) : _tracker_name(tracker_name) { _tracker = new vrpn_Tracker_Remote(_tracker_name.c_str(), connection); @@ -76,7 +76,7 @@ unmark(VrpnTrackerDevice *device) { * */ void VrpnTracker:: -output(ostream &out) const { +output(std::ostream &out) const { out << _tracker_name; } @@ -84,7 +84,7 @@ output(ostream &out) const { * */ void VrpnTracker:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_tracker_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnTrackerDevice.cxx b/panda/src/vrpn/vrpnTrackerDevice.cxx index 5484df2c23..980f9cf77c 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.cxx +++ b/panda/src/vrpn/vrpnTrackerDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnTrackerDevice::_type_handle; * */ VrpnTrackerDevice:: -VrpnTrackerDevice(VrpnClient *client, const string &device_name, +VrpnTrackerDevice(VrpnClient *client, const std::string &device_name, int sensor, VrpnTrackerDevice::DataType data_type, VrpnTracker *vrpn_tracker) : ClientTrackerDevice(client, device_name), diff --git a/panda/src/vrpn/vrpn_interface.h b/panda/src/vrpn/vrpn_interface.h index e3626e9055..a788d7ae73 100644 --- a/panda/src/vrpn/vrpn_interface.h +++ b/panda/src/vrpn/vrpn_interface.h @@ -19,7 +19,6 @@ #ifdef CPPPARSER // For correct interrogate parsing of UNC's vrpn library. #if defined(WIN32_VC) || defined(WIN64_VC) - #define _WIN32 #define SOCKET int #else #define linux diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 868ff727b2..aacedf0ae3 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -28,7 +28,7 @@ TypeHandle wglGraphicsBuffer::_type_handle; */ wglGraphicsBuffer:: wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index abffe1e1ee..4186c35a35 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -22,6 +22,7 @@ TypeHandle wglGraphicsPipe::_type_handle; bool wglGraphicsPipe::_current_valid; HDC wglGraphicsPipe::_current_hdc; HGLRC wglGraphicsPipe::_current_hglrc; +Thread *wglGraphicsPipe::_current_thread; /** * @@ -41,16 +42,19 @@ wglGraphicsPipe:: /** * a thin wrapper around wglMakeCurrent to avoid unnecessary OS-call overhead. */ -void wglGraphicsPipe:: +bool wglGraphicsPipe:: wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { + Thread *thread = Thread::get_current_thread(); if ((_current_valid) && (_current_hdc == hdc) && - (_current_hglrc == hglrc)) { - return; + (_current_hglrc == hglrc) && + (_current_thread == thread)) { + return true; } _current_valid = true; _current_hdc = hdc; _current_hglrc = hglrc; + _current_thread = thread; BOOL res; if (collector) { PStatTimer timer(*collector); @@ -58,6 +62,7 @@ wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { } else { res = wglMakeCurrent(hdc, hglrc); } + return (res != 0); } /** @@ -66,7 +71,7 @@ wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string wglGraphicsPipe:: +std::string wglGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -85,7 +90,7 @@ pipe_constructor() { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) wglGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -232,7 +237,7 @@ make_callback_gsg(GraphicsEngine *engine) { /** * Returns pfd_flags formatted as a string in a user-friendly way. */ -string wglGraphicsPipe:: +std::string wglGraphicsPipe:: format_pfd_flags(DWORD pfd_flags) { struct FlagDef { DWORD flag; @@ -255,7 +260,7 @@ format_pfd_flags(DWORD pfd_flags) { }; static const int num_flag_defs = sizeof(flag_def) / sizeof(FlagDef); - ostringstream out; + std::ostringstream out; const char *sep = ""; bool got_any = false; @@ -269,7 +274,7 @@ format_pfd_flags(DWORD pfd_flags) { } if (pfd_flags != 0 || !got_any) { - out << sep << hex << "0x" << pfd_flags << dec; + out << sep << std::hex << "0x" << pfd_flags << std::dec; } return out.str(); diff --git a/panda/src/wgldisplay/wglGraphicsPipe.h b/panda/src/wgldisplay/wglGraphicsPipe.h index 176483f92c..49ff95cd5a 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.h +++ b/panda/src/wgldisplay/wglGraphicsPipe.h @@ -46,11 +46,12 @@ protected: private: static std::string format_pfd_flags(DWORD pfd_flags); - static void wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector); + static bool wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector); static bool _current_valid; static HDC _current_hdc; static HGLRC _current_hglrc; + static Thread *_current_thread; public: static TypeHandle get_class_type() { diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 0d6f78ae1c..735f7fc409 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -319,7 +319,12 @@ choose_pixel_format(const FrameBufferProperties &properties, return; } - wglGraphicsPipe::wgl_make_current(twindow_dc, twindow_ctx, nullptr); + if (!wglGraphicsPipe::wgl_make_current(twindow_dc, twindow_ctx, nullptr)) { + wgldisplay_cat.error() + << "Failed to make WGL context current.\n"; + wglDeleteContext(twindow_ctx); + return; + } _extensions.clear(); save_extensions((const char *)GLP(GetString)(GL_EXTENSIONS)); @@ -395,7 +400,7 @@ choose_pixel_format(const FrameBufferProperties &properties, max_pformats, pformat, (unsigned int *)&nformats)) { nformats = 0; } - nformats = min(nformats, max_pformats); + nformats = std::min(nformats, max_pformats); if (wgldisplay_cat.is_debug()) { wgldisplay_cat.debug() @@ -706,7 +711,7 @@ make_twindow() { if (!_twindow) { wgldisplay_cat.error() - << "CreateWindow() failed!" << endl; + << "CreateWindow() failed!" << std::endl; return false; } @@ -764,7 +769,7 @@ register_twindow_class() { if (!RegisterClass(&wc)) { wgldisplay_cat.error() - << "could not register window class!" << endl; + << "could not register window class!" << std::endl; return; } _twindow_class_registered = true; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index fcba0b8bf4..6ff5b88c36 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -28,7 +28,7 @@ TypeHandle wglGraphicsWindow::_type_handle; */ wglGraphicsWindow:: wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -79,7 +79,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { HGLRC context = wglgsg->get_context(_hdc); nassertr(context, false); - wglGraphicsPipe::wgl_make_current(_hdc, context, &_make_current_pcollector); + if (!wglGraphicsPipe::wgl_make_current(_hdc, context, &_make_current_pcollector)) { + wgldisplay_cat.error() + << "Failed to make WGL context current.\n"; + return false; + } wglgsg->reset_if_new(); if (mode == FM_render) { @@ -386,7 +390,7 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { wgldisplay_cat.debug() << msg << ", " << OGLDrvStrings[drvtype] << " driver\n" - << "PFD flags: 0x" << hex << pfd->dwFlags << dec << " (" + << "PFD flags: 0x" << std::hex << pfd->dwFlags << std::dec << " (" << PRINT_FLAG(GENERIC_ACCELERATED) << PRINT_FLAG(GENERIC_FORMAT) << PRINT_FLAG(DOUBLEBUFFER) @@ -403,15 +407,15 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { << PRINT_FLAG(SUPPORT_DIRECTDRAW) << ")\n" << "PFD iPixelType: " << ((pfd->iPixelType==PFD_TYPE_RGBA) ? "PFD_TYPE_RGBA":"PFD_TYPE_COLORINDEX") - << endl + << std::endl << "PFD cColorBits: " << (DWORD)pfd->cColorBits << " R: " << (DWORD)pfd->cRedBits <<" G: " << (DWORD)pfd->cGreenBits - <<" B: " << (DWORD)pfd->cBlueBits << endl + <<" B: " << (DWORD)pfd->cBlueBits << std::endl << "PFD cAlphaBits: " << (DWORD)pfd->cAlphaBits << " DepthBits: " << (DWORD)pfd->cDepthBits <<" StencilBits: " << (DWORD)pfd->cStencilBits <<" AccumBits: " << (DWORD)pfd->cAccumBits - << endl; + << std::endl; } #endif diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index bd8244e880..954d8aca41 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -37,6 +37,9 @@ // Not used on Windows XP, but we still need to define it. #define TOUCH_COORD_TO_PIXEL(l) ((l) / 100) +using std::endl; +using std::wstring; + DECLARE_HANDLE(HTOUCHINPUT); #endif @@ -82,7 +85,7 @@ static PFN_CLOSETOUCHINPUTHANDLE pCloseTouchInputHandle = 0; */ WinGraphicsWindow:: WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -117,6 +120,30 @@ WinGraphicsWindow:: } } +/** + * Returns the MouseData associated with the nth input device's pointer. + */ +MouseData WinGraphicsWindow:: +get_pointer(int device) const { + MouseData result; + { + LightMutexHolder holder(_input_lock); + nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData()); + + result = _input_devices[device].get_pointer(); + + // We recheck this immediately to get the most up-to-date value. + POINT cpos; + if (device == 0 && result._in_window && GetCursorPos(&cpos) && ScreenToClient(_hWnd, &cpos)) { + double time = ClockObject::get_global_clock()->get_real_time(); + result._xpos = cpos.x; + result._ypos = cpos.y; + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); + } + } + return result; +} + /** * Forces the pointer to the indicated position within the window, if * possible. @@ -257,7 +284,7 @@ set_properties_now(WindowProperties &properties) { } if (properties.has_title()) { - string title = properties.get_title(); + std::string title = properties.get_title(); _properties.set_title(title); TextEncoder encoder; wstring title_w = encoder.decode_text(title); @@ -1359,7 +1386,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // This is a message from the system indicating that the user has // requested to close the window (e.g. alt-f4). { - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the // request and process it directly. @@ -1724,8 +1751,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { size_t num_chars = result_size / sizeof(wchar_t); _input_devices[0].candidate(wstring(ime_buffer, num_chars), - min(cursor_pos, delta_start), - max(cursor_pos, delta_start), + std::min(cursor_pos, delta_start), + std::max(cursor_pos, delta_start), cursor_pos); } ImmReleaseContext(hwnd, hIMC); @@ -2829,7 +2856,7 @@ register_window_class(const WindowProperties &props) { wclass_name << L"WinGraphicsWindow" << _window_class_index; wcreg._name = wclass_name.str(); - pair found = _window_classes.insert(wcreg); + std::pair found = _window_classes.insert(wcreg); const WindowClass &wclass = (*found.first); if (!found.second) { diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index ffcbc79553..ff0340aa0d 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -72,6 +72,7 @@ public: GraphicsOutput *host); virtual ~WinGraphicsWindow(); + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual void close_ime(); diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index 494da180da..2348d58706 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -33,12 +33,12 @@ LightReMutex x11GraphicsPipe::_x_mutex; * */ x11GraphicsPipe:: -x11GraphicsPipe(const string &display) : +x11GraphicsPipe(const std::string &display) : _have_xrandr(false), _xcursor_size(-1), _XF86DGADirectVideo(nullptr) { - string display_spec = display; + std::string display_spec = display; if (display_spec.empty()) { display_spec = display_cfg; } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 5fb290e315..17f6ca0a2a 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -38,6 +38,10 @@ #include #endif +using std::istream; +using std::ostringstream; +using std::string; + struct _XcursorFile { void *closure; int (*read)(XcursorFile *, unsigned char *, int); @@ -132,13 +136,48 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ x11GraphicsWindow:: ~x11GraphicsWindow() { - pmap::iterator it; - - for (it = _cursor_filenames.begin(); it != _cursor_filenames.end(); it++) { - XFreeCursor(_display, it->second); + if (!_cursor_filenames.empty()) { + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + for (auto item : _cursor_filenames) { + XFreeCursor(_display, item.second); + } } } +/** + * Returns the MouseData associated with the nth input device's pointer. This + * is deprecated; use get_pointer_device().get_pointer() instead, or for raw + * mice, use the InputDeviceManager interface. + */ +MouseData x11GraphicsWindow:: +get_pointer(int device) const { + MouseData result; + { + LightMutexHolder holder(_input_lock); + nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData()); + + result = _input_devices[device].get_pointer(); + + // We recheck this immediately to get the most up-to-date value, but we + // won't bother waiting for the lock if we can't. + if (device == 0 && !_dga_mouse_enabled && result._in_window && + x11GraphicsPipe::_x_mutex.try_lock()) { + XEvent event; + if (_xwindow != None && + XQueryPointer(_display, _xwindow, &event.xbutton.root, + &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, + &event.xbutton.x, &event.xbutton.y, &event.xbutton.state)) { + double time = ClockObject::get_global_clock()->get_real_time(); + result._xpos = event.xbutton.x; + result._ypos = event.xbutton.y; + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer_in_window(result._xpos, result._ypos, time); + } + x11GraphicsPipe::_x_mutex.release(); + } + } + return result; +} + /** * Forces the pointer to the indicated position within the window, if * possible. @@ -163,6 +202,7 @@ move_pointer(int device, int x, int y) { const MouseData &md = _input_devices[0].get_pointer(); if (!md.get_in_window() || md.get_x() != x || md.get_y() != y) { if (!_dga_mouse_enabled) { + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); XWarpPointer(_display, None, _xwindow, 0, 0, 0, 0, x, y); } _input_devices[0].set_pointer_in_window(x, y); @@ -170,7 +210,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); @@ -498,6 +538,8 @@ set_properties_now(WindowProperties &properties) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + // We're either going into or out of fullscreen, or are in fullscreen and // are changing the resolution. bool is_fullscreen = _properties.has_fullscreen() && _properties.get_fullscreen(); @@ -824,6 +866,7 @@ close_window() { _gsg.clear(); } + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); if (_ic != (XIC)nullptr) { XDestroyIC(_ic); _ic = (XIC)nullptr; @@ -882,6 +925,9 @@ open_window() { _properties.set_size(100, 100); } + // Make sure we are not making X11 calls from other threads. + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + if (_properties.get_fullscreen() && x11_pipe->_have_xrandr) { XRRScreenConfiguration* conf = _XRRGetScreenInfo(_display, x11_pipe->get_root()); if (_orig_size_id == (SizeID) -1) { @@ -1025,6 +1071,8 @@ open_window() { * If already_mapped is true, the window has already been mapped (manifested) * on the display. This means we may need to use a different action in some * cases. + * + * Assumes the X11 lock is held. */ void x11GraphicsWindow:: set_wm_properties(const WindowProperties &properties, bool already_mapped) { @@ -1348,9 +1396,7 @@ open_raw_mice() { void x11GraphicsWindow:: poll_raw_mice() { #ifdef PHAVE_LINUX_INPUT_H - for (int di = 0; di < _mouse_device_info.size(); ++di) { - MouseDeviceInfo &inf = _mouse_device_info[di]; - + for (MouseDeviceInfo &inf : _mouse_device_info) { // Read all bytes into buffer. if (inf._fd >= 0) { while (1) { @@ -1912,7 +1958,7 @@ map_button(KeySym key) const { } if (x11display_cat.is_debug()) { x11display_cat.debug() - << "Unrecognized keysym 0x" << hex << key << dec << "\n"; + << "Unrecognized keysym 0x" << std::hex << key << std::dec << "\n"; } return ButtonHandle::none(); } @@ -2147,7 +2193,13 @@ get_cursor(const Filename &filename) { << "Could not read from cursor file " << filename << "\n"; return None; } - str->seekg(0, istream::beg); + + // Put back the read bytes. Do not use seekg, because this will + // corrupt the stream if it points to encrypted/compressed file + str->putback(magic[3]); + str->putback(magic[2]); + str->putback(magic[1]); + str->putback(magic[0]); X11_Cursor h = None; if (memcmp(magic, "Xcur", 4) == 0) { diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 46b93225dd..078b016262 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -34,6 +34,7 @@ public: GraphicsOutput *host); virtual ~x11GraphicsWindow(); + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 4694e89217..d04c1d55ad 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -41,6 +41,10 @@ #include "postprocess.h" +using std::ostringstream; +using std::stringstream; +using std::string; + struct BoneWeight { CPT(JointVertexTransform) joint_vertex_xform; float weight; @@ -99,9 +103,34 @@ bool AssimpLoader:: read(const Filename &filename) { _filename = filename; - // I really don't know why we need to flip the winding order, but otherwise - // the models I tested with are showing inside out. - _scene = _importer.ReadFile(_filename.c_str(), aiProcess_Triangulate | aiProcess_GenUVCoords | aiProcess_FlipWindingOrder); + unsigned int flags = aiProcess_Triangulate | aiProcess_GenUVCoords; + + if (assimp_calc_tangent_space) { + flags |= aiProcess_CalcTangentSpace; + } + if (assimp_join_identical_vertices) { + flags |= aiProcess_JoinIdenticalVertices; + } + if (assimp_improve_cache_locality) { + flags |= aiProcess_ImproveCacheLocality; + } + if (assimp_remove_redundant_materials) { + flags |= aiProcess_RemoveRedundantMaterials; + } + if (assimp_fix_infacing_normals) { + flags |= aiProcess_FixInfacingNormals; + } + if (assimp_optimize_meshes) { + flags |= aiProcess_OptimizeMeshes; + } + if (assimp_optimize_graph) { + flags |= aiProcess_OptimizeGraph; + } + if (assimp_flip_winding_order) { + flags |= aiProcess_FlipWindingOrder; + } + + _scene = _importer.ReadFile(_filename.c_str(), flags); if (_scene == nullptr) { _error = true; return false; diff --git a/pandatool/src/assimp/config_assimp.cxx b/pandatool/src/assimp/config_assimp.cxx index 6e7dfcfe86..2dbf29fa16 100644 --- a/pandatool/src/assimp/config_assimp.cxx +++ b/pandatool/src/assimp/config_assimp.cxx @@ -25,6 +25,50 @@ ConfigureFn(config_assimp) { init_libassimp(); } +ConfigVariableBool assimp_calc_tangent_space +("assimp-calc-tangent-space", false, + PRC_DESC("Calculates tangents and binormals for meshes imported via Assimp.")); + +ConfigVariableBool assimp_join_identical_vertices +("assimp-join-identical-vertices", true, + PRC_DESC("Merges duplicate vertices. Set this to false if you want each " + "vertex to only be in use on one triangle.")); + +ConfigVariableBool assimp_improve_cache_locality +("assimp-improve-cache-locality", true, + PRC_DESC("Improves rendering performance of the loaded meshes by reordering " + "triangles for better vertex cache locality. Set this to false if " + "you need geometry to be loaded in the exact order that it was " + "specified in the file, or to improve load performance.")); + +ConfigVariableBool assimp_remove_redundant_materials +("assimp-remove-redundant-materials", true, + PRC_DESC("Removes redundant/unreferenced materials from assets.")); + +ConfigVariableBool assimp_fix_infacing_normals +("assimp-fix-infacing-normals", false, + PRC_DESC("Determines which normal vectors are facing inward and inverts them " + "so that they are facing outward.")); + +ConfigVariableBool assimp_optimize_meshes +("assimp-optimize-meshes", true, + PRC_DESC("Removes the number of draw calls by unifying geometry with the same " + "materials. Especially effective in conjunction with " + "assimp-optimize-graph and assimp-remove-redundant-materials.")); + +ConfigVariableBool assimp_optimize_graph +("assimp-optimize-graph", false, + PRC_DESC("Optimizes the scene geometry by flattening the scene hierarchy. " + "This is very efficient (combined with assimp-optimize-meshes), but " + "it may result the hierarchy to become lost, so it is disabled by " + "default.")); + +ConfigVariableBool assimp_flip_winding_order +("assimp-flip-winding-order", false, + PRC_DESC("Set this true to flip the winding order of all models loaded via " + "the Assimp loader. Note that you may need to clear the model-cache " + "after changing this.")); + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/pandatool/src/assimp/config_assimp.h b/pandatool/src/assimp/config_assimp.h index 7ca6a98094..16efc8a754 100644 --- a/pandatool/src/assimp/config_assimp.h +++ b/pandatool/src/assimp/config_assimp.h @@ -15,12 +15,21 @@ #define CONFIG_ASSIMP_H #include "pandatoolbase.h" - +#include "configVariableBool.h" #include "dconfig.h" ConfigureDecl(config_assimp, EXPCL_ASSIMP, EXPTP_ASSIMP); NotifyCategoryDecl(assimp, EXPCL_ASSIMP, EXPTP_ASSIMP); +extern ConfigVariableBool assimp_calc_tangent_space; +extern ConfigVariableBool assimp_join_identical_vertices; +extern ConfigVariableBool assimp_improve_cache_locality; +extern ConfigVariableBool assimp_remove_redundant_materials; +extern ConfigVariableBool assimp_fix_infacing_normals; +extern ConfigVariableBool assimp_optimize_meshes; +extern ConfigVariableBool assimp_optimize_graph; +extern ConfigVariableBool assimp_flip_winding_order; + extern EXPCL_ASSIMP void init_libassimp(); #endif diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx index 3f344b2674..73c27ee7d4 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx +++ b/pandatool/src/assimp/loaderFileTypeAssimp.cxx @@ -15,6 +15,8 @@ #include "config_assimp.h" #include "assimpLoader.h" +using std::string; + TypeHandle LoaderFileTypeAssimp::_type_handle; /** diff --git a/pandatool/src/assimp/pandaIOStream.cxx b/pandatool/src/assimp/pandaIOStream.cxx index e4dde48e79..ad610d608f 100644 --- a/pandatool/src/assimp/pandaIOStream.cxx +++ b/pandatool/src/assimp/pandaIOStream.cxx @@ -13,12 +13,13 @@ #include "pandaIOStream.h" +using std::ios; /** * */ PandaIOStream:: -PandaIOStream(istream &stream) : _istream(stream) { +PandaIOStream(std::istream &stream) : _istream(stream) { } /** @@ -26,9 +27,9 @@ PandaIOStream(istream &stream) : _istream(stream) { */ size_t PandaIOStream:: FileSize() const { - streampos cur = _istream.tellg(); + std::streampos cur = _istream.tellg(); _istream.seekg(0, ios::end); - streampos end = _istream.tellg(); + std::streampos end = _istream.tellg(); _istream.seekg(cur, ios::beg); return end; } diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index ff400bd285..87dea240d2 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -72,7 +72,7 @@ Open(const char *file, const char *mode) { Filename fn = Filename::from_os_specific(file); if (mode[0] == 'r') { - istream *stream = _vfs->open_read_file(file, true); + std::istream *stream = _vfs->open_read_file(file, true); if (stream == nullptr) { return nullptr; } diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx index bda00908a5..a30a5066dd 100644 --- a/pandatool/src/bam/bamInfo.cxx +++ b/pandatool/src/bam/bamInfo.cxx @@ -234,7 +234,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { strftime(time_buffer, 1024, "%c", localtime(&header->_start_time)); - pset recorders; + pset recorders; double last_timestamp = 0.0; for (size_t i = 1; i < objects.size(); i++) { @@ -256,7 +256,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { << " secs, " << objects.size() - 1 << " frames, " << time_buffer << ".\n" << "Recorders:"; - for (pset::iterator ni = recorders.begin(); + for (pset::iterator ni = recorders.begin(); ni != recorders.end(); ++ni) { nout << " " << (*ni); diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index 7522a70cc6..a7e760d29c 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -246,7 +246,7 @@ run() { if (_ctex_quality != "default") { // Override the user's config file with the command-line parameter for // texture compression. - string prc = "texture-quality-level " + _ctex_quality; + std::string prc = "texture-quality-level " + _ctex_quality; load_prc_file_data("prc", prc); } @@ -442,7 +442,7 @@ bool EggToBam:: make_buffer() { if (!_load_display.empty()) { // Override the user's config file with the command-line parameter. - string prc = "load-display " + _load_display; + std::string prc = "load-display " + _load_display; load_prc_file_data("prc", prc); } diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 538022bfbc..0059df8616 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -22,6 +22,8 @@ #include "string_utils.h" #include "config_egg2pg.h" +using std::string; + /** * */ @@ -71,7 +73,7 @@ run() { _num_points_expected = 0; _num_points_found = 0; _num_points_added = 0; - _decimate_factor = 1.0 / max(1.0, _decimate_divisor); + _decimate_factor = 1.0 / std::max(1.0, _decimate_divisor); _line_number = 0; _point_number = 0; _decimated_point_number = 0.0; @@ -215,7 +217,7 @@ close_vertex_data() { int num_vertices = _data->get_num_rows(); int vertices_so_far = 0; while (num_vertices > 0) { - int this_num_vertices = min(num_vertices, (int)egg_max_indices); + int this_num_vertices = std::min(num_vertices, (int)egg_max_indices); PT(GeomPrimitive) points = new GeomPoints(GeomEnums::UH_static); points->add_consecutive_vertices(vertices_so_far, this_num_vertices); geom->add_primitive(points); diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx index 1e1629fe1b..0f357883c8 100644 --- a/pandatool/src/converter/eggToSomethingConverter.cxx +++ b/pandatool/src/converter/eggToSomethingConverter.cxx @@ -54,9 +54,9 @@ set_egg_data(EggData *egg_data) { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string EggToSomethingConverter:: +std::string EggToSomethingConverter:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx index 58c914b7f5..8911021a0a 100644 --- a/pandatool/src/converter/somethingToEggConverter.cxx +++ b/pandatool/src/converter/somethingToEggConverter.cxx @@ -71,9 +71,9 @@ set_egg_data(EggData *egg_data) { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string SomethingToEggConverter:: +std::string SomethingToEggConverter:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index cc970748a0..17dd07eb66 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -17,6 +17,8 @@ #include "pnotify.h" #include +using std::string; + /** * */ diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.cxx b/pandatool/src/cvscopy/cvsSourceDirectory.cxx index 9ccacc3afd..0eb741044d 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.cxx +++ b/pandatool/src/cvscopy/cvsSourceDirectory.cxx @@ -17,6 +17,8 @@ #include "pnotify.h" +using std::string; + /** * */ diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index 69b483fa3c..8511afac6a 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -28,6 +28,8 @@ #include // for chdir #endif +using std::string; + bool CVSSourceTree::_got_start_fullpath = false; Filename CVSSourceTree::_start_fullpath; @@ -440,7 +442,7 @@ string CVSSourceTree:: prompt(const string &message) { nout << std::flush; while (true) { - cerr << message << std::flush; + std::cerr << message << std::flush; std::string response; std::getline(std::cin, response); diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index 3b98fa80a7..39aee067bd 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -76,7 +76,7 @@ bind_joints(JointMap &joint_map) { // Record the bind pose for each joint. for (size_t j = 0; j < num_joints; ++j) { const FCDSkinControllerJoint *skin_joint = _skin_controller->GetJoint(j); - string sid = FROM_FSTRING(skin_joint->GetId()); + std::string sid = FROM_FSTRING(skin_joint->GetId()); LMatrix4d bind_pose; bind_pose.invert_from(DAEToEggConverter::convert_matrix( skin_joint->GetBindPoseInverse())); @@ -126,7 +126,7 @@ adjust_joints(FCDSceneNode *node, const JointMap &joint_map, LMatrix4d this_transform = transform; if (node->IsJoint()) { - string sid = FROM_FSTRING(node->GetSubId()); + std::string sid = FROM_FSTRING(node->GetSubId()); JointMap::const_iterator ji = joint_map.find(sid); if (ji != joint_map.end()) { @@ -252,7 +252,7 @@ build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { return; } - string node_id = FROM_FSTRING(node->GetDaeId()); + std::string node_id = FROM_FSTRING(node->GetDaeId()); PT(EggTable) table = new EggTable(node_id); table->set_table_type(EggTable::TT_table); parent->add_child(table); diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 0c15fe819d..6aab105cc7 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -25,6 +25,9 @@ #include "filename.h" #include "string_utils.h" +using std::endl; +using std::string; + TypeHandle DaeMaterials::_type_handle; // luminance function, based on the ISOCIE color standards see ITU-R diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index f054643d7b..00c20a36da 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -48,6 +48,9 @@ #include "FCDocument/FCDGeometryPolygonsInput.h" #endif +using std::endl; +using std::string; + /** * */ diff --git a/pandatool/src/daeegg/pre_fcollada_include.h b/pandatool/src/daeegg/pre_fcollada_include.h index 18cbe7a45d..59ad054c2a 100644 --- a/pandatool/src/daeegg/pre_fcollada_include.h +++ b/pandatool/src/daeegg/pre_fcollada_include.h @@ -38,4 +38,8 @@ #define NO_LIBXML #define FCOLLADA_NOMINMAX +// FCollada does use global min/max. +using std::min; +using std::max; + #endif diff --git a/pandatool/src/daeprogs/daeToEgg.cxx b/pandatool/src/daeprogs/daeToEgg.cxx index c3ba781361..e00747344a 100644 --- a/pandatool/src/daeprogs/daeToEgg.cxx +++ b/pandatool/src/daeprogs/daeToEgg.cxx @@ -49,7 +49,7 @@ void DAEToEgg:: run() { if (_animation_convert != AC_both && _animation_convert != AC_none && _animation_convert != AC_chan && _animation_convert != AC_model) { - cerr << "Unsupported animation convert option.\n"; + std::cerr << "Unsupported animation convert option.\n"; exit(1); } diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index cc3d9facf4..b9652e698f 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -28,6 +28,8 @@ #define FROM_MAT4(v) (FMMatrix44(v.get_data())) #define FROM_FSTRING(fs) (fs.c_str()) +using std::cerr; + /** * */ diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index 0637c97d39..f5bb6e0912 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "virtualFileSystem.h" +using std::istream; +using std::ostream; +using std::string; + DXFFile::Color DXFFile::_colors[DXF_num_colors] = { { 1, 1, 1 }, // Color 0 is not used. { 1, 0, 0 }, // Color 1 = Red diff --git a/pandatool/src/dxf/dxfLayer.cxx b/pandatool/src/dxf/dxfLayer.cxx index 5ffc96a5cc..6803cc179e 100644 --- a/pandatool/src/dxf/dxfLayer.cxx +++ b/pandatool/src/dxf/dxfLayer.cxx @@ -18,7 +18,7 @@ * */ DXFLayer:: -DXFLayer(const string &name) : Namable(name) { +DXFLayer(const std::string &name) : Namable(name) { } /** diff --git a/pandatool/src/dxf/dxfLayerMap.cxx b/pandatool/src/dxf/dxfLayerMap.cxx index 447b27e8ca..d2049c8191 100644 --- a/pandatool/src/dxf/dxfLayerMap.cxx +++ b/pandatool/src/dxf/dxfLayerMap.cxx @@ -22,7 +22,7 @@ * this function to create a specialized time, if desired. */ DXFLayer *DXFLayerMap:: -get_layer(const string &name, DXFFile *dxffile) { +get_layer(const std::string &name, DXFFile *dxffile) { iterator lmi; lmi = find(name); if (lmi != end()) { diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx index 3620f96abd..6ba6411940 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.cxx +++ b/pandatool/src/dxfegg/dxfToEggConverter.cxx @@ -50,7 +50,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string DXFToEggConverter:: +std::string DXFToEggConverter:: get_name() const { return "DXF"; } @@ -58,7 +58,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string DXFToEggConverter:: +std::string DXFToEggConverter:: get_extension() const { return "dxf"; } @@ -92,7 +92,7 @@ convert_file(const Filename &filename) { * */ DXFLayer *DXFToEggConverter:: -new_layer(const string &name) { +new_layer(const std::string &name) { return new DXFToEggLayer(name, get_egg_data()); } diff --git a/pandatool/src/dxfegg/dxfToEggLayer.cxx b/pandatool/src/dxfegg/dxfToEggLayer.cxx index 333cd5a69e..3ecb915efb 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.cxx +++ b/pandatool/src/dxfegg/dxfToEggLayer.cxx @@ -26,7 +26,7 @@ * */ DXFToEggLayer:: -DXFToEggLayer(const string &name, EggGroupNode *parent) : DXFLayer(name) { +DXFToEggLayer(const std::string &name, EggGroupNode *parent) : DXFLayer(name) { _group = new EggGroup(name); parent->add_child(_group); _vpool = new EggVertexPool(name); diff --git a/pandatool/src/dxfprogs/eggToDXF.cxx b/pandatool/src/dxfprogs/eggToDXF.cxx index e3fb8a85d5..412b815601 100644 --- a/pandatool/src/dxfprogs/eggToDXF.cxx +++ b/pandatool/src/dxfprogs/eggToDXF.cxx @@ -52,7 +52,7 @@ run() { // uniquify_names("layer", _layers.begin(), _layers.end()); - ostream &out = get_output(); + std::ostream &out = get_output(); // Autodesk says we don't need the header, but some DXF-reading programs // might get confused if it's missing. We'll write an empty header. @@ -107,7 +107,7 @@ get_layers(EggGroupNode *group) { * gets written later, in write_entities(). */ void EggToDXF:: -write_tables(ostream &out) { +write_tables(std::ostream &out) { out << "0\nSECTION\n" << "2\nTABLES\n" // Begin TABLES section. << "0\nTABLE\n" @@ -127,7 +127,7 @@ write_tables(ostream &out) { * Writes out the "entities", e.g. polygons, defined for all layers. */ void EggToDXF:: -write_entities(ostream &out) { +write_entities(std::ostream &out) { out << "0\nSECTION\n" << "2\nENTITIES\n"; // Begin ENTITIES section. diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.cxx b/pandatool/src/dxfprogs/eggToDXFLayer.cxx index c10c51f862..6922f0b8a6 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.cxx +++ b/pandatool/src/dxfprogs/eggToDXFLayer.cxx @@ -19,6 +19,8 @@ #include "eggPolygon.h" #include "dcast.h" +using std::ostream; + /** * */ diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx index 8ae277126b..4efa4a5ad5 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.cxx +++ b/pandatool/src/egg-mkfont/eggMakeFont.cxx @@ -32,6 +32,8 @@ #include +using std::string; + /** * */ @@ -424,7 +426,7 @@ run() { _bg[0], _bg[1], _bg[2], _bg[3], _palette_size[0], _palette_size[1], 100.0 / _palettize_scale_factor); - istringstream txa_script(buffer); + std::istringstream txa_script(buffer); pal->read_txa_file(txa_script, "default script"); pal->all_params_set(); diff --git a/pandatool/src/egg-mkfont/rangeDescription.cxx b/pandatool/src/egg-mkfont/rangeDescription.cxx index bedfc086ea..2833f53359 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.cxx +++ b/pandatool/src/egg-mkfont/rangeDescription.cxx @@ -15,6 +15,8 @@ #include "string_utils.h" #include "pnotify.h" +using std::string; + /** * */ @@ -71,7 +73,7 @@ parse_parameter(const string ¶m) { * */ void RangeDescription:: -output(ostream &out) const { +output(std::ostream &out) const { bool first_time = true; RangeList::const_iterator ri; for (ri = _range_list.begin(); ri != _range_list.end(); ++ri) { diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index c7027ec9ec..182b657968 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -34,6 +34,10 @@ #include +using std::cout; +using std::setw; +using std::string; + /** * */ diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index e81290f06c..afa7fa00b7 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -696,7 +696,7 @@ run() { bool okflag = true; if (_got_txa_script) { - istringstream txa_script(_txa_script); + std::istringstream txa_script(_txa_script); pal->read_txa_file(txa_script, "command line"); } else { @@ -757,13 +757,13 @@ run() { // And process the egg files named for addition. bool all_eggs_valid = true; - string egg_comment = get_exec_command(); + std::string egg_comment = get_exec_command(); Eggs::const_iterator ei; for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) { EggData *egg_data = (*ei); Filename source_filename = egg_data->get_egg_filename(); Filename dest_filename = get_output_filename(source_filename); - string name = source_filename.get_basename(); + std::string name = source_filename.get_basename(); EggFile *egg_file = pal->get_egg_file(name); if (!egg_file->from_command_line(egg_data, source_filename, dest_filename, @@ -834,7 +834,7 @@ run() { // state file into place. We do this in case the user interrupts us (or // we core dump) before we're done; that way we won't leave the state file // incompletely written. - string dirname = state_filename.get_dirname(); + std::string dirname = state_filename.get_dirname(); if (dirname.empty()) { dirname = "."; } diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index 980dc7d114..f8c20cfb0c 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -52,7 +52,7 @@ post_load(Texture *tex) { } TextureImage tex_image; - string name = tex->get_filename().get_basename_wo_extension(); + std::string name = tex->get_filename().get_basename_wo_extension(); tex_image.set_name(name); SourceTextureImage *source = tex_image.get_source @@ -131,7 +131,7 @@ read_txa_file() { << "Filename " << filename << " not found.\n"; } else { filename.set_text(); - istream *ifile = vfs->open_read_file(filename, true); + std::istream *ifile = vfs->open_read_file(filename, true); if (ifile == nullptr) { txafile_cat.warning() << "Filename " << filename << " cannot be read.\n"; diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx index fea4d09344..37473557bf 100644 --- a/pandatool/src/egg-qtess/eggQtess.cxx +++ b/pandatool/src/egg-qtess/eggQtess.cxx @@ -155,9 +155,9 @@ run() { if (_total_tris != 0) { // Whatever number of triangles we have unaccounted for, assign to the // default bucket. - int extra_tris = max(0, _total_tris - num_tris); + int extra_tris = std::max(0, _total_tris - num_tris); if (read_qtess && default_entry.get_num_surfaces() != 0) { - cerr << extra_tris << " triangles unaccounted for.\n"; + std::cerr << extra_tris << " triangles unaccounted for.\n"; } default_entry.set_num_tris(extra_tris); @@ -180,13 +180,13 @@ run() { int tris = 0; - ostream &out = get_output(); + std::ostream &out = get_output(); Surfaces::const_iterator si; for (si = _surfaces.begin(); si != _surfaces.end(); ++si) { tris += (*si)->write_qtess_parameter(out); } - cerr << tris << " tris generated.\n"; + std::cerr << tris << " tris generated.\n"; } else { @@ -197,7 +197,7 @@ run() { tris += (*si)->tesselate(); } - cerr << tris << " tris generated.\n"; + std::cerr << tris << " tris generated.\n"; // Clear out the surfaces list before removing the vertices, since each // surface is holding reference counts to the previously-used vertices. diff --git a/pandatool/src/egg-qtess/isoPlacer.cxx b/pandatool/src/egg-qtess/isoPlacer.cxx index 25c7a38b0a..fda96904e3 100644 --- a/pandatool/src/egg-qtess/isoPlacer.cxx +++ b/pandatool/src/egg-qtess/isoPlacer.cxx @@ -82,7 +82,7 @@ get_scores(int subdiv, int across, double ratio, // non-equal points. double d = v1.dot(v2); - _cscore[i] += acos(max(min(d, 1.0), -1.0)); + _cscore[i] += acos(std::max(std::min(d, 1.0), -1.0)); } } } diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx index da7e940545..66df4c8813 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.cxx +++ b/pandatool/src/egg-qtess/qtessInputEntry.cxx @@ -21,6 +21,8 @@ #include #include +using std::string; + /** * */ @@ -354,7 +356,7 @@ count_tris(double tri_factor, int attempts) { * user control. */ void QtessInputEntry:: -output_extra(ostream &out, const pvector &iso, char axis) { +output_extra(std::ostream &out, const pvector &iso, char axis) { pvector::const_iterator di; int expect = 0; for (di = iso.begin(); di != iso.end(); ++di) { @@ -376,7 +378,7 @@ output_extra(ostream &out, const pvector &iso, char axis) { * */ void QtessInputEntry:: -output(ostream &out) const { +output(std::ostream &out) const { NodeNames::const_iterator nni; for (nni = _node_names.begin(); nni != _node_names.end(); @@ -458,6 +460,6 @@ output(ostream &out) const { * */ void QtessInputEntry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx index 850ad638f9..180a2e9547 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.cxx +++ b/pandatool/src/egg-qtess/qtessInputFile.cxx @@ -15,6 +15,8 @@ #include "config_egg_qtess.h" #include "string_utils.h" +using std::string; + /** * */ @@ -306,7 +308,7 @@ count_tris() { * */ void QtessInputFile:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { (*ei).write(out, indent_level); diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index 896fd68079..d7ccebe76f 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -23,6 +23,9 @@ #include "pset.h" #include "pmap.h" +using std::max; +using std::string; + /** * */ @@ -133,7 +136,7 @@ tesselate() { * should be tesselated uniformly. Returns the number of tris. */ int QtessSurface:: -write_qtess_parameter(ostream &out) { +write_qtess_parameter(std::ostream &out) { apply_match(); if (_tess_u == 0 || _tess_v == 0) { diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 1ebd65a28e..83d07a0a6a 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -20,6 +20,8 @@ #include "dcast.h" #include "string_utils.h" +using std::string; + /** * */ diff --git a/pandatool/src/eggbase/eggConverter.cxx b/pandatool/src/eggbase/eggConverter.cxx index a55d68856f..036b7dea18 100644 --- a/pandatool/src/eggbase/eggConverter.cxx +++ b/pandatool/src/eggbase/eggConverter.cxx @@ -21,8 +21,8 @@ * with a leading dot. */ EggConverter:: -EggConverter(const string &format_name, - const string &preferred_extension, +EggConverter(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggFilter(allow_last_param, allow_stdout), diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 87900624f6..981c8ad4cf 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -81,7 +81,7 @@ handle_args(ProgramBase::Args &args) { nout << "Error opening file: " << _input_filename << "\n"; return false; } - string line; + std::string line; // File should be a space-delimited list of egg files while (std::getline(input, line, ' ')) { args.push_back(line); diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index 428e07710a..16c5e2ad28 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -178,7 +178,7 @@ handle_args(ProgramBase::Args &args) { exit(1); } } else { - if (!file_data.read(cin)) { + if (!file_data.read(std::cin)) { exit(1); } } diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx index 3aa290ee32..eb6adc89e5 100644 --- a/pandatool/src/eggbase/eggToSomething.cxx +++ b/pandatool/src/eggbase/eggToSomething.cxx @@ -19,8 +19,8 @@ * just used in printing error messages and such. */ EggToSomething:: -EggToSomething(const string &format_name, - const string &preferred_extension, +EggToSomething(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggConverter(format_name, preferred_extension, allow_last_param, allow_stdout) @@ -34,7 +34,7 @@ EggToSomething(const string &format_name, add_runline("[opts] input.egg >output" + _preferred_extension); } - string o_description; + std::string o_description; if (_allow_stdout) { if (_allow_last_param) { diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx index 28365de2c1..c881991a08 100644 --- a/pandatool/src/eggbase/eggWriter.cxx +++ b/pandatool/src/eggbase/eggWriter.cxx @@ -47,7 +47,7 @@ EggWriter(bool allow_last_param, bool allow_stdout) : add_runline("[opts] >output.egg"); } - string o_description; + std::string o_description; if (_allow_stdout) { if (_allow_last_param) { diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 6c8017d988..45d705f12c 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -22,8 +22,8 @@ * just used in printing error messages and such. */ SomethingToEgg:: -SomethingToEgg(const string &format_name, - const string &preferred_extension, +SomethingToEgg(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggConverter(format_name, preferred_extension, allow_last_param, allow_stdout) { @@ -316,7 +316,7 @@ post_process_egg_file() { * specified parameter. var is a pointer to an AnimationConvert variable. */ bool SomethingToEgg:: -dispatch_animation_convert(const string &opt, const string &arg, void *var) { +dispatch_animation_convert(const std::string &opt, const std::string &arg, void *var) { AnimationConvert *ip = (AnimationConvert *)var; (*ip) = string_animation_convert(arg); if ((*ip) == AC_invalid) { diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx index aa4a95f73a..400d9e3b2f 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.cxx +++ b/pandatool/src/eggcharbase/eggBackPointer.cxx @@ -55,5 +55,5 @@ has_vertices() const { * Applies the indicated name change to the egg file. */ void EggBackPointer:: -set_name(const string &name) { +set_name(const std::string &name) { } diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx index 3dfa5aaee8..f90c7d9a91 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx +++ b/pandatool/src/eggcharbase/eggCharacterCollection.cxx @@ -29,6 +29,8 @@ #include +using std::string; + /** * @@ -626,7 +628,7 @@ rename_char(int i, const string &name) { * */ void EggCharacterCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Characters::const_iterator ci; for (ci = _characters.begin(); ci != _characters.end(); ++ci) { @@ -646,7 +648,7 @@ write(ostream &out, int indent_level) const { * initially different. */ void EggCharacterCollection:: -check_errors(ostream &out, bool force_initial_rest_frame) { +check_errors(std::ostream &out, bool force_initial_rest_frame) { Characters::const_iterator ci; for (ci = _characters.begin(); ci != _characters.end(); ++ci) { EggCharacterData *char_data = (*ci); diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx index 03cffa7d47..d3c7a54530 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.cxx +++ b/pandatool/src/eggcharbase/eggCharacterData.cxx @@ -63,7 +63,7 @@ EggCharacterData:: * as if they are expected to have the same skeleton hierarchy. */ void EggCharacterData:: -rename_char(const string &name) { +rename_char(const std::string &name) { Models::iterator mi; for (mi = _models.begin(); mi != _models.end(); ++mi) { (*mi)._model_root->set_name(name); @@ -107,7 +107,7 @@ get_num_frames(int model_index) const { // We have a winner. Assume all other components will be similar. return num_frames; } - max_num_frames = max(max_num_frames, num_frames); + max_num_frames = std::max(max_num_frames, num_frames); } // Every component had either 1 frame or 0 frames. Return the maximum of @@ -154,7 +154,7 @@ check_num_frames(int model_index) { // than 0 or 1), we have a discrepency. This is an error condition. any_violations = true; } - max_num_frames = max(max_num_frames, num_frames); + max_num_frames = std::max(max_num_frames, num_frames); } if (any_violations) { @@ -338,7 +338,7 @@ choose_optimal_hierarchy() { * name. */ EggSliderData *EggCharacterData:: -find_slider(const string &name) const { +find_slider(const std::string &name) const { SlidersByName::const_iterator si; si = _sliders_by_name.find(name); if (si != _sliders_by_name.end()) { @@ -353,7 +353,7 @@ find_slider(const string &name) const { * already, creates a new one. */ EggSliderData *EggCharacterData:: -make_slider(const string &name) { +make_slider(const std::string &name) { SlidersByName::const_iterator si; si = _sliders_by_name.find(name); if (si != _sliders_by_name.end()) { @@ -397,7 +397,7 @@ estimate_db_size() const { * */ void EggCharacterData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Character " << get_name() << ":\n"; get_root_joint()->write(out, indent_level + 2); diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx index 6a30bc4969..5af9dd3d57 100644 --- a/pandatool/src/eggcharbase/eggComponentData.cxx +++ b/pandatool/src/eggcharbase/eggComponentData.cxx @@ -53,7 +53,7 @@ EggComponentData:: * matched_name(). */ void EggComponentData:: -add_name(const string &name, NameUniquifier &uniquifier) { +add_name(const std::string &name, NameUniquifier &uniquifier) { if (_names.insert(name).second) { // This is a new name for this component. if (!has_name()) { @@ -71,7 +71,7 @@ add_name(const string &name, NameUniquifier &uniquifier) { * with this particular joint, false otherwise. */ bool EggComponentData:: -matches_name(const string &name) const { +matches_name(const std::string &name) const { if (name == get_name()) { return true; } diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 8197a1ec84..65ed9505a5 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -22,6 +22,8 @@ #include "fftCompressor.h" #include "zStream.h" +using std::string; + TypeHandle EggJointData::_type_handle; @@ -259,7 +261,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { #else // The FFTCompressor does minimal run-length encoding, but to really get an // accurate measure we should zlib-compress the resulting stream. - ostringstream sstr; + std::ostringstream sstr; OCompressStream zstr(&sstr, false); zstr.write((const char *)dg.get_data(), dg.get_length()); zstr.flush(); @@ -442,7 +444,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { * */ void EggJointData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Joint " << get_name() << " (models:"; diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index 4ab8a7227a..c9c891606b 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -192,7 +192,7 @@ has_vertices() const { * pointer to it. */ EggJointPointer *EggJointNodePointer:: -make_new_joint(const string &name) { +make_new_joint(const std::string &name) { EggGroup *new_joint = new EggGroup(name); new_joint->set_group_type(EggGroup::GT_joint); _joint->add_child(new_joint); @@ -203,6 +203,6 @@ make_new_joint(const string &name) { * Applies the indicated name change to the egg file. */ void EggJointNodePointer:: -set_name(const string &name) { +set_name(const std::string &name) { _joint->set_name(name); } diff --git a/pandatool/src/eggcharbase/eggJointPointer.cxx b/pandatool/src/eggcharbase/eggJointPointer.cxx index 350931d635..6a5ed44003 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.cxx +++ b/pandatool/src/eggcharbase/eggJointPointer.cxx @@ -69,7 +69,7 @@ expose(EggGroup::DCSType) { * Zeroes out the named components of the transform in the animation frames. */ void EggJointPointer:: -zero_channels(const string &) { +zero_channels(const std::string &) { } /** @@ -77,7 +77,7 @@ zero_channels(const string &) { * quantum. */ void EggJointPointer:: -quantize_channels(const string &, double) { +quantize_channels(const std::string &, double) { } /** diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index 130975fc0b..21c9c63516 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -17,6 +17,8 @@ #include "eggXfmAnimData.h" #include "eggXfmSAnim.h" +using std::string; + TypeHandle EggMatrixTablePointer::_type_handle; /** diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx index 18f4aaaf5c..450bb548ce 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx @@ -89,7 +89,7 @@ get_frame(int n) const { * Applies the indicated name change to the egg file. */ void EggScalarTablePointer:: -set_name(const string &name) { +set_name(const std::string &name) { // Actually, let's not rename the slider table (yet), because we haven't // written the code to rename all of the morph targets. diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx index 25bbae1140..91d041366f 100644 --- a/pandatool/src/eggcharbase/eggSliderData.cxx +++ b/pandatool/src/eggcharbase/eggSliderData.cxx @@ -88,7 +88,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { * */ void EggSliderData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Slider " << get_name() << " (models:"; diff --git a/pandatool/src/eggprogs/eggListTextures.cxx b/pandatool/src/eggprogs/eggListTextures.cxx index c804a8110b..fd44c73a48 100644 --- a/pandatool/src/eggprogs/eggListTextures.cxx +++ b/pandatool/src/eggprogs/eggListTextures.cxx @@ -48,10 +48,10 @@ run() { Filename fullpath = (*ti)->get_fullpath(); PNMImageHeader header; if (header.read_header(fullpath)) { - cout << fullpath.get_basename() << " : " + std::cout << fullpath.get_basename() << " : " << header.get_x_size() << " " << header.get_y_size() << "\n"; } else { - cout << fullpath.get_basename() << " : unknown\n"; + std::cout << fullpath.get_basename() << " : unknown\n"; } } } diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx index 0c522652e1..ba55d19b7f 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.cxx +++ b/pandatool/src/eggprogs/eggRetargetAnim.cxx @@ -97,7 +97,7 @@ run() { exit(1); } - string ref_name = col.get_character(0)->get_name(); + std::string ref_name = col.get_character(0)->get_name(); // Now rename all of the animations to the same name as the reference model, // and add the reference animation in to the same collection to match it up @@ -111,7 +111,7 @@ run() { EggCharacterData *char_data = _collection->get_character(0); nout << "Processing " << char_data->get_name() << "\n"; - typedef pset Names; + typedef pset Names; Names keep_names; vector_string::const_iterator si; @@ -133,7 +133,7 @@ run() { */ void EggRetargetAnim:: retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, - int reference_model, const pset &keep_names, + int reference_model, const pset &keep_names, EggCharacterDb &db) { if (keep_names.find(joint_data->get_name()) != keep_names.end()) { // Don't retarget this joint; keep the translation and scale and whatever. diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index bf7032230f..bb3350f02c 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -22,6 +22,8 @@ #include +using std::string; + /** * */ diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index a1f0a4d081..bafc37fde9 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -22,6 +22,9 @@ #include "eggBin.h" #include "string_utils.h" +using std::ostream; +using std::string; + /** * */ diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx index 4b0397e065..2a46431f25 100644 --- a/pandatool/src/eggprogs/eggTopstrip.cxx +++ b/pandatool/src/eggprogs/eggTopstrip.cxx @@ -185,14 +185,14 @@ run() { */ void EggTopstrip:: check_transform_channels() { - static string expected = "ijkphrxyz"; + static std::string expected = "ijkphrxyz"; static const int num_channels = 9; bool has_each[num_channels]; memset(has_each, 0, num_channels * sizeof(bool)); for (size_t p = 0; p < _transform_channels.size(); p++) { int i = expected.find(_transform_channels[p]); - if (i == (int)string::npos) { + if (i == (int)std::string::npos) { nout << "Invalid letter for -s: " << _transform_channels[p] << "\n"; exit(1); } @@ -235,7 +235,7 @@ strip_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_into_frames = char_data->get_num_frames(i); int num_from_frames = from_char->get_num_frames(model); - int num_frames = max(num_into_frames, num_from_frames); + int num_frames = std::max(num_into_frames, num_from_frames); EggBackPointer *back = joint_data->get_model(i); nassertv(back != nullptr); diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx index 32348d583e..4b6dc695a7 100644 --- a/pandatool/src/flt/fltBeadID.cxx +++ b/pandatool/src/flt/fltBeadID.cxx @@ -28,7 +28,7 @@ FltBeadID(FltHeader *header) : FltBead(header) { * Returns the id (name) of this particular bead. Each MultiGen bead will * have a unique name. */ -const string &FltBeadID:: +const std::string &FltBeadID:: get_id() const { return _id; } @@ -38,7 +38,7 @@ get_id() const { * is unique to this bead. */ void FltBeadID:: -set_id(const string &id) { +set_id(const std::string &id) { _id = id; } @@ -48,7 +48,7 @@ set_id(const string &id) { * flt file, use FltHeader::write_flt(). */ void FltBeadID:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (!_id.empty()) { out << " " << _id; diff --git a/pandatool/src/flt/fltError.cxx b/pandatool/src/flt/fltError.cxx index fe9cf918bb..b0b58ea6ae 100644 --- a/pandatool/src/flt/fltError.cxx +++ b/pandatool/src/flt/fltError.cxx @@ -13,8 +13,8 @@ #include "fltError.h" -ostream & -operator << (ostream &out, FltError error) { +std::ostream & +operator << (std::ostream &out, FltError error) { switch (error) { case FE_ok: return out << "no error"; diff --git a/pandatool/src/flt/fltExternalReference.cxx b/pandatool/src/flt/fltExternalReference.cxx index 1780e577ba..fa6aaa05f4 100644 --- a/pandatool/src/flt/fltExternalReference.cxx +++ b/pandatool/src/flt/fltExternalReference.cxx @@ -45,7 +45,7 @@ apply_converted_filenames() { * flt file, use FltHeader::write_flt(). */ void FltExternalReference:: -output(ostream &out) const { +output(std::ostream &out) const { out << "External " << get_ref_filename(); if (!_bead_id.empty()) { out << " (" << _bead_id << ")"; @@ -83,7 +83,7 @@ extract_record(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_external_ref, false); DatagramIterator &iterator = reader.get_iterator(); - string name = iterator.get_fixed_string(200); + std::string name = iterator.get_fixed_string(200); iterator.skip_bytes(1 + 1); iterator.skip_bytes(2); // Undocumented additional padding. _flags = iterator.get_be_uint32(); @@ -95,7 +95,7 @@ extract_record(FltRecordReader &reader) { if (!name.empty() && name[name.length() - 1] == '>') { // Extract out the bead name. size_t open = name.rfind('<'); - if (open != string::npos) { + if (open != std::string::npos) { _orig_filename = name.substr(0, open); _bead_id = name.substr(open + 1, name.length() - open - 2); } @@ -120,7 +120,7 @@ build_record(FltRecordWriter &writer) const { writer.set_opcode(FO_external_ref); Datagram &datagram = writer.update_datagram(); - string name = _orig_filename; + std::string name = _orig_filename; if (!_bead_id.empty()) { name += "<" + _bead_id + ">"; } diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index e6cd4dbd10..a08748637e 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -190,7 +190,7 @@ read_flt(Filename filename) { _flt_filename = filename; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { assert(!flt_error_abort); return FE_could_not_open; @@ -205,7 +205,7 @@ read_flt(Filename filename) { * Returns FE_ok on success, otherwise on failure. */ FltError FltHeader:: -read_flt(istream &in) { +read_flt(std::istream &in) { FltRecordReader reader(in); FltError result = reader.advance(); if (result == FE_end_of_file) { @@ -260,7 +260,7 @@ write_flt(Filename filename) { * Returns FE_ok on success, otherwise on failure. */ FltError FltHeader:: -write_flt(ostream &out) { +write_flt(std::ostream &out) { FltRecordWriter writer(out); FltError result = write_record_and_children(writer); @@ -600,14 +600,14 @@ has_color_name(int color_index) const { /** * Returns the name associated with the given color, if any. */ -string FltHeader:: +std::string FltHeader:: get_color_name(int color_index) const { ColorNames::const_iterator ni; ni = _color_names.find(color_index); if (ni != _color_names.end()) { return (*ni).second; } - return string(); + return std::string(); } /** @@ -836,7 +836,7 @@ add_material(FltMaterial *material) { } else { // Make sure our next generated material index will be different from any // existing material indices. - _next_material_index = max(_next_material_index, material->_material_index + 1); + _next_material_index = std::max(_next_material_index, material->_material_index + 1); } _materials[material->_material_index] = material; @@ -895,7 +895,7 @@ add_texture(FltTexture *texture) { } else { // Make sure our next generated pattern index will be different from any // existing texture indices. - _next_pattern_index = max(_next_pattern_index, texture->_pattern_index + 1); + _next_pattern_index = std::max(_next_pattern_index, texture->_pattern_index + 1); } _textures[texture->_pattern_index] = texture; @@ -1563,7 +1563,7 @@ write_color_palette(FltRecordWriter &writer) const { // Now append all the names at the end. ColorNames::const_iterator ni; for (ni = _color_names.begin(); ni != _color_names.end(); ++ni) { - string name = (*ni).second.substr(0, 80); + std::string name = (*ni).second.substr(0, 80); int entry_length = name.length() + 8; datagram.add_be_uint16(entry_length); datagram.pad_bytes(2); diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx index 8622f6180b..f33ef3b145 100644 --- a/pandatool/src/flt/fltInstanceRef.cxx +++ b/pandatool/src/flt/fltInstanceRef.cxx @@ -42,7 +42,7 @@ get_instance() const { * flt file, use FltHeader::write_flt(). */ void FltInstanceRef:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "instance"; FltInstanceDefinition *def = _header->get_instance(_instance_index); if (def != nullptr) { diff --git a/pandatool/src/flt/fltMeshPrimitive.cxx b/pandatool/src/flt/fltMeshPrimitive.cxx index 0456cad142..6db78c8059 100644 --- a/pandatool/src/flt/fltMeshPrimitive.cxx +++ b/pandatool/src/flt/fltMeshPrimitive.cxx @@ -91,7 +91,7 @@ build_record(FltRecordWriter &writer) const { int max_index = 0; Vertices::const_iterator vi; for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) { - max_index = max(max_index, (*vi)); + max_index = std::max(max_index, (*vi)); } int vertex_width; diff --git a/pandatool/src/flt/fltOpcode.cxx b/pandatool/src/flt/fltOpcode.cxx index 4ca497a9ee..92fd64afda 100644 --- a/pandatool/src/flt/fltOpcode.cxx +++ b/pandatool/src/flt/fltOpcode.cxx @@ -13,8 +13,8 @@ #include "fltOpcode.h" -ostream & -operator << (ostream &out, FltOpcode opcode) { +std::ostream & +operator << (std::ostream &out, FltOpcode opcode) { switch (opcode) { case FO_none: return out << "null opcode"; diff --git a/pandatool/src/flt/fltPackedColor.cxx b/pandatool/src/flt/fltPackedColor.cxx index cc5dc7540d..0faa4eb644 100644 --- a/pandatool/src/flt/fltPackedColor.cxx +++ b/pandatool/src/flt/fltPackedColor.cxx @@ -19,7 +19,7 @@ * */ void FltPackedColor:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _r << " " << _g << " " << _b << " " << _a << ")"; } diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 5325259ec6..9fcc52fcfa 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -220,7 +220,7 @@ has_comment() const { * Retrieves the comment for this record, or empty string if the record has no * comment. */ -const string &FltRecord:: +const std::string &FltRecord:: get_comment() const { return _comment; } @@ -237,7 +237,7 @@ clear_comment() { * Changes the comment for this record. */ void FltRecord:: -set_comment(const string &comment) { +set_comment(const std::string &comment) { _comment = comment; } @@ -251,7 +251,7 @@ set_comment(const string &comment) { * this is exactly the sort of thing we expect. */ void FltRecord:: -check_remaining_size(const DatagramIterator &di, const string &name) const { +check_remaining_size(const DatagramIterator &di, const std::string &name) const { if (di.get_remaining_size() == 0) { return; } @@ -291,7 +291,7 @@ apply_converted_filenames() { * flt file, use FltHeader::write_flt(). */ void FltRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -301,7 +301,7 @@ output(ostream &out) const { * flt file, use FltHeader::write_flt(). */ void FltRecord:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this; write_children(out, indent_level); } @@ -311,7 +311,7 @@ write(ostream &out, int indent_level) const { * line of the record description, writes out the list of children. */ void FltRecord:: -write_children(ostream &out, int indent_level) const { +write_children(std::ostream &out, int indent_level) const { if (!_ancillary.empty()) { out << " + " << _ancillary.size() << " ancillary"; } diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index f2650fa423..c999001d64 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -22,7 +22,7 @@ * */ FltRecordReader:: -FltRecordReader(istream &in) : +FltRecordReader(std::istream &in) : _in(in) { _opcode = FO_none; diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index df3d904d27..909e5ce298 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -28,7 +28,7 @@ static const int max_write_length = 65532; * */ FltRecordWriter:: -FltRecordWriter(ostream &out) : +FltRecordWriter(std::ostream &out) : _out(out) { } @@ -75,7 +75,7 @@ FltError FltRecordWriter:: advance() { int start_byte = 0; int write_length = - min((int)_datagram.get_length() - start_byte, max_write_length - header_size); + std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size); FltOpcode opcode = _opcode; do { @@ -107,7 +107,7 @@ advance() { start_byte += write_length; write_length = - min((int)_datagram.get_length() - start_byte, max_write_length - header_size); + std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size); opcode = FO_continuation; } while (write_length > 0); diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index ee56205c6f..c65f5a05e2 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -123,7 +123,7 @@ set_texture_filename(const Filename &filename) { */ Filename FltTexture:: get_attr_filename() const { - string texture_filename = get_texture_filename(); + std::string texture_filename = get_texture_filename(); return Filename::binary_filename(texture_filename + ".attr"); } @@ -142,15 +142,15 @@ read_attr_data() { } // Determine the file's size so we can read it all into one big datagram. - attr.seekg(0, ios::end); + attr.seekg(0, std::ios::end); if (attr.fail()) { return FE_read_error; } - streampos length = attr.tellg(); + std::streampos length = attr.tellg(); char *buffer = new char[length]; - attr.seekg(0, ios::beg); + attr.seekg(0, std::ios::beg); attr.read(buffer, length); if (attr.fail()) { return FE_read_error; diff --git a/pandatool/src/flt/fltUnsupportedRecord.cxx b/pandatool/src/flt/fltUnsupportedRecord.cxx index e3bcc07a2a..7a6e67aa84 100644 --- a/pandatool/src/flt/fltUnsupportedRecord.cxx +++ b/pandatool/src/flt/fltUnsupportedRecord.cxx @@ -31,7 +31,7 @@ FltUnsupportedRecord(FltHeader *header) : FltRecord(header) { * flt file, use FltHeader::write_flt(). */ void FltUnsupportedRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Unsupported(" << _opcode << ")"; } diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx index 941d35c300..65da9b5923 100644 --- a/pandatool/src/flt/fltVertexList.cxx +++ b/pandatool/src/flt/fltVertexList.cxx @@ -65,7 +65,7 @@ add_vertex(FltVertex *vertex) { * flt file, use FltHeader::write_flt(). */ void FltVertexList:: -output(ostream &out) const { +output(std::ostream &out) const { out << _vertices.size() << " vertices"; } diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index bd4898b0c5..98b01938c5 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -35,6 +35,8 @@ #include "eggExternalReference.h" #include "string_utils.h" +using std::string; + /** * diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index 238208527e..ef396fd818 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -56,7 +56,7 @@ ParentNodes() { * group per polygon. */ EggGroupNode *FltToEggLevelState:: -get_synthetic_group(const string &name, +get_synthetic_group(const std::string &name, const FltBead *transform_bead, FltGeometry::BillboardType type) { LMatrix4d transform = transform_bead->get_transform(); diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 5ca9224225..f6cbc9d24f 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -93,7 +93,7 @@ run() { * Dispatch function for the -attr parameter. */ bool EggToFlt:: -dispatch_attr(const string &opt, const string &arg, void *var) { +dispatch_attr(const std::string &opt, const std::string &arg, void *var) { FltHeader::AttrUpdate *ip = (FltHeader::AttrUpdate *)var; if (cmp_nocase(arg, "none") == 0) { @@ -231,7 +231,7 @@ convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, void EggToFlt:: convert_group(EggGroup *egg_group, FltBead *flt_node, FltGeometry::BillboardType billboard) { - ostringstream egg_syntax; + std::ostringstream egg_syntax; FltGroup *flt_group = new FltGroup(_flt_header); flt_node->add_child(flt_group); @@ -450,9 +450,9 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { * comment, so that flt2egg will reapply it to the egg groups. */ void EggToFlt:: -apply_egg_syntax(const string &egg_syntax, FltRecord *flt_record) { +apply_egg_syntax(const std::string &egg_syntax, FltRecord *flt_record) { if (!egg_syntax.empty()) { - ostringstream out; + std::ostringstream out; out << " {\n" << egg_syntax << "}"; diff --git a/pandatool/src/fltprogs/fltInfo.cxx b/pandatool/src/fltprogs/fltInfo.cxx index a6d4649bff..bd0e9d8a83 100644 --- a/pandatool/src/fltprogs/fltInfo.cxx +++ b/pandatool/src/fltprogs/fltInfo.cxx @@ -65,7 +65,7 @@ run() { void FltInfo:: list_hierarchy(FltRecord *record, int indent_level) { // Maybe in the future we can do something fancier here. - record->write(cout, indent_level); + record->write(std::cout, indent_level); } diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index fad28f1a4b..e6889ff23b 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -66,9 +66,9 @@ main(int argc, char *argv[]) { g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(destroy), nullptr); - ostringstream stream; + std::ostringstream stream; stream << "Listening on port " << pstats_port; - string str = stream.str(); + std::string str = stream.str(); GtkWidget *label = gtk_label_new(str.c_str()); gtk_container_add(GTK_CONTAINER(main_window), label); gtk_widget_show(label); @@ -76,12 +76,12 @@ main(int argc, char *argv[]) { // Create the server object. server = new GtkStatsServer; if (!server->listen()) { - ostringstream stream; + std::ostringstream stream; stream << "Unable to open port " << pstats_port << ". Try specifying a different\n" << "port number using pstats-port in your Config file."; - string str = stream.str(); + std::string str = stream.str(); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx index 5bd5a7691f..c7f8b3f4be 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx @@ -48,7 +48,7 @@ get_menu_widget() { void GtkStatsChartMenu:: add_to_menu_bar(GtkWidget *menu_bar, int position) { const PStatClientData *client_data = _monitor->get_client_data(); - string thread_name; + std::string thread_name; if (_thread_index == 0) { // A special case for the main thread. thread_name = "Graphs"; @@ -142,7 +142,7 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, int collector = view_level->get_collector(); const PStatClientData *client_data = _monitor->get_client_data(); - string collector_name = client_data->get_collector_name(collector); + std::string collector_name = client_data->get_collector_name(collector); GtkStatsMonitor::MenuDef smd(_thread_index, collector, show_level); const GtkStatsMonitor::MenuDef *menu_def = _monitor->add_menu(smd); @@ -158,7 +158,7 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, if (num_children > 1) { // If the collector has more than one child, add a menu entry to go // directly to each of its children. - string submenu_name = collector_name + " components"; + std::string submenu_name = collector_name + " components"; GtkWidget *submenu_item = gtk_menu_item_new_with_label(submenu_name.c_str()); gtk_widget_show(submenu_item); diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 2f1b1e7189..e56e262d23 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -341,8 +341,8 @@ void GtkStatsGraph:: setup_pixmap(int xsize, int ysize) { release_pixmap(); - _pixmap_xsize = max(xsize, 0); - _pixmap_ysize = max(ysize, 0); + _pixmap_xsize = std::max(xsize, 0); + _pixmap_ysize = std::max(ysize, 0); _pixmap = gdk_pixmap_new(_graph_window->window, _pixmap_xsize, _pixmap_ysize, -1); // g_object_ref(_pixmap); Should this be ref_sink? diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index 1c7a8b1f1f..4f78d88450 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -67,7 +67,7 @@ GtkStatsMonitor:: * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string GtkStatsMonitor:: +std::string GtkStatsMonitor:: get_monitor_name() { return "GtkStats"; } @@ -103,7 +103,7 @@ got_hello() { void GtkStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { - ostringstream str; + std::ostringstream str; str << "Unable to honor connection attempt from " << get_client_progname() << " on " << get_client_hostname() << ": unsupported PStats version " @@ -117,7 +117,7 @@ got_bad_version(int client_major, int client_minor, << ".0 through " << server_major << "." << server_minor << ")."; } - string message = str.str(); + std::string message = str.str(); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -279,7 +279,7 @@ open_piano_roll(int thread_index) { */ const GtkStatsMonitor::MenuDef *GtkStatsMonitor:: add_menu(const MenuDef &menu_def) { - pair result = _menus.insert(menu_def); + std::pair result = _menus.insert(menu_def); Menus::iterator mi = result.first; const GtkStatsMonitor::MenuDef &new_menu_def = (*mi); if (result.second) { diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx index f29ae4955c..60a3dc7887 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx @@ -47,8 +47,8 @@ GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) : const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data(); - string thread_name = client_data->get_thread_name(_thread_index); - string window_title = thread_name + " thread piano roll"; + std::string thread_name = client_data->get_thread_name(_thread_index); + std::string window_title = thread_name + " thread piano roll"; gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str()); gtk_widget_show_all(_window); @@ -441,7 +441,7 @@ draw_guide_label(const PStatGraph::GuideBar &bar) { } int x = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; PangoLayout *layout = gtk_widget_create_pango_layout(_window, label.c_str()); int width, height; diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index 8370cd958b..117ef96576 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -111,7 +111,7 @@ new_collector(int collector_index) { void GtkStatsStripChart:: new_data(int thread_index, int frame_number) { if (is_title_unknown()) { - string window_title = get_title_text(); + std::string window_title = get_title_text(); if (!is_title_unknown()) { gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str()); } @@ -120,7 +120,7 @@ new_data(int thread_index, int frame_number) { if (!_pause) { update(); - string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name()); + std::string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name()); if (_net_value_text != text) { _net_value_text = text; gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str()); @@ -575,7 +575,7 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { } int y = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; PangoLayout *layout = gtk_widget_create_pango_layout(_window, label.c_str()); int width, height; diff --git a/pandatool/src/imagebase/imageWriter.cxx b/pandatool/src/imagebase/imageWriter.cxx index 3a4bfc1d56..eb50188e29 100644 --- a/pandatool/src/imagebase/imageWriter.cxx +++ b/pandatool/src/imagebase/imageWriter.cxx @@ -26,7 +26,7 @@ ImageWriter(bool allow_last_param) : } add_runline("[opts] -o outputimage"); - string o_description; + std::string o_description; if (_allow_last_param) { o_description = "Specify the filename to which the resulting image file will be written. " diff --git a/pandatool/src/imageprogs/imageResize.cxx b/pandatool/src/imageprogs/imageResize.cxx index f3c51c8554..a41ff771de 100644 --- a/pandatool/src/imageprogs/imageResize.cxx +++ b/pandatool/src/imageprogs/imageResize.cxx @@ -87,11 +87,11 @@ run() { * Interprets the -x or -y parameters. */ bool ImageResize:: -dispatch_size_request(const string &opt, const string &arg, void *var) { +dispatch_size_request(const std::string &opt, const std::string &arg, void *var) { SizeRequest *ip = (SizeRequest *)var; if (!arg.empty() && arg[arg.length() - 1] == '%') { // A ratio. - string str = arg.substr(0, arg.length() - 1); + std::string str = arg.substr(0, arg.length() - 1); double ratio; if (!string_to_double(str, ratio)) { nout << "Invalid ratio for -" << opt << ": " diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index 48bc98c5d2..517abee647 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -144,7 +144,7 @@ run() { * Interprets the -chan parameter. */ bool ImageTrans:: -dispatch_channels(const string &opt, const string &arg, void *var) { +dispatch_channels(const std::string &opt, const std::string &arg, void *var) { Channels *ip = (Channels *)var; if (cmp_nocase(arg, "l") == 0) { (*ip) = C_l; diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index 0600956a91..0efee4aab0 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -16,6 +16,10 @@ #include "pnmImage.h" #include +using std::max; +using std::min; +using std::string; + /** * */ diff --git a/pandatool/src/lwo/iffChunk.cxx b/pandatool/src/lwo/iffChunk.cxx index e3ba7107a5..a86ac62dd9 100644 --- a/pandatool/src/lwo/iffChunk.cxx +++ b/pandatool/src/lwo/iffChunk.cxx @@ -22,7 +22,7 @@ TypeHandle IffChunk::_type_handle; * */ void IffChunk:: -output(ostream &out) const { +output(std::ostream &out) const { out << _id << " (" << get_type() << ")"; } @@ -30,7 +30,7 @@ output(ostream &out) const { * */ void IffChunk:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _id << " { ... }\n"; } diff --git a/pandatool/src/lwo/iffGenericChunk.cxx b/pandatool/src/lwo/iffGenericChunk.cxx index 87625c2193..c8eaf015ee 100644 --- a/pandatool/src/lwo/iffGenericChunk.cxx +++ b/pandatool/src/lwo/iffGenericChunk.cxx @@ -37,7 +37,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void IffGenericChunk:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { " << _data.get_length() << " bytes }\n"; } diff --git a/pandatool/src/lwo/iffId.cxx b/pandatool/src/lwo/iffId.cxx index 6d31a79bad..eda63c0b5d 100644 --- a/pandatool/src/lwo/iffId.cxx +++ b/pandatool/src/lwo/iffId.cxx @@ -19,7 +19,7 @@ * */ void IffId:: -output(ostream &out) const { +output(std::ostream &out) const { // If all of the characters are printable, just output them. if (isprint(_id._c[0]) && isprint(_id._c[1]) && isprint(_id._c[2]) && isprint(_id._c[3])) { @@ -32,10 +32,10 @@ output(ostream &out) const { } else { // Otherwise, write out the hex. - out << "0x" << hex << setfill('0'); + out << "0x" << std::hex << std::setfill('0'); for (int i = 0; i < 4; i++) { - out << setw(2) << (int)(unsigned char)_id._c[i]; + out << std::setw(2) << (int)(unsigned char)_id._c[i]; } - out << dec << setfill(' '); + out << std::dec << std::setfill(' '); } } diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index e3ffa34044..f00dbf5469 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -51,7 +51,7 @@ open_read(Filename filename) { filename.set_binary(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { return false; } @@ -68,7 +68,7 @@ open_read(Filename filename) { * IffInputFile destructs. */ void IffInputFile:: -set_input(istream *input, bool owns_istream) { +set_input(std::istream *input, bool owns_istream) { if (_owns_istream) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_input); @@ -174,9 +174,9 @@ get_be_float32() { /** * Extracts a null-terminated string. */ -string IffInputFile:: +std::string IffInputFile:: get_string() { - string result; + std::string result; char byte; while (read_byte(byte)) { if (byte == 0) { diff --git a/pandatool/src/lwo/lwoBoundingBox.cxx b/pandatool/src/lwo/lwoBoundingBox.cxx index 8f23e7b403..10ef60a7b0 100644 --- a/pandatool/src/lwo/lwoBoundingBox.cxx +++ b/pandatool/src/lwo/lwoBoundingBox.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoBoundingBox:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { min = " << _min << ", max = " << _max << " }\n"; } diff --git a/pandatool/src/lwo/lwoClip.cxx b/pandatool/src/lwo/lwoClip.cxx index d0bda7993f..fd1e602a0e 100644 --- a/pandatool/src/lwo/lwoClip.cxx +++ b/pandatool/src/lwo/lwoClip.cxx @@ -36,7 +36,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoClip:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx index f0cab49c18..3e4b0c003c 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx @@ -82,7 +82,7 @@ read_iff(IffInputFile *in, size_t stop_at) { } VMap &vmap = _vmad[polygon_index]; - pair ir = + std::pair ir = vmap.insert(VMap::value_type(vertex_index, value)); if (!ir.second) { // This polygonvertex pair was repeated in the vmad. Is it simply @@ -115,7 +115,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoDiscontinuousVertexMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { map_type = " << _map_type << ", dimension = " << _dimension diff --git a/pandatool/src/lwo/lwoGroupChunk.cxx b/pandatool/src/lwo/lwoGroupChunk.cxx index a9bb29fbe7..481f27bb28 100644 --- a/pandatool/src/lwo/lwoGroupChunk.cxx +++ b/pandatool/src/lwo/lwoGroupChunk.cxx @@ -74,7 +74,7 @@ read_subchunks_iff(IffInputFile *in, size_t stop_at) { * debugging), one per line. */ void LwoGroupChunk:: -write_chunks(ostream &out, int indent_level) const { +write_chunks(std::ostream &out, int indent_level) const { Chunks::const_iterator ci; for (ci = _chunks.begin(); ci != _chunks.end(); ++ci) { (*ci)->write(out, indent_level); diff --git a/pandatool/src/lwo/lwoHeader.cxx b/pandatool/src/lwo/lwoHeader.cxx index 4fe302f54d..aba632eb93 100644 --- a/pandatool/src/lwo/lwoHeader.cxx +++ b/pandatool/src/lwo/lwoHeader.cxx @@ -61,7 +61,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoHeader:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoInputFile.cxx b/pandatool/src/lwo/lwoInputFile.cxx index 78e7dfa10c..a6737855ea 100644 --- a/pandatool/src/lwo/lwoInputFile.cxx +++ b/pandatool/src/lwo/lwoInputFile.cxx @@ -24,6 +24,8 @@ #include "lwoSurface.h" #include "lwoVertexMap.h" +using std::string; + TypeHandle LwoInputFile::_type_handle; /** diff --git a/pandatool/src/lwo/lwoLayer.cxx b/pandatool/src/lwo/lwoLayer.cxx index 75f4a18606..1fea2cd546 100644 --- a/pandatool/src/lwo/lwoLayer.cxx +++ b/pandatool/src/lwo/lwoLayer.cxx @@ -63,9 +63,9 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoLayer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { number = " << _number << ", flags = 0x" - << hex << _flags << dec << ", pivot = " << _pivot + << std::hex << _flags << std::dec << ", pivot = " << _pivot << ", _name = \"" << _name << "\", _parent = " << _parent << " }\n"; } diff --git a/pandatool/src/lwo/lwoPoints.cxx b/pandatool/src/lwo/lwoPoints.cxx index 875d6e8909..7abfeea668 100644 --- a/pandatool/src/lwo/lwoPoints.cxx +++ b/pandatool/src/lwo/lwoPoints.cxx @@ -58,7 +58,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPoints:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { " << _points.size() << " points }\n"; } diff --git a/pandatool/src/lwo/lwoPolygonTags.cxx b/pandatool/src/lwo/lwoPolygonTags.cxx index aef4b051aa..48f81b47e0 100644 --- a/pandatool/src/lwo/lwoPolygonTags.cxx +++ b/pandatool/src/lwo/lwoPolygonTags.cxx @@ -73,7 +73,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPolygonTags:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { tag_type = " << _tag_type << ", " << _tmap.size() << " values }\n"; diff --git a/pandatool/src/lwo/lwoPolygons.cxx b/pandatool/src/lwo/lwoPolygons.cxx index 4e51d3ee26..22d03c2121 100644 --- a/pandatool/src/lwo/lwoPolygons.cxx +++ b/pandatool/src/lwo/lwoPolygons.cxx @@ -113,7 +113,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPolygons:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { polygon_type = " << _polygon_type << ", " << _polygons.size() << " polygons }\n"; diff --git a/pandatool/src/lwo/lwoStillImage.cxx b/pandatool/src/lwo/lwoStillImage.cxx index 851aa6c8ef..9a31986c43 100644 --- a/pandatool/src/lwo/lwoStillImage.cxx +++ b/pandatool/src/lwo/lwoStillImage.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoStillImage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { filename = \"" << _filename << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurface.cxx b/pandatool/src/lwo/lwoSurface.cxx index edbc67506a..e1318947d9 100644 --- a/pandatool/src/lwo/lwoSurface.cxx +++ b/pandatool/src/lwo/lwoSurface.cxx @@ -41,7 +41,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index 76babe281c..8dd32652fa 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -54,7 +54,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlock:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; _header->write(out, indent_level + 2); diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx index 8698e9dea5..3390debdea 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockAxis:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { axis = " << (int)_axis << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx index 523b379e4b..94dc45c8af 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockChannel:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { channel_id = " << _channel_id << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx index 4e1e3f0766..e2c9b77a84 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockCoordSys:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { type = " << (int)_type << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx index c4d01dd557..8240539502 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockEnabled:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { enabled = " << _enabled << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx index a4a88d982a..69351fa403 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx @@ -43,18 +43,18 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockHeader:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) - << "ordinal = 0x" << hex << setfill('0'); + << "ordinal = 0x" << std::hex << std::setfill('0'); - string::const_iterator si; + std::string::const_iterator si; for (si = _ordinal.begin(); si != _ordinal.end(); ++si) { - out << setw(2) << (int)(unsigned char)(*si); + out << std::setw(2) << (int)(unsigned char)(*si); } - out << dec << setfill(' ') << "\n"; + out << std::dec << std::setfill(' ') << "\n"; write_chunks(out, indent_level + 2); indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx index dce817b6aa..520d8cef2a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockImage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { index = " << _index << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx index d6554d0b82..456e1383ca 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx @@ -40,7 +40,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockOpacity:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { type = " << (int)_type << ", opacity = " << _opacity * 100.0 << "%, envelope = " << _envelope diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx index 2f6d214177..500d90c2ed 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockProjection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { mode = " << (int)_mode << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx index d7dccc5693..1c19fedfac 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockRefObj:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { name = \"" << _name << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx index e264667caa..9036c143fc 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockRepeat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { cycles = " << _cycles << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx index f404910611..1f355d2d4d 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx @@ -41,7 +41,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockTMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; write_chunks(out, indent_level + 2); diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx index e2fdccad18..2ed2738161 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockTransform:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { vec = " << _vec << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx index 208f309e4c..f4db699457 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockVMapName:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { name = \"" << _name << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx index ec7cc24796..006be5f8be 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockWrap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { width = " << (int)_width << ", height = " << (int)_height << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceColor.cxx b/pandatool/src/lwo/lwoSurfaceColor.cxx index ceeb5ab747..5a4526eb55 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.cxx +++ b/pandatool/src/lwo/lwoSurfaceColor.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceColor:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { color = " << _color << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceParameter.cxx b/pandatool/src/lwo/lwoSurfaceParameter.cxx index f1ff64203b..fd3543f18a 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.cxx +++ b/pandatool/src/lwo/lwoSurfaceParameter.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceParameter:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { value = " << _value << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.cxx b/pandatool/src/lwo/lwoSurfaceSidedness.cxx index b67c1492be..2c773b25f6 100644 --- a/pandatool/src/lwo/lwoSurfaceSidedness.cxx +++ b/pandatool/src/lwo/lwoSurfaceSidedness.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceSidedness:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { sidedness = " << (int)_sidedness << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx index 1b0570c46b..49c1f729f5 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceSmoothingAngle:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { angle = " << rad_2_deg(_angle) << " degrees }\n"; } diff --git a/pandatool/src/lwo/lwoTags.cxx b/pandatool/src/lwo/lwoTags.cxx index c2d9ebbc8d..43eaa2ab70 100644 --- a/pandatool/src/lwo/lwoTags.cxx +++ b/pandatool/src/lwo/lwoTags.cxx @@ -30,9 +30,9 @@ get_num_tags() const { /** * Returns the nth tag of this group. */ -string LwoTags:: +std::string LwoTags:: get_tag(int n) const { - nassertr(n >= 0 && n < (int)_tags.size(), string()); + nassertr(n >= 0 && n < (int)_tags.size(), std::string()); return _tags[n]; } @@ -47,7 +47,7 @@ read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); while (lin->get_bytes_read() < stop_at && !lin->is_eof()) { - string tag = lin->get_string(); + std::string tag = lin->get_string(); _tags.push_back(tag); } @@ -58,7 +58,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoTags:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { "; diff --git a/pandatool/src/lwo/lwoVertexMap.cxx b/pandatool/src/lwo/lwoVertexMap.cxx index 396ab91b33..a0ecbf9cd5 100644 --- a/pandatool/src/lwo/lwoVertexMap.cxx +++ b/pandatool/src/lwo/lwoVertexMap.cxx @@ -79,7 +79,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoVertexMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { map_type = " << _map_type << ", dimension = " << _dimension diff --git a/pandatool/src/lwoegg/cLwoPoints.cxx b/pandatool/src/lwoegg/cLwoPoints.cxx index 43f48ee690..93a89f79c6 100644 --- a/pandatool/src/lwoegg/cLwoPoints.cxx +++ b/pandatool/src/lwoegg/cLwoPoints.cxx @@ -26,7 +26,7 @@ void CLwoPoints:: add_vmap(const LwoVertexMap *lwo_vmap) { IffId map_type = lwo_vmap->_map_type; - const string &name = lwo_vmap->_name; + const std::string &name = lwo_vmap->_name; bool inserted; if (map_type == IffId("TXUV")) { @@ -52,7 +52,7 @@ add_vmap(const LwoVertexMap *lwo_vmap) { * given vertex, false otherwise. If true, fills in uv with the value. */ bool CLwoPoints:: -get_uv(const string &uv_name, int n, LPoint2 &uv) const { +get_uv(const std::string &uv_name, int n, LPoint2 &uv) const { VMap::const_iterator ni = _txuv.find(uv_name); if (ni == _txuv.end()) { return false; @@ -82,7 +82,7 @@ void CLwoPoints:: make_egg() { // Generate a vpool name based on the layer index, for lack of anything // better. - string vpool_name = "layer" + format_string(_layer->get_number()); + std::string vpool_name = "layer" + format_string(_layer->get_number()); _egg_vpool = new EggVertexPool(vpool_name); } diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index 3f64a6ee83..e6a0fac4cf 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -25,6 +25,8 @@ #include "eggPoint.h" #include "deg_2_rad.h" +using std::string; + /** * Associates the indicated PolygonTags and Tags with the polygons in this * chunk. This may define features such as per-polygon surfaces, parts, and diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index b3a1c78d1d..63559dd62f 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -190,7 +190,7 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, } if ((_flags & F_smooth_angle) != 0) { - smooth_angle = max(smooth_angle, _smooth_angle); + smooth_angle = std::max(smooth_angle, _smooth_angle); } } diff --git a/pandatool/src/lwoegg/lwoToEggConverter.cxx b/pandatool/src/lwoegg/lwoToEggConverter.cxx index 94aa3b7fe6..42844f19f0 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.cxx +++ b/pandatool/src/lwoegg/lwoToEggConverter.cxx @@ -69,7 +69,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string LwoToEggConverter:: +std::string LwoToEggConverter:: get_name() const { return "Lightwave"; } @@ -77,7 +77,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string LwoToEggConverter:: +std::string LwoToEggConverter:: get_extension() const { return "lwo"; } @@ -182,7 +182,7 @@ get_clip(int number) const { * there is no such surface. */ CLwoSurface *LwoToEggConverter:: -get_surface(const string &name) const { +get_surface(const std::string &name) const { Surfaces::const_iterator si; si = _surfaces.find(name); if (si != _surfaces.end()) { diff --git a/pandatool/src/lwoprogs/lwoScan.cxx b/pandatool/src/lwoprogs/lwoScan.cxx index 5bb0f5a600..c299a3a783 100644 --- a/pandatool/src/lwoprogs/lwoScan.cxx +++ b/pandatool/src/lwoprogs/lwoScan.cxx @@ -48,7 +48,7 @@ run() { nout << "Unable to read file.\n"; } else { while (chunk != nullptr) { - chunk->write(cout, 0); + chunk->write(std::cout, 0); chunk = in.get_chunk(); } } diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index 88ae826490..2d9765ee01 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -19,6 +19,10 @@ #include #include #include "errno.h" + +using std::min; +using std::max; + #include "Max.h" #include "eggGroup.h" #include "eggTable.h" diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index e2747e6dd0..a6855657e6 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -26,6 +26,9 @@ #include "eggPolysetMaker.h" #include "eggBin.h" +using std::min; +using std::max; + #include #include "Max.h" #include "istdplug.h" @@ -39,6 +42,8 @@ #include "maxEggLoader.h" +using std::vector; + class MaxEggMesh; class MaxEggJoint; class MaxEggTex; @@ -64,7 +69,7 @@ public: typedef second_of_pair_iterator MeshIterator; typedef phash_map JointTable; typedef second_of_pair_iterator JointIterator; - typedef phash_map TexTable; + typedef phash_map TexTable; typedef second_of_pair_iterator TexIterator; MeshTable _mesh_tab; @@ -296,7 +301,7 @@ void MaxEggJoint::CreateMaxBone(void) // MaxEggMesh -typedef pair MaxEggWeight; +typedef std::pair MaxEggWeight; struct MaxEggVertex { @@ -344,7 +349,7 @@ class MaxEggMesh { public: - string _name; + std::string _name; TriObject *_obj; Mesh *_mesh; INode *_node; @@ -434,7 +439,7 @@ MaxEggMesh *MaxEggLoader::GetMesh(EggVertexPool *pool) { MaxEggMesh *result = _mesh_tab[pool]; if (result == 0) { - string name = pool->get_name(); + std::string name = pool->get_name(); int nsize = name.size(); if ((nsize > 6) && (name.rfind(".verts")==(nsize-6))) name.resize(nsize-6); diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 85b909a6e2..41718f66e8 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -27,6 +27,8 @@ #include "maxEgg.h" #include "config_putil.h" +using std::string; + /** * */ @@ -704,7 +706,7 @@ make_polyset(INode *max_node, Mesh *mesh, // standard material to the object for (int iChan=0; iChan // for chdir() #endif +using std::string; + MayaApi *MayaApi::_global_api = nullptr; // We need this bogus object just to force the application to link with @@ -255,7 +257,7 @@ read(const Filename &filename) { string dirname = _cwd.to_os_specific(); if (maya_cat.is_debug()) { - maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << endl; + maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << std::endl; } MFileIO::newFile(true); @@ -293,7 +295,7 @@ write(const Filename &filename) { string dirname = _cwd.to_os_specific(); if (maya_cat.is_debug()) { - maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << endl; + maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << std::endl; } const char *type = "mayaBinary"; diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index 78484d0be3..9be62a60d3 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -32,6 +32,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * Reads the Maya "shading engine" to determine the relevant shader * properties. @@ -92,7 +95,7 @@ MayaShader:: * */ void MayaShader:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Shader " << get_name(); } @@ -100,7 +103,7 @@ output(ostream &out) const { * */ void MayaShader:: -write(ostream &out) const { +write(std::ostream &out) const { out << "Shader " << get_name() << "\n"; } diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index 41c9bdf77f..34ff13a808 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -21,7 +21,6 @@ #include "lmatrix.h" #include "namable.h" -class MObject; /** * Corresponds to a single "shader" in Maya. This extracts out all the diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 69aa0cd85e..cbaa82d5b7 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -29,6 +29,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * */ @@ -177,7 +180,7 @@ project_uv(const LPoint3d &pos, const LPoint3d ¢roid) const { * */ void MayaShaderColorDef:: -write(ostream &out) const { +write(std::ostream &out) const { if (_has_texture) { out << " texture filename is " << _texture_filename << "\n" << " texture name is " << _texture_name << "\n" @@ -364,15 +367,17 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { if (li > -1) { // found a blend mode if (maya_cat.is_spam()) { + MString name = inputsPlug.name(); maya_cat.spam() << "*** Start doIt... ***" << endl; - maya_cat.spam() << "inputsPlug Name: " << inputsPlug.name() << endl; + maya_cat.spam() << "inputsPlug Name: " << name.asChar() << endl; } status = blendModePlug.selectAncestorLogicalIndex(li,inputsPlug); blendModePlug.getValue(blendValue); if (maya_cat.is_spam()) { + MString name = blendModePlug.name(); maya_cat.spam() - << blendModePlug.name() << ": has value " << blendValue << endl; + << name.asChar() << ": has value " << blendValue << endl; } MFnEnumAttribute blendModeEnum(blendModePlug); @@ -394,9 +399,13 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { bt = BT_add; break; } - maya_cat.info() << layered_fn.name() << ": blendMode used " << blendName << endl; - if (maya_cat.is_spam()) { - maya_cat.spam() << "*** END doIt... ***" << endl; + + if (maya_cat.is_info()) { + MString name = layered_fn.name(); + maya_cat.info() << name.asChar() << ": blendMode used " << blendName.asChar() << endl; + if (maya_cat.is_spam()) { + maya_cat.spam() << "*** END doIt... ***" << endl; + } } // advance to the next plug, because that is where the shader info are diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index ca2d532f13..2609f2bb43 100644 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -21,8 +21,6 @@ #include "pmap.h" #include "pvector.h" -class MObject; -class MPlug; class MayaShader; class MayaShaderColorDef; typedef pvector MayaShaderColorList; diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index 7aecbd3d61..dca3712366 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -27,6 +27,8 @@ #include #include "post_maya_include.h" +using std::string; + /** * */ diff --git a/pandatool/src/maya/mayaShaders.h b/pandatool/src/maya/mayaShaders.h index f1c107a755..5428ab5f73 100644 --- a/pandatool/src/maya/mayaShaders.h +++ b/pandatool/src/maya/mayaShaders.h @@ -21,7 +21,6 @@ #include "mayaShaderColorDef.h" class MayaShader; -class MObject; /** * Collects the set of MayaShaders that have been encountered so far. diff --git a/pandatool/src/maya/maya_funcs.T b/pandatool/src/maya/maya_funcs.T index 80d8803d3f..3418ce3647 100644 --- a/pandatool/src/maya/maya_funcs.T +++ b/pandatool/src/maya/maya_funcs.T @@ -17,7 +17,7 @@ */ template bool -get_maya_attribute(MObject &node, const string &attribute_name, +get_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value) { bool status = false; @@ -35,7 +35,7 @@ get_maya_attribute(MObject &node, const string &attribute_name, */ template bool -set_maya_attribute(MObject &node, const string &attribute_name, +set_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value) { bool status = false; diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 184a903f66..2f21adefb3 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -31,6 +31,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * Gets the named MPlug associated, if any. */ diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 2966fef9e3..ad0a7210b3 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -28,7 +28,6 @@ #include #include "post_maya_include.h" -class MObject; bool get_maya_plug(MObject &node, const std::string &attribute_name, MPlug &plug); diff --git a/pandatool/src/maya/pre_maya_include.h b/pandatool/src/maya/pre_maya_include.h index 0244ec7ba4..85442c1e7b 100644 --- a/pandatool/src/maya/pre_maya_include.h +++ b/pandatool/src/maya/pre_maya_include.h @@ -43,4 +43,21 @@ #if MAYA_API_VERSION < 201600 #include #endif +#else +// This defines MAYA_API_VERSION +#include +#endif + +#if MAYA_API_VERSION >= 20180000 +#include +#else +class MObject; +class MDagPath; +class MFloatArray; +class MFnDagNode; +class MFnMesh; +class MFnNurbsCurve; +class MFnNurbsSurface; +class MPlug; +class MPointArray; #endif diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index c60ecf515a..b396ed86b6 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -24,7 +24,7 @@ MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : _deformer(deformer.object()), _weight_index(weight_index) { - ostringstream strm; + std::ostringstream strm; strm << _deformer.name().asChar() << "." << _weight_index; set_name(strm.str()); diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 6664e54aa0..4baf1dff86 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -71,6 +71,12 @@ #include "mayaEggLoader.h" +using std::cerr; +using std::endl; +using std::ostringstream; +using std::string; +using std::vector; + class MayaEggGroup; class MayaEggGeom; class MayaEggMesh; @@ -617,7 +623,7 @@ void MayaEggJoint::CreateMayaBone(MayaEggGroup *eggParent) // MayaEggGeom : base abstract class of MayaEggMesh and MayaEggNurbsSurface -typedef pair MayaEggWeight; +typedef std::pair MayaEggWeight; struct MayaEggVertex { @@ -1364,7 +1370,6 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del int numVertices = 0; for (ci = poly->begin(); ci != poly->end(); ++ci) { EggVertex *vtx = (*ci); - EggVertexPool *pool = poly->get_pool(); LTexCoordd uv(0,0); if (vtx->has_uv()) { uv = vtx->get_uv(); @@ -1565,8 +1570,8 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del mayaloader_cat.debug() << delim+delstring << "found an EggTable: " << node->get_name() << endl; } } else if (node->is_of_type(EggXfmSAnim::get_class_type())) { - MayaAnim *anim = GetAnim(DCAST(EggXfmSAnim, node)); - // anim->PrintData(); + //MayaAnim *anim = GetAnim(DCAST(EggXfmSAnim, node)); + //anim->PrintData(); if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << delim+delstring << "found an EggXfmSAnim: " << node->get_name() << endl; } @@ -1791,7 +1796,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a double thickness = 0.0; for (ji = _joint_tab.begin(); ji != _joint_tab.end(); ++ji) { MayaEggJoint *joint = (*ji).second; - double dfo = ((*ji).second->GetPos()).length(); + double dfo = (joint->GetPos()).length(); if (dfo > thickness) { thickness = dfo; } @@ -2007,7 +2012,6 @@ void MayaEggLoader::PrintData(MayaEggMesh *mesh) void MayaEggLoader::ParseFrameInfo(string comment) { - int length = 0; int pos, ls, le; pos = comment.find("-fri"); diff --git a/pandatool/src/mayaegg/mayaNodeDesc.cxx b/pandatool/src/mayaegg/mayaNodeDesc.cxx index 9049bf2dc8..8a86f1cb96 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.cxx +++ b/pandatool/src/mayaegg/mayaNodeDesc.cxx @@ -26,6 +26,8 @@ #include #include "post_maya_include.h" +using std::string; + TypeHandle MayaNodeDesc::_type_handle; // This is a list of the names of Maya connections that count as a transform. @@ -339,7 +341,7 @@ check_pseudo_joints(bool joint_above) { space.append(" "); } if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj:" << space << get_name() << " joint_type: " << _joint_type << endl; + mayaegg_cat.spam() << "cpj:" << space << get_name() << " joint_type: " << _joint_type << std::endl; } if (_joint_type == JT_joint_parent && joint_above) { // This is one such node: it is the parent of a joint (JT_joint_parent is @@ -387,11 +389,11 @@ check_pseudo_joints(bool joint_above) { child->_joint_type = JT_pseudo_joint; } else if (child->_joint_type == JT_none) { if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj: " << space << "jt_none for " << child->get_name() << endl; + mayaegg_cat.spam() << "cpj: " << space << "jt_none for " << child->get_name() << std::endl; } if (type_name.find("transform") == string::npos) { if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj: " << space << "all_joints false for " << get_name() << endl; + mayaegg_cat.spam() << "cpj: " << space << "all_joints false for " << get_name() << std::endl; } all_joints = false; } diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index 32a6281725..f80a3c95c1 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -32,6 +32,8 @@ #include #include "post_maya_include.h" +using std::string; + /** * */ @@ -611,7 +613,7 @@ r_build_node(const string &path) { if (node_desc != _root) { MayaNodeDesc *parent_node_desc = r_build_node(parent_path); if (parent_node_desc == nullptr) - mayaegg_cat.info() << "empty parent: " << local_name << endl; + mayaegg_cat.info() << "empty parent: " << local_name << std::endl; node_desc = new MayaNodeDesc(this, parent_node_desc, local_name); _nodes.push_back(node_desc); } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index cefe15e1cc..747c8ac279 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -76,6 +76,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * @@ -591,7 +594,7 @@ convert_flip(double start_frame, double end_frame, double frame_inc, while (frame <= frame_stop) { mayaegg_cat.info(false) << "frame " << frame.value() << "\n"; - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "frame" << frame.value(); EggGroup *frame_root = new EggGroup(name_strm.str()); sequence_node->add_child(frame_root); @@ -835,12 +838,14 @@ process_model_node(MayaNodeDesc *node_desc) { // Extract some interesting Camera data if (mayaegg_cat.is_spam()) { MPoint eyePoint = camera.eyePoint(MSpace::kWorld); + MVector upDirection = camera.upDirection(MSpace::kWorld); + MVector viewDirection = camera.viewDirection(MSpace::kWorld); mayaegg_cat.spam() << " eyePoint: " << eyePoint.x << " " << eyePoint.y << " " << eyePoint.z << endl; - mayaegg_cat.spam() << " upDirection: " - << camera.upDirection(MSpace::kWorld) << endl; - mayaegg_cat.spam() << " viewDirection: " - << camera.viewDirection(MSpace::kWorld) << endl; + mayaegg_cat.spam() << " upDirection: " << upDirection.x << " " + << upDirection.y << " " << upDirection.z << endl; + mayaegg_cat.spam() << " viewDirection: " << viewDirection.x << " " + << viewDirection.y << " " << viewDirection.z << endl; mayaegg_cat.spam() << " aspectRatio: " << camera.aspectRatio() << endl; mayaegg_cat.spam() << " horizontalFilmAperture: " << camera.horizontalFilmAperture() << endl; @@ -919,9 +924,12 @@ process_model_node(MayaNodeDesc *node_desc) { mayaegg_cat.error() << "light extraction failed" << endl; return false; } - mayaegg_cat.info() << "-- Light found -- tranlations in cm, rotations in rads\n"; - mayaegg_cat.info() << "\"" << dag_path.partialPathName() << "\" : \n"; + if (mayaegg_cat.is_info()) { + MString name = dag_path.partialPathName(); + mayaegg_cat.info() << "-- Light found -- tranlations in cm, rotations in rads\n"; + mayaegg_cat.info() << "\"" << name.asChar() << "\" : \n"; + } // Get the translationrotationscale data MObject transformNode = dag_path.transform(&status); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index 3e3782a601..c2266e0096 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -42,15 +42,6 @@ class EggPrimitive; class EggXfmSAnim; class MayaShaderColorDef; -class MObject; -class MDagPath; -class MFnDagNode; -class MFnNurbsSurface; -class MFnNurbsCurve; -class MFnMesh; -class MPointArray; -class MFloatArray; - /** * This class supervises the construction of an EggData structure from a * single Maya file, or from the data already in the global Maya model space. diff --git a/pandatool/src/mayaprogs/blend_test.cxx b/pandatool/src/mayaprogs/blend_test.cxx index 5cbd6d413e..ed03fd3661 100644 --- a/pandatool/src/mayaprogs/blend_test.cxx +++ b/pandatool/src/mayaprogs/blend_test.cxx @@ -21,7 +21,7 @@ #include #include -using namespace std; +using std::cerr; void scan_nodes() { @@ -177,7 +177,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - std::ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, std::ios::out | std::ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/mayaprogs/mayaCopy.cxx b/pandatool/src/mayaprogs/mayaCopy.cxx index 70cb614a2d..d10ed8e0aa 100644 --- a/pandatool/src/mayaprogs/mayaCopy.cxx +++ b/pandatool/src/mayaprogs/mayaCopy.cxx @@ -16,7 +16,6 @@ #include "mayaCopy.h" #include "config_maya.h" #include "cvsSourceDirectory.h" -#include "mayaShader.h" #include "dcast.h" #include "pre_maya_include.h" @@ -32,6 +31,11 @@ #include #include "post_maya_include.h" +#include "mayaShader.h" + +using std::endl; +using std::string; + /** * */ diff --git a/pandatool/src/mayaprogs/mayaCopy.h b/pandatool/src/mayaprogs/mayaCopy.h index 90ceddfbc0..38f0aef9de 100644 --- a/pandatool/src/mayaprogs/mayaCopy.h +++ b/pandatool/src/mayaprogs/mayaCopy.h @@ -17,15 +17,19 @@ #include "pandatoolbase.h" #include "cvsCopy.h" #include "mayaApi.h" -#include "mayaShaders.h" #include "dSearchPath.h" #include "pointerTo.h" #include "pset.h" +#include "pre_maya_include.h" +#include +#include "post_maya_include.h" + +#include "mayaShaders.h" + class MayaShader; class MayaShaderColorDef; -class MDagPath; /** * A program to copy Maya .mb files into the cvs tree. diff --git a/pandatool/src/mayaprogs/mayaEggImport.cxx b/pandatool/src/mayaprogs/mayaEggImport.cxx index 4b4ee413f0..5e38271517 100644 --- a/pandatool/src/mayaprogs/mayaEggImport.cxx +++ b/pandatool/src/mayaprogs/mayaEggImport.cxx @@ -115,7 +115,7 @@ MStatus MayaEggImporter::reader ( const MFileObject& file, std::ostringstream log; Notify::ptr()->set_ostream_ptr(&log, false); bool ok = MayaLoadEggFile(fileName.asChar(), merge, model, anim, false); - string txt = log.str(); + std::string txt = log.str(); if (txt != "") { MGlobal::displayError(txt.c_str()); } else { diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 687ec99886..06fc171b14 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -119,13 +119,13 @@ doIt(const MArgList &args) { MProgressWindow::advanceProgress(1); // Now spawn a pview instance to view this temporary file. - string pview_args = "-clD"; + std::string pview_args = "-clD"; if (animate) { pview_args = "-clDa"; } // On Windows, we use the spawn function to run pview asynchronously. - string quoted = string("\"") + bam_filename.get_fullpath() + string("\""); + std::string quoted = std::string("\"") + bam_filename.get_fullpath() + std::string("\""); nout << "pview " << pview_args << " " << quoted << "\n"; int retval = _spawnlp(_P_DETACH, "pview", "pview", pview_args.c_str(), quoted.c_str(), nullptr); @@ -242,7 +242,7 @@ convert(const NodePath &parent, bool animate) { // Accept relative pathnames in the Maya file. Filename source_file = Filename::from_os_specific(MFileIO::currentFile().asChar()); - string source_dir = source_file.get_dirname(); + std::string source_dir = source_file.get_dirname(); if (!source_dir.empty()) { path_replace->_path.append_directory(source_dir); } diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index 8d58808a5b..1219f5389a 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -319,7 +319,7 @@ run() { * option. */ bool MayaToEgg:: -dispatch_transform_type(const string &opt, const string &arg, void *var) { +dispatch_transform_type(const std::string &opt, const std::string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; (*ip) = MayaToEggConverter::string_transform_type(arg); diff --git a/pandatool/src/mayaprogs/mayaToEgg_client.cxx b/pandatool/src/mayaprogs/mayaToEgg_client.cxx index dfde2661c1..a92e6195ec 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_client.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_client.cxx @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { // Get the current working directory and make sure it's a string Filename cwd = ExecutionEnvironment::get_cwd(); - string s_cwd = (string)cwd.to_os_specific(); + std::string s_cwd = (std::string)cwd.to_os_specific(); NetDatagram datagram; // First part of the datagram is the argc diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.cxx b/pandatool/src/mayaprogs/mayaToEgg_server.cxx index 8b97d920a4..e95118d33b 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_server.cxx @@ -329,7 +329,7 @@ run() { * option. */ bool MayaToEggServer:: -dispatch_transform_type(const string &opt, const string &arg, void *var) { +dispatch_transform_type(const std::string &opt, const std::string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; (*ip) = MayaToEggConverter::string_transform_type(arg); @@ -389,7 +389,7 @@ poll() { // track of all the pointers we're gonna malloc. Needed later for // cleanup. vector_string vargv; - vector buffers; + std::vector buffers; // Get the strings from the datagram and put them into the string vector int i; @@ -399,7 +399,7 @@ poll() { // Last string is the current directory the client was run from. Not // part of the argument list, but we still need it - string cwd = data.get_string(); + std::string cwd = data.get_string(); // We allocate some memory to hold the pointers to the pointers we're // going to pass in to parse_command_line(). @@ -439,7 +439,7 @@ poll() { vargv.clear(); // No, iterate through the char * vector and cleanup the malloc'd // pointers - vector::iterator vi; + std::vector::iterator vi; for ( vi = buffers.begin() ; vi != buffers.end(); vi++) { free(*vi); } diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index cac021eebe..441a22c0e2 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -51,6 +51,10 @@ #include #endif +using std::cerr; +using std::endl; +using std::string; + #define QUOTESTR(x) #x #define TOSTRING(x) QUOTESTR(x) @@ -101,6 +105,7 @@ struct MayaVerInfo maya_versions[] = { { "MAYA2016", "2016"}, { "MAYA20165", "2016.5"}, { "MAYA2017", "2017"}, + { "MAYA2018", "2018"}, { 0, 0 }, }; diff --git a/pandatool/src/mayaprogs/normal_test.cxx b/pandatool/src/mayaprogs/normal_test.cxx index ca1b4638eb..41680254de 100644 --- a/pandatool/src/mayaprogs/normal_test.cxx +++ b/pandatool/src/mayaprogs/normal_test.cxx @@ -23,7 +23,8 @@ #include #include -using namespace std; +using std::cerr; +using std::endl; void scan_nodes() { diff --git a/pandatool/src/miscprogs/binToC.cxx b/pandatool/src/miscprogs/binToC.cxx index 44eddfb1ac..f963c08986 100644 --- a/pandatool/src/miscprogs/binToC.cxx +++ b/pandatool/src/miscprogs/binToC.cxx @@ -73,13 +73,13 @@ run() { } std::ostream &out = get_output(); - string static_keyword; + std::string static_keyword; if (_static_table) { static_keyword = "static "; } - string table_type = "const unsigned char "; - string length_type = "const int "; + std::string table_type = "const unsigned char "; + std::string length_type = "const int "; if (_for_string) { // Actually, declaring the table as "const char" causes VC7 to yell about // truncating all of the values >= 0x80. table_type = "const char "; @@ -96,7 +96,7 @@ run() { << "#include \n" << "\n" << static_keyword << table_type << _table_name << "[] = {"; - out << hex << setfill('0'); + out << std::hex << std::setfill('0'); int count = 0; int col = 0; unsigned int ch; @@ -110,14 +110,14 @@ run() { } else { out << ", "; } - out << "0x" << setw(2) << ch; + out << "0x" << std::setw(2) << ch; col++; count++; ch = in.get(); } out << "\n};\n\n" << static_keyword << length_type << _table_name << "_len = " - << dec << count << ";\n\n"; + << std::dec << count << ";\n\n"; } /** diff --git a/pandatool/src/objegg/eggToObjConverter.cxx b/pandatool/src/objegg/eggToObjConverter.cxx index 96505e7f35..a03630698c 100644 --- a/pandatool/src/objegg/eggToObjConverter.cxx +++ b/pandatool/src/objegg/eggToObjConverter.cxx @@ -23,6 +23,9 @@ #include "eggLine.h" #include "dcast.h" +using std::ostream; +using std::string; + /** * */ diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 05af8ce1a2..7044409ca5 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -27,6 +27,8 @@ #include "triangulator3.h" #include "config_egg2pg.h" +using std::string; + /** * */ @@ -147,7 +149,7 @@ convert_to_node(const LoaderOptions &options, const Filename &filename) { bool ObjToEggConverter:: process(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *strm = vfs->open_read_file(filename, true); + std::istream *strm = vfs->open_read_file(filename, true); if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; @@ -552,7 +554,7 @@ generate_egg_points() { bool ObjToEggConverter:: process_node(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *strm = vfs->open_read_file(filename, true); + std::istream *strm = vfs->open_read_file(filename, true); if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; @@ -647,7 +649,7 @@ process_f_node(vector_string &words) { _f_given = true; bool all_vn = true; - int non_vn_index = -1; + //int non_vn_index = -1; pvector verts; verts.reserve(words.size() - 1); @@ -656,7 +658,7 @@ process_f_node(vector_string &words) { verts.push_back(entry); if (entry._vni == 0) { all_vn = false; - non_vn_index = i; + //non_vn_index = i; } } @@ -704,7 +706,7 @@ process_f_node(vector_string &words) { } if (_current_vertex_data->_prim->get_num_vertices() + 3 * num_tris > egg_max_indices || - _current_vertex_data->_entries.size() + verts.size() > egg_max_vertices) { + _current_vertex_data->_entries.size() + verts.size() > (size_t)egg_max_vertices) { // We'll exceed our specified limit with these triangles; start a new // Geom. _current_vertex_data->close_geom(this); @@ -799,7 +801,7 @@ generate_points() { */ int ObjToEggConverter:: add_synth_normal(const LVecBase3d &normal) { - pair result = _unique_synth_vn_table.insert(UniqueVec3Table::value_type(normal, _unique_synth_vn_table.size())); + std::pair result = _unique_synth_vn_table.insert(UniqueVec3Table::value_type(normal, _unique_synth_vn_table.size())); UniqueVec3Table::iterator ni = result.first; int index = (*ni).second; @@ -895,7 +897,7 @@ VertexData(PandaNode *parent, const string &name) : */ int ObjToEggConverter::VertexData:: add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { - pair result; + std::pair result; UniqueVertexEntries::iterator ni; int index; diff --git a/pandatool/src/palettizer/destTextureImage.cxx b/pandatool/src/palettizer/destTextureImage.cxx index b1b3c1853b..38f9a879d1 100644 --- a/pandatool/src/palettizer/destTextureImage.cxx +++ b/pandatool/src/palettizer/destTextureImage.cxx @@ -48,8 +48,8 @@ DestTextureImage(TexturePlacement *placement) { _x_size = to_power_2(_x_size); _y_size = to_power_2(_y_size); } else { - _x_size = max(_x_size, 1); - _y_size = max(_y_size, 1); + _x_size = std::max(_x_size, 1); + _y_size = std::max(_y_size, 1); } } diff --git a/pandatool/src/palettizer/eggFile.cxx b/pandatool/src/palettizer/eggFile.cxx index 1b9e20e9e8..40376a7988 100644 --- a/pandatool/src/palettizer/eggFile.cxx +++ b/pandatool/src/palettizer/eggFile.cxx @@ -57,7 +57,7 @@ bool EggFile:: from_command_line(EggData *data, const Filename &source_filename, const Filename &dest_filename, - const string &egg_comment) { + const std::string &egg_comment) { _data = data; _had_data = true; remove_backstage(_data); @@ -588,7 +588,7 @@ write_egg() { * the indicated output stream. */ void EggFile:: -write_description(ostream &out, int indent_level) const { +write_description(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << ": "; if (_explicitly_assigned_groups.empty()) { if (_default_group != nullptr) { @@ -609,7 +609,7 @@ write_description(ostream &out, int indent_level) const { * per line. */ void EggFile:: -write_texture_refs(ostream &out, int indent_level) const { +write_texture_refs(std::ostream &out, int indent_level) const { Textures::const_iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureReference *reference = (*ti); @@ -663,7 +663,7 @@ rescan_textures() { // Make sure each tref name is unique within a given file. tc.uniquify_trefs(); - typedef pmap ByTRefName; + typedef pmap ByTRefName; ByTRefName by_tref_name; for (Textures::const_iterator ti = _textures.begin(); ti != _textures.end(); diff --git a/pandatool/src/palettizer/imageFile.cxx b/pandatool/src/palettizer/imageFile.cxx index eb2409aab6..15a5ebc4e6 100644 --- a/pandatool/src/palettizer/imageFile.cxx +++ b/pandatool/src/palettizer/imageFile.cxx @@ -24,6 +24,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::string; + TypeHandle ImageFile::_type_handle; /** @@ -419,7 +421,7 @@ update_egg_tex(EggTexture *egg_tex) const { * Writes the filename (or pair of filenames) to the indicated output stream. */ void ImageFile:: -output_filename(ostream &out) const { +output_filename(std::ostream &out) const { out << FilenameUnifier::make_user_filename(_filename); if (_properties.uses_alpha() && !_alpha_filename.empty()) { out << " " << FilenameUnifier::make_user_filename(_alpha_filename); diff --git a/pandatool/src/palettizer/omitReason.cxx b/pandatool/src/palettizer/omitReason.cxx index 94848b865c..6bc14240f4 100644 --- a/pandatool/src/palettizer/omitReason.cxx +++ b/pandatool/src/palettizer/omitReason.cxx @@ -13,8 +13,8 @@ #include "omitReason.h" -ostream & -operator << (ostream &out, OmitReason omit) { +std::ostream & +operator << (std::ostream &out, OmitReason omit) { switch (omit) { case OR_none: return out << "none"; diff --git a/pandatool/src/palettizer/pal_string_utils.cxx b/pandatool/src/palettizer/pal_string_utils.cxx index be747e4106..279a7aad47 100644 --- a/pandatool/src/palettizer/pal_string_utils.cxx +++ b/pandatool/src/palettizer/pal_string_utils.cxx @@ -16,6 +16,8 @@ #include "pnmFileType.h" #include "pnmFileTypeRegistry.h" +using std::string; + // Extracts the first word of the string into param, and the remainder of the // line into value. diff --git a/pandatool/src/palettizer/paletteGroup.cxx b/pandatool/src/palettizer/paletteGroup.cxx index 409bf28f33..182479216f 100644 --- a/pandatool/src/palettizer/paletteGroup.cxx +++ b/pandatool/src/palettizer/paletteGroup.cxx @@ -26,6 +26,8 @@ #include "indirectCompareNames.h" #include "pvector.h" +using std::string; + TypeHandle PaletteGroup::_type_handle; /** @@ -454,7 +456,7 @@ update_unknown_textures(const TxaFile &txa_file) { * their textures, to the indicated output stream. */ void PaletteGroup:: -write_image_info(ostream &out, int indent_level) const { +write_image_info(std::ostream &out, int indent_level) const { Pages::const_iterator pai; for (pai = _pages.begin(); pai != _pages.end(); ++pai) { PalettePage *page = (*pai).second; diff --git a/pandatool/src/palettizer/paletteGroups.cxx b/pandatool/src/palettizer/paletteGroups.cxx index ae1f810d5e..c964f2b057 100644 --- a/pandatool/src/palettizer/paletteGroups.cxx +++ b/pandatool/src/palettizer/paletteGroups.cxx @@ -213,7 +213,7 @@ end() const { * */ void PaletteGroups:: -output(ostream &out) const { +output(std::ostream &out) const { if (!_groups.empty()) { // Sort the group names into order by name for output. pvector group_vector; @@ -239,7 +239,7 @@ output(ostream &out) const { * */ void PaletteGroups:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { // Sort the group names into order by name for output. pvector group_vector; group_vector.reserve(_groups.size()); diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index ee2ae01856..871b71ca40 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -476,7 +476,7 @@ resize_swapped_image(int x_size, int y_size) { * indicated output stream, one per line. */ void PaletteImage:: -write_placements(ostream &out, int indent_level) const { +write_placements(std::ostream &out, int indent_level) const { Placements::const_iterator pi; for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); @@ -712,9 +712,9 @@ bool PaletteImage:: setup_filename() { // Build up the basename for the palette image, based on the supplied image // pattern. - _basename = string(); + _basename = std::string(); - string::iterator si = pal->_generated_image_pattern.begin(); + std::string::iterator si = pal->_generated_image_pattern.begin(); while (si != pal->_generated_image_pattern.end()) { if ((*si) == '%') { // Some keycode. @@ -800,7 +800,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { } next_x = overlap->get_placed_x() + overlap->get_placed_x_size(); - next_y = min(next_y, overlap->get_placed_y() + overlap->get_placed_y_size()); + next_y = std::min(next_y, overlap->get_placed_y() + overlap->get_placed_y_size()); nassertr(next_x > x, false); x = next_x; } diff --git a/pandatool/src/palettizer/palettePage.cxx b/pandatool/src/palettizer/palettePage.cxx index adc73c660f..9bdc74c57e 100644 --- a/pandatool/src/palettizer/palettePage.cxx +++ b/pandatool/src/palettizer/palettePage.cxx @@ -141,7 +141,7 @@ unplace(TexturePlacement *placement) { * their textures, to the indicated output stream. */ void PalettePage:: -write_image_info(ostream &out, int indent_level) const { +write_image_info(std::ostream &out, int indent_level) const { Images::const_iterator ii; for (ii = _images.begin(); ii != _images.end(); ++ii) { PaletteImage *image = (*ii); diff --git a/pandatool/src/palettizer/palettizer.cxx b/pandatool/src/palettizer/palettizer.cxx index 3244fd396a..157c267730 100644 --- a/pandatool/src/palettizer/palettizer.cxx +++ b/pandatool/src/palettizer/palettizer.cxx @@ -29,6 +29,9 @@ #include "bamWriter.h" #include "indent.h" +using std::cout; +using std::string; + Palettizer *pal = nullptr; // This number is written out as the first number to the pi file, to indicate @@ -60,7 +63,7 @@ int Palettizer::_read_pi_version = 0; TypeHandle Palettizer::_type_handle; -ostream &operator << (ostream &out, Palettizer::RemapUV remap) { +std::ostream &operator << (std::ostream &out, Palettizer::RemapUV remap) { switch (remap) { case Palettizer::RU_never: return out << "never"; @@ -347,7 +350,7 @@ report_statistics() const { * files. */ void Palettizer:: -read_txa_file(istream &txa_file, const string &txa_filename) { +read_txa_file(std::istream &txa_file, const string &txa_filename) { // Clear out the group dependencies, in preparation for reading them again // from the .txa file. Groups::iterator gi; @@ -890,7 +893,7 @@ string_remap(const string &str) { * texture placements, and reports this to the indicated output stream. */ void Palettizer:: -compute_statistics(ostream &out, int indent_level, +compute_statistics(std::ostream &out, int indent_level, const Palettizer::Placements &placements) const { TextureMemoryCounter counter; @@ -1021,7 +1024,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { DCAST_INTO_R(texture, p_list[index], index); string name = downcase(texture->get_name()); - pair result = _textures.insert(Textures::value_type(name, texture)); + std::pair result = _textures.insert(Textures::value_type(name, texture)); if (!result.second) { // Two textures mapped to the same slot--probably a case error (since we // just changed this rule). diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index f33d01c408..612aa5b3c6 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -31,6 +31,8 @@ #include +using std::string; + TypeHandle TextureImage::_type_handle; /** @@ -661,7 +663,7 @@ copy_unplaced(bool redo_all) { Filename filename = dest->get_filename(); FilenameUnifier::make_canonical(filename); - pair insert_result = generate.insert + std::pair insert_result = generate.insert (Dests::value_type(filename, dest)); if (!insert_result.second) { // At least two DestTextureImages map to the same filename, no sweat. @@ -780,7 +782,7 @@ is_newer_than(const Filename &reference_filename) { * to the indicated output stream, one per line. */ void TextureImage:: -write_source_pathnames(ostream &out, int indent_level) const { +write_source_pathnames(std::ostream &out, int indent_level) const { Sources::const_iterator si; for (si = _sources.begin(); si != _sources.end(); ++si) { SourceTextureImage *source = (*si).second; @@ -853,7 +855,7 @@ write_source_pathnames(ostream &out, int indent_level) const { * Writes the information about the texture's size and placement. */ void TextureImage:: -write_scale_info(ostream &out, int indent_level) { +write_scale_info(std::ostream &out, int indent_level) { SourceTextureImage *source = get_preferred_source(); indent(out, indent_level) << get_name(); diff --git a/pandatool/src/palettizer/textureMemoryCounter.cxx b/pandatool/src/palettizer/textureMemoryCounter.cxx index 3c3f78b571..91281670c6 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.cxx +++ b/pandatool/src/palettizer/textureMemoryCounter.cxx @@ -81,7 +81,7 @@ add_placement(TexturePlacement *placement) { * Reports the measured texture memory usage. */ void TextureMemoryCounter:: -report(ostream &out, int indent_level) { +report(std::ostream &out, int indent_level) { indent(out, indent_level) << _num_placed << " of " << _num_textures << " textures appear on " << _num_palettes << " palette images with " << _num_unplaced @@ -120,8 +120,8 @@ report(ostream &out, int indent_level) { * Writes to the indicated ostream an indication of the fraction of the total * memory usage that is represented by fraction_bytes. */ -ostream &TextureMemoryCounter:: -format_memory_fraction(ostream &out, int fraction_bytes, int palette_bytes) { +std::ostream &TextureMemoryCounter:: +format_memory_fraction(std::ostream &out, int fraction_bytes, int palette_bytes) { out << floor(1000.0 * (double)fraction_bytes / (double)palette_bytes + 0.5) / 10.0 << "% (" << (fraction_bytes + 512) / 1024 << "k)"; return out; @@ -156,7 +156,7 @@ add_palette(PaletteImage *image) { */ void TextureMemoryCounter:: add_texture(TextureImage *texture, int bytes) { - pair result; + std::pair result; result = _textures.insert(Textures::value_type(texture, bytes)); if (result.second) { // If it was inserted, no problem--no duplicates. @@ -167,8 +167,8 @@ add_texture(TextureImage *texture, int bytes) { // If it was not inserted, we have a duplicate. Textures::iterator ti = result.first; - _duplicate_bytes += min(bytes, (*ti).second); - (*ti).second = max(bytes, (*ti).second); + _duplicate_bytes += std::min(bytes, (*ti).second); + (*ti).second = std::max(bytes, (*ti).second); } /** diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index 36331ed233..01f47b42a1 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -27,6 +27,9 @@ #include "bamWriter.h" #include "pnmImage.h" +using std::max; +using std::min; + TypeHandle TexturePlacement::_type_handle; /** @@ -88,7 +91,7 @@ TexturePlacement:: /** * Returns the name of the texture that this placement represents. */ -const string &TexturePlacement:: +const std::string &TexturePlacement:: get_name() const { return _texture->get_name(); } @@ -640,7 +643,7 @@ compute_tex_matrix(LMatrix3d &transform) { * Writes the placement position information on a line by itself. */ void TexturePlacement:: -write_placed(ostream &out, int indent_level) { +write_placed(std::ostream &out, int indent_level) { indent(out, indent_level) << get_texture()->get_name(); diff --git a/pandatool/src/palettizer/textureProperties.cxx b/pandatool/src/palettizer/textureProperties.cxx index 9538b85165..573dd784b3 100644 --- a/pandatool/src/palettizer/textureProperties.cxx +++ b/pandatool/src/palettizer/textureProperties.cxx @@ -20,6 +20,8 @@ #include "bamWriter.h" #include "string_utils.h" +using std::string; + TypeHandle TextureProperties::_type_handle; /** @@ -183,7 +185,7 @@ get_string() const { string result; if (_got_num_channels) { - ostringstream num; + std::ostringstream num; num << _effective_num_channels; result += num.str(); } diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index 7bb869c336..4a11b5348d 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -35,6 +35,10 @@ #include +using std::max; +using std::min; +using std::string; + TypeHandle TextureReference::_type_handle; /** @@ -455,7 +459,7 @@ apply_properties_to_source() { * */ void TextureReference:: -output(ostream &out) const { +output(std::ostream &out) const { out << *_source_texture; } @@ -463,7 +467,7 @@ output(ostream &out) const { * */ void TextureReference:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_texture()->get_name(); diff --git a/pandatool/src/palettizer/txaFile.cxx b/pandatool/src/palettizer/txaFile.cxx index 7aff6ad221..cb4cb5331d 100644 --- a/pandatool/src/palettizer/txaFile.cxx +++ b/pandatool/src/palettizer/txaFile.cxx @@ -20,6 +20,8 @@ #include "pnotify.h" #include "pnmFileTypeRegistry.h" +using std::string; + /** * */ @@ -32,7 +34,7 @@ TxaFile() { * there is an error. */ bool TxaFile:: -read(istream &in, const string &filename) { +read(std::istream &in, const string &filename) { string line; int line_number = 1; @@ -160,7 +162,7 @@ match_texture(TextureImage *texture) const { * output stream. This is primarily useful for debugging. */ void TxaFile:: -write(ostream &out) const { +write(std::ostream &out) const { Lines::const_iterator li; for (li = _lines.begin(); li != _lines.end(); ++li) { out << (*li) << "\n"; @@ -173,7 +175,7 @@ write(ostream &out) const { * line, or EOF if the end of file has been reached. */ int TxaFile:: -get_line_or_semicolon(istream &in, string &line) { +get_line_or_semicolon(std::istream &in, string &line) { line = string(); int ch = in.get(); char semicolon = ';'; diff --git a/pandatool/src/palettizer/txaLine.cxx b/pandatool/src/palettizer/txaLine.cxx index 51a1532610..41f9349c51 100644 --- a/pandatool/src/palettizer/txaLine.cxx +++ b/pandatool/src/palettizer/txaLine.cxx @@ -22,6 +22,8 @@ #include "pnotify.h" #include "pnmFileType.h" +using std::string; + /** * */ @@ -410,8 +412,8 @@ match_texture(TextureImage *texture) const { case ST_scale: if (source != nullptr && source->get_size()) { request._got_size = true; - request._x_size = max(1, (int)(source->get_x_size() * _scale / 100.0)); - request._y_size = max(1, (int)(source->get_y_size() * _scale / 100.0)); + request._x_size = std::max(1, (int)(source->get_x_size() * _scale / 100.0)); + request._y_size = std::max(1, (int)(source->get_y_size() * _scale / 100.0)); } break; @@ -523,7 +525,7 @@ match_texture(TextureImage *texture) const { * */ void TxaLine:: -output(ostream &out) const { +output(std::ostream &out) const { Patterns::const_iterator pi; for (pi = _texture_patterns.begin(); pi != _texture_patterns.end(); ++pi) { out << (*pi) << " "; diff --git a/pandatool/src/pandatoolbase/animationConvert.cxx b/pandatool/src/pandatoolbase/animationConvert.cxx index 6403da48cd..d09ce0f19f 100644 --- a/pandatool/src/pandatoolbase/animationConvert.cxx +++ b/pandatool/src/pandatoolbase/animationConvert.cxx @@ -19,7 +19,7 @@ /** * Returns the string corresponding to this method. */ -string +std::string format_animation_convert(AnimationConvert convert) { switch (convert) { case AC_invalid: @@ -53,8 +53,8 @@ format_animation_convert(AnimationConvert convert) { /** * */ -ostream & -operator << (ostream &out, AnimationConvert convert) { +std::ostream & +operator << (std::ostream &out, AnimationConvert convert) { return out << format_animation_convert(convert); } @@ -63,7 +63,7 @@ operator << (ostream &out, AnimationConvert convert) { * AnimationConvert types. Returns AC_invalid if the string is unknown. */ AnimationConvert -string_animation_convert(const string &str) { +string_animation_convert(const std::string &str) { if (cmp_nocase(str, "none") == 0) { return AC_none; diff --git a/pandatool/src/pandatoolbase/distanceUnit.cxx b/pandatool/src/pandatoolbase/distanceUnit.cxx index d2479de244..8ee495be3c 100644 --- a/pandatool/src/pandatoolbase/distanceUnit.cxx +++ b/pandatool/src/pandatoolbase/distanceUnit.cxx @@ -16,6 +16,10 @@ #include "string_utils.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + /** * Returns the string representing the common abbreviation for the given unit. */ diff --git a/pandatool/src/pandatoolbase/pathReplace.cxx b/pandatool/src/pandatoolbase/pathReplace.cxx index c3891cf047..b3b6bcb498 100644 --- a/pandatool/src/pandatoolbase/pathReplace.cxx +++ b/pandatool/src/pandatoolbase/pathReplace.cxx @@ -354,7 +354,7 @@ full_convert_path(const Filename &orig_filename, * */ void PathReplace:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { indent(out, indent_level) @@ -451,7 +451,7 @@ copy_this_file(Filename &filename) { * */ PathReplace::Entry:: -Entry(const string &orig_prefix, const string &replacement_prefix) : +Entry(const std::string &orig_prefix, const std::string &replacement_prefix) : _orig_prefix(orig_prefix), _replacement_prefix(replacement_prefix) { @@ -495,7 +495,7 @@ try_match(const Filename &filename, Filename &new_filename) const { } // We found a match. Construct the replacement string. - string result = _replacement_prefix; + std::string result = _replacement_prefix; while (mi < components.size()) { if (!result.empty()) { result += '/'; diff --git a/pandatool/src/pandatoolbase/pathStore.cxx b/pandatool/src/pandatoolbase/pathStore.cxx index d40fe3f276..dffacfe678 100644 --- a/pandatool/src/pandatoolbase/pathStore.cxx +++ b/pandatool/src/pandatoolbase/pathStore.cxx @@ -19,7 +19,7 @@ /** * Returns the string corresponding to this method. */ -string +std::string format_path_store(PathStore store) { switch (store) { case PS_invalid: @@ -47,8 +47,8 @@ format_path_store(PathStore store) { /** * */ -ostream & -operator << (ostream &out, PathStore store) { +std::ostream & +operator << (std::ostream &out, PathStore store) { return out << format_path_store(store); } @@ -57,7 +57,7 @@ operator << (ostream &out, PathStore store) { * PathStore types. Returns PS_invalid if the string is unknown. */ PathStore -string_path_store(const string &str) { +string_path_store(const std::string &str) { if (cmp_nocase(str, "relative") == 0 || cmp_nocase(str, "rel") == 0) { return PS_relative; diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 30804d8fea..ce0851a47f 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -77,7 +77,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { pofstream out; if (!bba_filename.open_write(out)) { - cerr << "Unable to open " << bba_filename << "\n"; + std::cerr << "Unable to open " << bba_filename << "\n"; return false; } diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index fdf803b601..ffb99b2472 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -21,6 +21,8 @@ #include "string_utils.h" #include "pandaFileStream.h" +using std::string; + /** * */ diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index e97a536127..9cdb70263d 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -45,6 +45,12 @@ #endif // TIOCGWINSZ #endif // IOCTL_TERMINAL_WIDTH +using std::cerr; +using std::cout; +using std::max; +using std::min; +using std::string; + bool ProgramBase::SortOptionsByIndex:: operator () (const Option *a, const Option *b) const { if (a->_index_group != b->_index_group) { @@ -181,7 +187,7 @@ show_text(const string &prefix, int indent_width, string text) { * This is useful when creating a man page for this utility. */ void ProgramBase:: -write_man_page(ostream &out) { +write_man_page(std::ostream &out) { string prog = _program_name.get_basename_wo_extension(); out << ".\\\" Automatically generated by " << prog << " -write-man\n"; @@ -296,7 +302,7 @@ parse_command_line(int argc, char **argv) { write_man_page(cout); } else { - pofstream man_out(argv[2], ios::out | ios::trunc); + pofstream man_out(argv[2], std::ios::out | std::ios::trunc); if (!man_out) { cerr << "Failed to open output file " << argv[2] << "!\n"; } @@ -1277,7 +1283,7 @@ handle_help_option(const string &, const string &, void *data) { * doubled newlines. */ void ProgramBase:: -format_text(ostream &out, bool &last_newline, +format_text(std::ostream &out, bool &last_newline, const string &prefix, int indent_width, const string &text, int line_width) { indent_width = min(indent_width, line_width - 20); diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index b88dec05d8..04e5005f0e 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -46,7 +46,7 @@ WithOutputFile:: * Returns an output stream that corresponds to the user's intended egg file * output--either stdout, or the named output file. */ -ostream &WithOutputFile:: +std::ostream &WithOutputFile:: get_output() { if (_output_ptr == nullptr) { if (!_got_output_filename) { @@ -55,7 +55,7 @@ get_output() { nout << "No output filename specified.\n"; exit(1); } - _output_ptr = &cout; + _output_ptr = &std::cout; _owns_output_ptr = false; } else { diff --git a/pandatool/src/progbase/wordWrapStream.cxx b/pandatool/src/progbase/wordWrapStream.cxx index a3ac50b99b..cd069d1eaa 100644 --- a/pandatool/src/progbase/wordWrapStream.cxx +++ b/pandatool/src/progbase/wordWrapStream.cxx @@ -19,7 +19,7 @@ */ WordWrapStream:: WordWrapStream(ProgramBase *program) : - ostream(&_lsb), + std::ostream(&_lsb), _lsb(this, program) { } diff --git a/pandatool/src/progbase/wordWrapStreamBuf.cxx b/pandatool/src/progbase/wordWrapStreamBuf.cxx index f8f4dced30..0e0c4abbcb 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.cxx +++ b/pandatool/src/progbase/wordWrapStreamBuf.cxx @@ -42,7 +42,7 @@ WordWrapStreamBuf:: */ int WordWrapStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n); // Send all the data out now. @@ -57,7 +57,7 @@ sync() { */ int WordWrapStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; @@ -81,10 +81,10 @@ void WordWrapStreamBuf:: write_chars(const char *start, int length) { if (length > 0) { set_literal_mode((_owner->flags() & Notify::get_literal_flag()) != 0); - string new_data(start, length); + std::string new_data(start, length); size_t newline = new_data.find_first_of("\n\r"); size_t p = 0; - while (newline != string::npos) { + while (newline != std::string::npos) { // The new data contains a newline; flush our data to that point. _data += new_data.substr(p, newline - p + 1); flush_data(); @@ -105,7 +105,7 @@ void WordWrapStreamBuf:: flush_data() { if (!_data.empty()) { if (_literal_mode) { - cerr << _data; + std::cerr << _data; } else { _program->show_text(_data); } diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index 77136b7f1d..26e06f069c 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -16,6 +16,8 @@ #include "pStatCollectorDef.h" +using std::string; + PStatCollectorDef PStatClientData::_null_collector(-1, "Unknown"); diff --git a/pandatool/src/pstatserver/pStatGraph.cxx b/pandatool/src/pstatserver/pStatGraph.cxx index f65dafbc3b..88130ff7ab 100644 --- a/pandatool/src/pstatserver/pStatGraph.cxx +++ b/pandatool/src/pstatserver/pStatGraph.cxx @@ -20,6 +20,8 @@ #include // for sprintf +using std::string; + /** * */ diff --git a/pandatool/src/pstatserver/pStatMonitor.cxx b/pandatool/src/pstatserver/pStatMonitor.cxx index f7e70727fe..09e22b093a 100644 --- a/pandatool/src/pstatserver/pStatMonitor.cxx +++ b/pandatool/src/pstatserver/pStatMonitor.cxx @@ -15,6 +15,8 @@ #include "pStatCollectorDef.h" +using std::string; + /** * diff --git a/pandatool/src/pstatserver/pStatReader.cxx b/pandatool/src/pstatserver/pStatReader.cxx index c302185e0f..02b01f26a2 100644 --- a/pandatool/src/pstatserver/pStatReader.cxx +++ b/pandatool/src/pstatserver/pStatReader.cxx @@ -123,7 +123,7 @@ get_monitor() { /** * Returns the current machine's hostname. */ -string PStatReader:: +std::string PStatReader:: get_hostname() { if (_hostname.empty()) { _hostname = ConnectionManager::get_host_name(); @@ -217,7 +217,7 @@ handle_client_control_message(const PStatClientControlMessage &message) { { for (int i = 0; i < (int)message._names.size(); i++) { int thread_index = message._first_thread_index + i; - string name = message._names[i]; + std::string name = message._names[i]; _client_data->define_thread(thread_index, name); _monitor->new_thread(thread_index); } diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 9b64abaa02..c9ffcb3109 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -22,6 +22,9 @@ #include +using std::max; +using std::min; + /** * */ @@ -248,9 +251,9 @@ get_collector_under_pixel(int xpoint, int ypoint) { /** * Returns the text suitable for the title label on the top line. */ -string PStatStripChart:: +std::string PStatStripChart:: get_title_text() { - string text; + std::string text; _title_unknown = false; diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index dade132585..9536b3fe65 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -47,7 +47,7 @@ LoaderFileTypePandatool:: /** * */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_name() const { if (_loader != nullptr) { return _loader->get_name(); @@ -58,7 +58,7 @@ get_name() const { /** * */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_extension() const { if (_loader != nullptr) { return _loader->get_extension(); @@ -70,7 +70,7 @@ get_extension() const { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_additional_extensions() const { if (_loader != nullptr) { return _loader->get_additional_extensions(); @@ -196,7 +196,7 @@ load_file(const Filename &path, const LoaderOptions &options, } delete loader; - return result.p(); + return result; } /** diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 86d98ab7db..ff0f624a20 100644 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -19,13 +19,15 @@ #include "softToEggConverter.h" #include "dcast.h" +using std::endl; + TypeHandle SoftNodeDesc::_type_handle; /** * */ SoftNodeDesc:: -SoftNodeDesc(SoftNodeDesc *parent, const string &name) : +SoftNodeDesc(SoftNodeDesc *parent, const std::string &name) : Namable(name), _parent(parent) { @@ -901,7 +903,7 @@ make_vertex_offsets(int numShapes) { SAA_Scene *scene = &stec.scene; EggVertexPool *vpool = nullptr; - string vpool_name = get_name() + ".verts"; + std::string vpool_name = get_name() + ".verts"; EggNode *t = stec._tree.get_egg_root()->find_child(vpool_name); if (t) DCAST_INTO_V(vpool, t); diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx index a896bce4e0..3b5be3252b 100644 --- a/pandatool/src/softegg/softNodeTree.cxx +++ b/pandatool/src/softegg/softNodeTree.cxx @@ -25,6 +25,8 @@ #include +using std::endl; + /** * */ @@ -288,7 +290,7 @@ get_node(int n) const { * Returns the node named 'name' in the hierarchy, in an arbitrary ordering. */ SoftNodeDesc *SoftNodeTree:: -get_node(string name) const { +get_node(std::string name) const { NodesByName::const_iterator ni = _nodes_by_name.find(name); if (ni != _nodes_by_name.end()) return (*ni).second; @@ -451,7 +453,7 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { SoftNodeDesc *SoftNodeTree:: build_node(SAA_Scene *scene, SAA_Elem *model) { char *name, *fullname; - string node_name; + std::string node_name; int numChildren; int thisChild; SAA_Elem *children; @@ -533,7 +535,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { * The recursive implementation of build_node(). */ SoftNodeDesc *SoftNodeTree:: -r_build_node(SoftNodeDesc *parent_node, const string &name) { +r_build_node(SoftNodeDesc *parent_node, const std::string &name) { SoftNodeDesc *node_desc; // If we have already encountered this pathname, return the corresponding diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index 3e0ab21ef6..44dafefb62 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -32,6 +32,9 @@ #include "string_utils.h" #include "dcast.h" +using std::endl; +using std::string; + SoftToEggConverter stec; const int TEX_PER_MAT = 1; diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index a0351b854e..478aa682d2 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -18,6 +18,8 @@ #include +using std::string; + /** * */ @@ -472,7 +474,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { * reference found, increments the appropriate element file's reference count. */ bool SoftCVS:: -scan_scene_file(istream &in, Multifile &multifile) { +scan_scene_file(std::istream &in, Multifile &multifile) { bool okflag = true; int c = in.get(); @@ -493,7 +495,7 @@ scan_scene_file(istream &in, Multifile &multifile) { SoftFilename v("", word); // Increment the use count on all matching elements of the multiset. - pair range; + std::pair range; range = _element_files.equal_range(v); ElementFiles::iterator ei; diff --git a/pandatool/src/softprogs/softFilename.cxx b/pandatool/src/softprogs/softFilename.cxx index 16d69de675..4c099c56be 100644 --- a/pandatool/src/softprogs/softFilename.cxx +++ b/pandatool/src/softprogs/softFilename.cxx @@ -15,6 +15,8 @@ #include "pnotify.h" +using std::string; + /** * */ diff --git a/pandatool/src/text-stats/textMonitor.cxx b/pandatool/src/text-stats/textMonitor.cxx index 69b134cc8f..2f4f458387 100644 --- a/pandatool/src/text-stats/textMonitor.cxx +++ b/pandatool/src/text-stats/textMonitor.cxx @@ -22,7 +22,7 @@ * */ TextMonitor:: -TextMonitor(TextStats *server, ostream *outStream, bool show_raw_data ) : PStatMonitor(server) { +TextMonitor(TextStats *server, std::ostream *outStream, bool show_raw_data ) : PStatMonitor(server) { _outStream = outStream; //[PECI] _show_raw_data = show_raw_data; } @@ -39,7 +39,7 @@ get_server() { * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string TextMonitor:: +std::string TextMonitor:: get_monitor_name() { return "Text Stats"; } diff --git a/pandatool/src/vrml/parse_vrml.cxx b/pandatool/src/vrml/parse_vrml.cxx index 1e55b68594..9ec700f19a 100644 --- a/pandatool/src/vrml/parse_vrml.cxx +++ b/pandatool/src/vrml/parse_vrml.cxx @@ -30,6 +30,10 @@ #include "zStream.h" #include "virtualFileSystem.h" +using std::istream; +using std::istringstream; +using std::string; + extern int vrmlyyparse(); extern void vrmlyyResetLineNumber(); extern int vrmlyydebug; @@ -99,7 +103,7 @@ parse_vrml(Filename filename) { VrmlScene * parse_vrml(istream &in, const string &filename) { if (!get_standard_nodes()) { - cerr << "Internal error--unable to parse VRML.\n"; + std::cerr << "Internal error--unable to parse VRML.\n"; return nullptr; } @@ -121,7 +125,7 @@ parse_vrml(istream &in, const string &filename) { int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "parse_vrml filename.wrl\n"; + std::cerr << "parse_vrml filename.wrl\n"; exit(1); } @@ -130,7 +134,7 @@ main(int argc, char *argv[]) { exit(1); } - cout << *scene << "\n"; + std::cout << *scene << "\n"; return (0); } #endif diff --git a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt index 87565a5ea2..8022d21f4b 100644 --- a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt @@ -2723,21 +2723,18 @@ int vrmlyy_flex_debug = 0; #define YY_RESTORE_YY_MORE_OFFSET char *vrmlyytext; #line 1 "vrmlLexer.lxx" -/* -// Filename: vrmlLexer.lxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * 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." + * + * @file vrmlLexer.lxx + * @author drose + * @date 2004-10-01 + */ /************************************************** * VRML 2.0 Parser * Copyright (C) 1996 Silicon Graphics, Inc. @@ -2774,13 +2771,13 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. -static string vrml_filename; +static std::string vrml_filename; -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); /* The YACC parser sets this to a token to direct the lexer */ /* in cases where just syntax isn't enough: */ @@ -2794,13 +2791,13 @@ static int sfImageIntsParsed = 0; static int sfImageIntsExpected = 0; // This is used while scanning a quoted string. -static string quoted_string; +static std::string quoted_string; // And this keeps track of the currently-parsing array. static MFArray *mfarray; void -vrml_init_lexer(istream &in, const string &filename) { +vrml_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ vrml_filename = filename; line_number = 0; @@ -2818,7 +2815,9 @@ vrmlyywrap(void) { } void -vrmlyyerror(const string &msg) { +vrmlyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -2831,7 +2830,9 @@ vrmlyyerror(const string &msg) { } void -vrmlyywarning(const string &msg) { +vrmlyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -2882,7 +2883,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index cd913fddc1..6b03b79894 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -1,18 +1,15 @@ -/* -// Filename: vrmlLexer.lxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * 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." + * + * @file vrmlLexer.lxx + * @author drose + * @date 2004-10-01 + */ /************************************************** * VRML 2.0 Parser @@ -50,13 +47,13 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. -static string vrml_filename; +static std::string vrml_filename; -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); /* The YACC parser sets this to a token to direct the lexer */ /* in cases where just syntax isn't enough: */ @@ -70,13 +67,13 @@ static int sfImageIntsParsed = 0; static int sfImageIntsExpected = 0; // This is used while scanning a quoted string. -static string quoted_string; +static std::string quoted_string; // And this keeps track of the currently-parsing array. static MFArray *mfarray; void -vrml_init_lexer(istream &in, const string &filename) { +vrml_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ vrml_filename = filename; line_number = 0; @@ -94,7 +91,9 @@ vrmlyywrap(void) { } void -vrmlyyerror(const string &msg) { +vrmlyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -107,7 +106,9 @@ vrmlyyerror(const string &msg) { } void -vrmlyywarning(const string &msg) { +vrmlyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -158,7 +159,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/vrml/vrmlNode.cxx b/pandatool/src/vrml/vrmlNode.cxx index 628e09fb31..c48ce35e4a 100644 --- a/pandatool/src/vrml/vrmlNode.cxx +++ b/pandatool/src/vrml/vrmlNode.cxx @@ -43,7 +43,7 @@ get_value(const char *field_name) const { return field->dflt; } - cerr << "No such field defined for type " << _type->getName() << ": " + std::cerr << "No such field defined for type " << _type->getName() << ": " << field_name << "\n"; exit(1); // Just to make the compiler happy. @@ -52,7 +52,7 @@ get_value(const char *field_name) const { } void VrmlNode:: -output(ostream &out, int indent_level) const { +output(std::ostream &out, int indent_level) const { out << _type->getName() << " {\n"; Fields::const_iterator fi; for (fi = _fields.begin(); fi != _fields.end(); ++fi) { @@ -64,13 +64,13 @@ output(ostream &out, int indent_level) const { void Declaration:: -output(ostream &out, int indent) const { +output(std::ostream &out, int indent) const { VrmlFieldValue v; v._sfnode = _node; output_value(out, v, SFNODE, indent); } -ostream &operator << (ostream &out, const VrmlScene &scene) { +std::ostream &operator << (std::ostream &out, const VrmlScene &scene) { VrmlScene::const_iterator si; for (si = scene.begin(); si != scene.end(); ++si) { out << (*si) << "\n"; diff --git a/pandatool/src/vrml/vrmlNodeType.cxx b/pandatool/src/vrml/vrmlNodeType.cxx index 923570bd81..56652507b5 100644 --- a/pandatool/src/vrml/vrmlNodeType.cxx +++ b/pandatool/src/vrml/vrmlNodeType.cxx @@ -20,6 +20,8 @@ #include // for sprintf() +using std::ostream; + // // Static list of node types. @@ -177,8 +179,8 @@ void VrmlNodeType::addToNameSpace(VrmlNodeType *_type) { if (find(_type->getName()) != nullptr) { - cerr << "PROTO " << _type->getName() << " already defined\n"; - return; + std::cerr << "PROTO " << _type->getName() << " already defined\n"; + return; } typeList.push_front(_type); } diff --git a/pandatool/src/vrml/vrmlParser.cxx.prebuilt b/pandatool/src/vrml/vrmlParser.cxx.prebuilt index 6eaddbf170..b94bc8d5ae 100644 --- a/pandatool/src/vrml/vrmlParser.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlParser.cxx.prebuilt @@ -151,14 +151,14 @@ void storeField(const VrmlFieldValue &value); void exitField(); void expect(int type); -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// void -vrml_init_parser(istream &in, const string &filename) { +vrml_init_parser(std::istream &in, const std::string &filename) { //yydebug = 0; vrml_init_lexer(in, filename); } @@ -2189,7 +2189,7 @@ endProto() // Add this proto definition: if (currentProtoStack.empty()) { - cerr << "Error: Empty PROTO stack!\n"; + std::cerr << "Error: Empty PROTO stack!\n"; } else { VrmlNodeType *t = currentProtoStack.top(); @@ -2232,14 +2232,14 @@ add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), int type = fieldType(typeString); if (type == 0) { - cerr << "Error: invalid field type: " << type << "\n"; + std::cerr << "Error: invalid field type: " << type << "\n"; } // Need to add support for Script nodes: // if (inScript) ... ??? if (currentProtoStack.empty()) { - cerr << "Error: declaration outside of prototype\n"; + std::cerr << "Error: declaration outside of prototype\n"; return 0; } VrmlNodeType *t = currentProtoStack.top(); @@ -2271,7 +2271,7 @@ fieldType(const char *type) if (strcmp(type, "MFVec2f") == 0) return MFVEC2F; if (strcmp(type, "MFVec3f") == 0) return MFVEC3F; - cerr << "Illegal field type: " << type << "\n"; + std::cerr << "Illegal field type: " << type << "\n"; return 0; } @@ -2306,7 +2306,7 @@ exitNode() nassertr(node != NULL, NULL); currentNode.pop(); - // cerr << "Just defined node:\n" << *node << "\n\n"; + // std::cerr << "Just defined node:\n" << *node << "\n\n"; delete fr; return node; @@ -2346,7 +2346,7 @@ enterField(const char *fieldName) expect(typeRec->type); } else { - cerr << "Error: Nodes of type " << fr->nodeType->getName() << + std::cerr << "Error: Nodes of type " << fr->nodeType->getName() << " do not have fields/eventIn/eventOut named " << fieldName << "\n"; // expect(ANY_FIELD); diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index d114028828..9bbdda7bf6 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -94,14 +94,14 @@ void storeField(const VrmlFieldValue &value); void exitField(); void expect(int type); -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// void -vrml_init_parser(istream &in, const string &filename) { +vrml_init_parser(std::istream &in, const std::string &filename) { //yydebug = 0; vrml_init_lexer(in, filename); } @@ -132,7 +132,7 @@ vrml_cleanup_parser() { * %type vrmlscene declarations */ -%token IDENTIFIER +%token IDENTIFIER %token DEF USE PROTO EXTERNPROTO TO IS ROUTE SFN_NULL %token EVENTIN EVENTOUT FIELD EXPOSEDFIELD @@ -370,7 +370,7 @@ endProto() // Add this proto definition: if (currentProtoStack.empty()) { - cerr << "Error: Empty PROTO stack!\n"; + std::cerr << "Error: Empty PROTO stack!\n"; } else { VrmlNodeType *t = currentProtoStack.top(); @@ -413,14 +413,14 @@ add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), int type = fieldType(typeString); if (type == 0) { - cerr << "Error: invalid field type: " << type << "\n"; + std::cerr << "Error: invalid field type: " << type << "\n"; } // Need to add support for Script nodes: // if (inScript) ... ??? if (currentProtoStack.empty()) { - cerr << "Error: declaration outside of prototype\n"; + std::cerr << "Error: declaration outside of prototype\n"; return 0; } VrmlNodeType *t = currentProtoStack.top(); @@ -452,7 +452,7 @@ fieldType(const char *type) if (strcmp(type, "MFVec2f") == 0) return MFVEC2F; if (strcmp(type, "MFVec3f") == 0) return MFVEC3F; - cerr << "Illegal field type: " << type << "\n"; + std::cerr << "Illegal field type: " << type << "\n"; return 0; } @@ -487,7 +487,7 @@ exitNode() nassertr(node != nullptr, nullptr); currentNode.pop(); - // cerr << "Just defined node:\n" << *node << "\n\n"; + // std::cerr << "Just defined node:\n" << *node << "\n\n"; delete fr; return node; @@ -527,7 +527,7 @@ enterField(const char *fieldName) expect(typeRec->type); } else { - cerr << "Error: Nodes of type " << fr->nodeType->getName() << + std::cerr << "Error: Nodes of type " << fr->nodeType->getName() << " do not have fields/eventIn/eventOut named " << fieldName << "\n"; // expect(ANY_FIELD); diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index 35e03857fc..0f0dce8e68 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -22,6 +22,8 @@ #include "eggVertexPool.h" #include "eggPolygon.h" +using std::cerr; + /** * */ diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 150cf6da4c..d308e34714 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -57,7 +57,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string VRMLToEggConverter:: +std::string VRMLToEggConverter:: get_name() const { return "VRML"; } @@ -65,7 +65,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string VRMLToEggConverter:: +std::string VRMLToEggConverter:: get_extension() const { return "wrl"; } @@ -145,7 +145,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { nassertv(vrml._name != nullptr); ni = nodes.find(vrml._name); if (ni == nodes.end()) { - cerr << "Unknown node reference: " << vrml._name << "\n"; + std::cerr << "Unknown node reference: " << vrml._name << "\n"; } else { // Increment the use count of the node. (*ni).second->_use_count++; @@ -214,7 +214,7 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform)) { const VrmlNode *node = vrml._p; nassertv(node != nullptr); - string name; + std::string name; if (vrml._name != nullptr) { name = vrml._name; } @@ -376,7 +376,7 @@ vrml_shape(const VrmlNode *node, EggGroup *group, IndexedFaceSet ifs(geometry, appearance); ifs.convert_to_egg(group, net_transform); } else { - cerr << "Ignoring " << geometry->_type->getName() << "\n"; + std::cerr << "Ignoring " << geometry->_type->getName() << "\n"; } } } diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index 0b22e9e0d7..7818ea5ed8 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -62,9 +62,9 @@ create_toplevel_window(HINSTANCE application) { DWORD window_style = WS_POPUP | WS_SYSMENU | WS_ICONIC; - ostringstream strm; + std::ostringstream strm; strm << "PStats " << pstats_port; - string window_name = strm.str(); + std::string window_name = strm.str(); HWND toplevel_window = CreateWindow(toplevel_class_name, window_name.c_str(), window_style, @@ -87,12 +87,12 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // Create the server object. server = new WinStatsServer; if (!server->listen()) { - ostringstream stream; + std::ostringstream stream; stream << "Unable to open port " << pstats_port << ". Try specifying a different\n" << "port number using pstats-port in your Config file."; - string str = stream.str(); + std::string str = stream.str(); MessageBox(toplevel_window, str.c_str(), "PStats error", MB_OK | MB_ICONEXCLAMATION); exit(1); diff --git a/pandatool/src/win-stats/winStatsChartMenu.cxx b/pandatool/src/win-stats/winStatsChartMenu.cxx index faeb59d874..c042acf8ba 100644 --- a/pandatool/src/win-stats/winStatsChartMenu.cxx +++ b/pandatool/src/win-stats/winStatsChartMenu.cxx @@ -47,7 +47,7 @@ get_menu_handle() { void WinStatsChartMenu:: add_to_menu_bar(HMENU menu_bar, int before_menu_id) { const PStatClientData *client_data = _monitor->get_client_data(); - string thread_name; + std::string thread_name; if (_thread_index == 0) { // A special case for the main thread. thread_name = "Graphs"; @@ -149,7 +149,7 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { int collector = view_level->get_collector(); const PStatClientData *client_data = _monitor->get_client_data(); - string collector_name = client_data->get_collector_name(collector); + std::string collector_name = client_data->get_collector_name(collector); WinStatsMonitor::MenuDef menu_def(_thread_index, collector, show_level); int menu_id = _monitor->get_menu_id(menu_def); @@ -169,7 +169,7 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { // If the collector has more than one child, add a menu entry to go // directly to each of its children. HMENU submenu = CreatePopupMenu(); - string submenu_name = collector_name + " components"; + std::string submenu_name = collector_name + " components"; mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; mii.fType = MFT_STRING; diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 6eb19583f6..4946bbc671 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -467,8 +467,8 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz void WinStatsGraph:: setup_bitmap(int xsize, int ysize) { release_bitmap(); - _bitmap_xsize = max(xsize, 0); - _bitmap_ysize = max(ysize, 0); + _bitmap_xsize = std::max(xsize, 0); + _bitmap_ysize = std::max(ysize, 0); HDC hdc = GetDC(_graph_window); _bitmap_dc = CreateCompatibleDC(hdc); @@ -508,7 +508,7 @@ create_graph_window() { HINSTANCE application = GetModuleHandle(nullptr); register_graph_window_class(application); - string window_title = "graph"; + std::string window_title = "graph"; DWORD window_style = WS_CHILD | WS_CLIPSIBLINGS; _graph_window = diff --git a/pandatool/src/win-stats/winStatsLabelStack.cxx b/pandatool/src/win-stats/winStatsLabelStack.cxx index 063a7780e8..af3bcccd00 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.cxx +++ b/pandatool/src/win-stats/winStatsLabelStack.cxx @@ -61,7 +61,7 @@ setup(HWND parent_window) { for (li = _labels.begin(); li != _labels.end(); ++li) { WinStatsLabel *label = (*li); label->setup(_window); - _ideal_width = max(_ideal_width, label->get_ideal_width()); + _ideal_width = std::max(_ideal_width, label->get_ideal_width()); } } @@ -192,7 +192,7 @@ add_label(WinStatsMonitor *monitor, WinStatsGraph *graph, label->setup(_window); label->set_pos(0, yp, _width); } - _ideal_width = max(_ideal_width, label->get_ideal_width()); + _ideal_width = std::max(_ideal_width, label->get_ideal_width()); int label_index = (int)_labels.size(); _labels.push_back(label); diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index 1b2cedee37..50c66362d1 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -71,7 +71,7 @@ WinStatsMonitor:: * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string WinStatsMonitor:: +std::string WinStatsMonitor:: get_monitor_name() { return "WinStats"; } @@ -107,7 +107,7 @@ got_hello() { void WinStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { - ostringstream str; + std::ostringstream str; str << "Unable to honor connection attempt from " << get_client_progname() << " on " << get_client_hostname() << ": unsupported PStats version " @@ -121,7 +121,7 @@ got_bad_version(int client_major, int client_minor, << ".0 through " << server_major << "." << server_minor << ")."; } - string message = str.str(); + std::string message = str.str(); MessageBox(nullptr, message.c_str(), "Bad version", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index 7c81b65fdf..859de11b68 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -468,7 +468,7 @@ draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) { } int x = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; SIZE size; GetTextExtentPoint32(hdc, label.data(), label.length(), &size); @@ -502,8 +502,8 @@ create_window() { const PStatClientData *client_data = WinStatsGraph::_monitor->get_client_data(); - string thread_name = client_data->get_thread_name(_thread_index); - string window_title = thread_name + " thread piano roll"; + std::string thread_name = client_data->get_thread_name(_thread_index); + std::string window_title = thread_name + " thread piano roll"; RECT win_rect = { diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 79411a03d7..879b920673 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -16,6 +16,8 @@ #include "pStatCollectorDef.h" #include "numeric_types.h" +using std::string; + static const int default_strip_chart_width = 400; static const int default_strip_chart_height = 100; diff --git a/pandatool/src/xfile/windowsGuid.cxx b/pandatool/src/xfile/windowsGuid.cxx index 101e2b98cf..fbe649673c 100644 --- a/pandatool/src/xfile/windowsGuid.cxx +++ b/pandatool/src/xfile/windowsGuid.cxx @@ -16,6 +16,8 @@ #include // for sscanf, sprintf +using std::string; + /** * Parses the hex representation in the indicated string and stores it in the * WindowsGuid object. Returns true if successful, false if the string @@ -69,6 +71,6 @@ format_string() const { * Outputs a hex representation of the GUID. */ void WindowsGuid:: -output(ostream &out) const { +output(std::ostream &out) const { out << format_string(); } diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 17fc9f1e34..c5534e0af1 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -22,6 +22,11 @@ #include "virtualFileSystem.h" #include "dcast.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::string; + TypeHandle XFile::_type_handle; PT(XFile) XFile::_standard_templates; diff --git a/pandatool/src/xfile/xFileArrayDef.cxx b/pandatool/src/xfile/xFileArrayDef.cxx index da5abf9f51..91078f5576 100644 --- a/pandatool/src/xfile/xFileArrayDef.cxx +++ b/pandatool/src/xfile/xFileArrayDef.cxx @@ -38,7 +38,7 @@ get_size(const XFileNode::PrevData &prev_data) const { * */ void XFileArrayDef:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_fixed_size()) { out << "[" << _fixed_size << "]"; } else { diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index 6c133347ef..5fe983891b 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -53,7 +53,7 @@ add_array_def(const XFileArrayDef &array_def) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataDef:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level); if (!_array_def.empty()) { @@ -376,7 +376,7 @@ unpack_template_value(const XFileParseDataList &parse_data_list, return nullptr; } - return data_value.p(); + return data_value; } /** @@ -405,7 +405,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, for (int i = 0; i < array_size; i++) { if (index >= parse_data_list._list.size()) { - xyyerror(string("Expected ") + format_string(array_size) + xyyerror(std::string("Expected ") + format_string(array_size) + " array elements, found " + format_string(i)); return data_value; } diff --git a/pandatool/src/xfile/xFileDataNode.cxx b/pandatool/src/xfile/xFileDataNode.cxx index d0ebb6dba8..bc1326697e 100644 --- a/pandatool/src/xfile/xFileDataNode.cxx +++ b/pandatool/src/xfile/xFileDataNode.cxx @@ -20,7 +20,7 @@ TypeHandle XFileDataNode::_type_handle; * */ XFileDataNode:: -XFileDataNode(XFile *x_file, const string &name, +XFileDataNode(XFile *x_file, const std::string &name, XFileTemplate *xtemplate) : XFileNode(x_file, name), _template(xtemplate) @@ -46,7 +46,7 @@ is_object() const { * object must be of type XFileDataNode. */ bool XFileDataNode:: -is_standard_object(const string &template_name) const { +is_standard_object(const std::string &template_name) const { if (_template->is_standard() && _template->get_name() == template_name) { return true; @@ -59,7 +59,7 @@ is_standard_object(const string &template_name) const { * Returns a string that represents the type of object this data object * represents. */ -string XFileDataNode:: +std::string XFileDataNode:: get_type_name() const { return _template->get_name(); } diff --git a/pandatool/src/xfile/xFileDataNodeReference.cxx b/pandatool/src/xfile/xFileDataNodeReference.cxx index 157acdbba6..7796aeeeda 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.cxx +++ b/pandatool/src/xfile/xFileDataNodeReference.cxx @@ -62,7 +62,7 @@ is_complex_object() const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeReference:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << "{ " << _object->get_name() << " }\n"; } @@ -89,6 +89,6 @@ get_element(int n) { * name. */ XFileDataObject *XFileDataNodeReference:: -get_element(const string &name) { +get_element(const std::string &name) { return &((*_object)[name]); } diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.cxx b/pandatool/src/xfile/xFileDataNodeTemplate.cxx index 9f09cc0583..6464716964 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.cxx +++ b/pandatool/src/xfile/xFileDataNodeTemplate.cxx @@ -17,6 +17,8 @@ #include "xLexerDefs.h" #include "config_xfile.h" +using std::string; + TypeHandle XFileDataNodeTemplate::_type_handle; /** @@ -127,7 +129,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeTemplate:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << _template->get_name(); if (has_name()) { @@ -149,7 +151,7 @@ write_text(ostream &out, int indent_level) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeTemplate:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { bool indented = false; for (size_t i = 0; i < _nested_elements.size() - 1; i++) { diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index 5abfa1e9ab..f3cf0b0303 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -21,6 +21,8 @@ #include "config_xfile.h" #include "indent.h" +using std::string; + TypeHandle XFileDataObject::_type_handle; /** @@ -168,7 +170,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObject:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << "(" << get_type() << "::output_data() not implemented.)"; } @@ -176,7 +178,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObject:: -write_data(ostream &out, int indent_level, const char *) const { +write_data(std::ostream &out, int indent_level, const char *) const { indent(out, indent_level) << "(" << get_type() << "::write_data() not implemented.)\n"; } diff --git a/pandatool/src/xfile/xFileDataObjectArray.cxx b/pandatool/src/xfile/xFileDataObjectArray.cxx index 10aa13d5f2..e648ef2c17 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.cxx +++ b/pandatool/src/xfile/xFileDataObjectArray.cxx @@ -41,7 +41,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectArray:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { bool indented = false; for (size_t i = 0; i < _nested_elements.size() - 1; i++) { diff --git a/pandatool/src/xfile/xFileDataObjectDouble.cxx b/pandatool/src/xfile/xFileDataObjectDouble.cxx index 3abd4fa909..d17b2bbb1e 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.cxx +++ b/pandatool/src/xfile/xFileDataObjectDouble.cxx @@ -31,7 +31,7 @@ XFileDataObjectDouble(const XFileDataDef *data_def, double value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectDouble:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << get_string_value(); } @@ -39,7 +39,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectDouble:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << get_string_value() << separator << "\n"; } @@ -79,7 +79,7 @@ get_double_value() const { /** * Returns the object's representation as a string, if it has one. */ -string XFileDataObjectDouble:: +std::string XFileDataObjectDouble:: get_string_value() const { // It's important to format with a decimal point, even if the value is // integral, since the DirectX .x reader differentiates betweens doubles and diff --git a/pandatool/src/xfile/xFileDataObjectInteger.cxx b/pandatool/src/xfile/xFileDataObjectInteger.cxx index 821363f339..ee3c539d68 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.cxx +++ b/pandatool/src/xfile/xFileDataObjectInteger.cxx @@ -31,7 +31,7 @@ XFileDataObjectInteger(const XFileDataDef *data_def, int value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectInteger:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << _value; } @@ -39,7 +39,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectInteger:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << _value << separator << "\n"; } @@ -71,7 +71,7 @@ get_double_value() const { /** * Returns the object's representation as a string, if it has one. */ -string XFileDataObjectInteger:: +std::string XFileDataObjectInteger:: get_string_value() const { return format_string(_value); } diff --git a/pandatool/src/xfile/xFileDataObjectString.cxx b/pandatool/src/xfile/xFileDataObjectString.cxx index 3425925b22..99ef31a89f 100644 --- a/pandatool/src/xfile/xFileDataObjectString.cxx +++ b/pandatool/src/xfile/xFileDataObjectString.cxx @@ -15,6 +15,8 @@ #include "string_utils.h" #include "indent.h" +using std::string; + TypeHandle XFileDataObjectString::_type_handle; /** @@ -31,7 +33,7 @@ XFileDataObjectString(const XFileDataDef *data_def, const string &value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectString:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { enquote_string(out); } @@ -39,7 +41,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectString:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level); enquote_string(out); out << separator << "\n"; @@ -66,7 +68,7 @@ get_string_value() const { * special characters as needed. */ void XFileDataObjectString:: -enquote_string(ostream &out) const { +enquote_string(std::ostream &out) const { // Actually, the XFile spec doesn't tell us how to escape special characters // within quotation marks. We'll just take a stab in the dark here. diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index a67c7488d0..51c795e42a 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -21,6 +21,8 @@ #include "filename.h" #include "string_utils.h" +using std::string; + TypeHandle XFileNode::_type_handle; /** @@ -214,7 +216,7 @@ clear() { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileNode:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { (*ci)->write_text(out, indent_level); diff --git a/pandatool/src/xfile/xFileParseData.cxx b/pandatool/src/xfile/xFileParseData.cxx index aeafa42a6f..0fcd8dbef9 100644 --- a/pandatool/src/xfile/xFileParseData.cxx +++ b/pandatool/src/xfile/xFileParseData.cxx @@ -34,6 +34,6 @@ XFileParseData() : * from which this object was originally parsed. */ void XFileParseData:: -yyerror(const string &message) const { +yyerror(const std::string &message) const { xyyerror(message, _line_number, _col_number, _current_line); } diff --git a/pandatool/src/xfile/xFileTemplate.cxx b/pandatool/src/xfile/xFileTemplate.cxx index 5c9691d02a..e4ef5e2c17 100644 --- a/pandatool/src/xfile/xFileTemplate.cxx +++ b/pandatool/src/xfile/xFileTemplate.cxx @@ -20,7 +20,7 @@ TypeHandle XFileTemplate::_type_handle; * */ XFileTemplate:: -XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid) : +XFileTemplate(XFile *x_file, const std::string &name, const WindowsGuid &guid) : XFileNode(x_file, name), _guid(guid), _is_standard(false), @@ -79,7 +79,7 @@ clear() { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileTemplate:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << "template " << get_name() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/xfile/xLexer.cxx.prebuilt b/pandatool/src/xfile/xLexer.cxx.prebuilt index a52c858c96..92eb941a15 100644 --- a/pandatool/src/xfile/xLexer.cxx.prebuilt +++ b/pandatool/src/xfile/xLexer.cxx.prebuilt @@ -643,12 +643,11 @@ goto find_rule; \ #define YY_RESTORE_YY_MORE_OFFSET char *xyytext; #line 1 "xLexer.lxx" -/* -// Filename: xLexer.lxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * @file xLexer.lxx + * @author drose + * @date 2004-10-03 + */ #line 9 "xLexer.lxx" #include "xLexerDefs.h" #include "xParserDefs.h" @@ -678,11 +677,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. -static string x_filename; +static std::string x_filename; //////////////////////////////////////////////////////////////////// @@ -690,7 +689,7 @@ static string x_filename; //////////////////////////////////////////////////////////////////// void -x_init_lexer(istream &in, const string &filename) { +x_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ x_filename = filename; x_line_number = 0; @@ -720,13 +719,13 @@ xyywrap(void) { } void -xyyerror(const string &msg) { +xyyerror(const std::string &msg) { xyyerror(msg, x_line_number, x_col_number, x_current_line); } void -xyyerror(const string &msg, int line_number, int col_number, - const string ¤t_line) { +xyyerror(const std::string &msg, int line_number, int col_number, + const std::string ¤t_line) { xfile_cat.error(false) << "\nError"; if (!x_filename.empty()) { xfile_cat.error(false) << " in " << x_filename; @@ -741,7 +740,7 @@ xyyerror(const string &msg, int line_number, int col_number, } void -xyywarning(const string &msg) { +xyywarning(const std::string &msg) { xfile_cat.warning(false) << "\nWarning"; if (!x_filename.empty()) { xfile_cat.warning(false) << " in " << x_filename; @@ -795,7 +794,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -817,9 +816,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -939,7 +938,7 @@ scan_quoted_string(char quote_mark) { // scan_guid_string reads a string of hexadecimal digits delimited by // angle brackets and returns the corresponding string. -static string +static std::string scan_guid_string() { // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -956,7 +955,7 @@ scan_guid_string() { int num_digits = 0; int num_hyphens = 0; - string result; + std::string result; int c; c = read_char(line, col); @@ -971,7 +970,7 @@ scan_guid_string() { x_line_number = line; x_col_number = col; xyyerror("Invalid character in GUID."); - return string(); + return std::string(); } result += c; @@ -981,15 +980,15 @@ scan_guid_string() { if (c == EOF) { xyyerror("This GUID string is unterminated."); - return string(); + return std::string(); } else if (num_digits != 32) { xyyerror("Incorrect number of hex digits in GUID."); - return string(); + return std::string(); } else if (num_hyphens != 4) { xyyerror("Incorrect number of hyphens in GUID."); - return string(); + return std::string(); } x_line_number = line; @@ -1000,7 +999,7 @@ scan_guid_string() { // Parses the text into a list of integers and returns them. static PTA_int -scan_int_list(const string &text) { +scan_int_list(const std::string &text) { PTA_int result; vector_string words; @@ -1008,7 +1007,7 @@ scan_int_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { int number = 0; string_to_int(trimmed, number); @@ -1021,7 +1020,7 @@ scan_int_list(const string &text) { // Parses the text into a list of doubles and returns them. static PTA_double -scan_double_list(const string &text) { +scan_double_list(const std::string &text) { PTA_double result; vector_string words; @@ -1029,7 +1028,7 @@ scan_double_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { double number = 0.0; string_to_double(trimmed, number); @@ -1655,7 +1654,7 @@ YY_RULE_SETUP { // Any other character is invalid. accept(); - xyyerror("Invalid character '" + string(xyytext) + "'."); + xyyerror("Invalid character '" + std::string(xyytext) + "'."); } YY_BREAK case 35: diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index 614679ff34..7a5aac98a1 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -1,9 +1,8 @@ -/* -// Filename: xLexer.lxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * @file xLexer.lxx + * @author drose + * @date 2004-10-03 + */ %{ #include "xLexerDefs.h" @@ -34,11 +33,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. -static string x_filename; +static std::string x_filename; //////////////////////////////////////////////////////////////////// @@ -46,7 +45,7 @@ static string x_filename; //////////////////////////////////////////////////////////////////// void -x_init_lexer(istream &in, const string &filename) { +x_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ x_filename = filename; x_line_number = 0; @@ -76,13 +75,13 @@ xyywrap(void) { } void -xyyerror(const string &msg) { +xyyerror(const std::string &msg) { xyyerror(msg, x_line_number, x_col_number, x_current_line); } void -xyyerror(const string &msg, int line_number, int col_number, - const string ¤t_line) { +xyyerror(const std::string &msg, int line_number, int col_number, + const std::string ¤t_line) { xfile_cat.error(false) << "\nError"; if (!x_filename.empty()) { xfile_cat.error(false) << " in " << x_filename; @@ -97,7 +96,7 @@ xyyerror(const string &msg, int line_number, int col_number, } void -xyywarning(const string &msg) { +xyywarning(const std::string &msg) { xfile_cat.warning(false) << "\nWarning"; if (!x_filename.empty()) { xfile_cat.warning(false) << " in " << x_filename; @@ -151,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -173,9 +172,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -295,7 +294,7 @@ scan_quoted_string(char quote_mark) { // scan_guid_string reads a string of hexadecimal digits delimited by // angle brackets and returns the corresponding string. -static string +static std::string scan_guid_string() { // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -312,7 +311,7 @@ scan_guid_string() { int num_digits = 0; int num_hyphens = 0; - string result; + std::string result; int c; c = read_char(line, col); @@ -327,7 +326,7 @@ scan_guid_string() { x_line_number = line; x_col_number = col; xyyerror("Invalid character in GUID."); - return string(); + return std::string(); } result += c; @@ -337,15 +336,15 @@ scan_guid_string() { if (c == EOF) { xyyerror("This GUID string is unterminated."); - return string(); + return std::string(); } else if (num_digits != 32) { xyyerror("Incorrect number of hex digits in GUID."); - return string(); + return std::string(); } else if (num_hyphens != 4) { xyyerror("Incorrect number of hyphens in GUID."); - return string(); + return std::string(); } x_line_number = line; @@ -356,7 +355,7 @@ scan_guid_string() { // Parses the text into a list of integers and returns them. static PTA_int -scan_int_list(const string &text) { +scan_int_list(const std::string &text) { PTA_int result; vector_string words; @@ -364,7 +363,7 @@ scan_int_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { int number = 0; string_to_int(trimmed, number); @@ -377,7 +376,7 @@ scan_int_list(const string &text) { // Parses the text into a list of doubles and returns them. static PTA_double -scan_double_list(const string &text) { +scan_double_list(const std::string &text) { PTA_double result; vector_string words; @@ -385,7 +384,7 @@ scan_double_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { double number = 0.0; string_to_double(trimmed, number); @@ -621,5 +620,5 @@ WHITESPACE [ ]+ . { // Any other character is invalid. accept(); - xyyerror("Invalid character '" + string(xyytext) + "'."); + xyyerror("Invalid character '" + std::string(xyytext) + "'."); } diff --git a/pandatool/src/xfile/xParser.cxx.prebuilt b/pandatool/src/xfile/xParser.cxx.prebuilt index 42c65a72a6..0d12c68d03 100644 --- a/pandatool/src/xfile/xParser.cxx.prebuilt +++ b/pandatool/src/xfile/xParser.cxx.prebuilt @@ -105,7 +105,7 @@ static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// void -x_init_parser(istream &in, const string &filename, XFile &file) { +x_init_parser(std::istream &in, const std::string &filename, XFile &file) { x_file = &file; current_node = &file; x_init_lexer(in, filename); @@ -1803,7 +1803,7 @@ yyreduce: /* Line 1464 of yacc.c */ #line 325 "xParser.yxx" { - (yyval.str) = string(); + (yyval.str) = std::string(); } break; diff --git a/pandatool/src/xfile/xParser.yxx b/pandatool/src/xfile/xParser.yxx index 0f151c70ec..0352a4d454 100644 --- a/pandatool/src/xfile/xParser.yxx +++ b/pandatool/src/xfile/xParser.yxx @@ -39,7 +39,7 @@ static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// void -x_init_parser(istream &in, const string &filename, XFile &file) { +x_init_parser(std::istream &in, const std::string &filename, XFile &file) { x_file = &file; current_node = &file; x_init_lexer(in, filename); @@ -324,7 +324,7 @@ multiword_name: optional_multiword_name: empty { - $$ = string(); + $$ = std::string(); } | multiword_name ; diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index 112b61ba12..f76bc33ee9 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -59,7 +59,7 @@ create_hierarchy(XFileToEggConverter *converter) { // Now populate those empty tables with the frame data. JointData::const_iterator ji; for (ji = _joint_data.begin(); ji != _joint_data.end(); ++ji) { - const string &joint_name = (*ji).first; + const std::string &joint_name = (*ji).first; const FrameData &table = (*ji).second; EggXfmSAnim *anim_table = get_table(joint_name); @@ -98,7 +98,7 @@ create_hierarchy(XFileToEggConverter *converter) { * Returns the table associated with the indicated joint name. */ EggXfmSAnim *XFileAnimationSet:: -get_table(const string &joint_name) const { +get_table(const std::string &joint_name) const { Tables::const_iterator ti; ti = _tables.find(joint_name); if (ti != _tables.end()) { @@ -112,7 +112,7 @@ get_table(const string &joint_name) const { * joint. */ XFileAnimationSet::FrameData &XFileAnimationSet:: -create_frame_data(const string &joint_name) { +create_frame_data(const std::string &joint_name) { return _joint_data[joint_name]; } diff --git a/pandatool/src/xfileegg/xFileMaker.cxx b/pandatool/src/xfileegg/xFileMaker.cxx index 915fa4ff20..e3d07cea0b 100644 --- a/pandatool/src/xfileegg/xFileMaker.cxx +++ b/pandatool/src/xfileegg/xFileMaker.cxx @@ -234,7 +234,7 @@ bool XFileMaker:: finalize_mesh(XFileNode *x_parent, XFileMesh *mesh) { // Get a unique number for each mesh. _mesh_index++; - string mesh_index = format_string(_mesh_index); + std::string mesh_index = format_string(_mesh_index); // Finally, create the Mesh object. mesh->make_x_mesh(x_parent, mesh_index); diff --git a/pandatool/src/xfileegg/xFileMaterial.cxx b/pandatool/src/xfileegg/xFileMaterial.cxx index 4efa732b4d..11457ebcd5 100644 --- a/pandatool/src/xfileegg/xFileMaterial.cxx +++ b/pandatool/src/xfileegg/xFileMaterial.cxx @@ -161,7 +161,7 @@ has_texture() const { * Creates a Material object for the material list. */ XFileDataNode *XFileMaterial:: -make_x_material(XFileNode *x_meshMaterials, const string &suffix) { +make_x_material(XFileNode *x_meshMaterials, const std::string &suffix) { XFileDataNode *x_material = x_meshMaterials->add_Material("material" + suffix, _face_color, _power, diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 9ddf66bc0e..4fad113ed4 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -24,6 +24,9 @@ #include "eggPolygon.h" #include "eggGroupNode.h" +using std::min; +using std::string; + /** * */ @@ -111,7 +114,7 @@ add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) { _has_uvs = true; } - pair result = + std::pair result = _unique_vertices.insert(UniqueVertices::value_type(vertex, next_index)); if (result.second) { @@ -140,7 +143,7 @@ add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim) { _has_normals = true; } - pair result = + std::pair result = _unique_normals.insert(UniqueNormals::value_type(normal, next_index)); if (result.second) { @@ -168,7 +171,7 @@ add_material(EggPrimitive *egg_prim) { _has_materials = true; } - pair result = + std::pair result = _unique_materials.insert(UniqueMaterials::value_type(material, next_index)); if (result.second) { diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 2f65643c0f..130c42546e 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -26,6 +26,8 @@ #include "eggTextureCollection.h" #include "dcast.h" +using std::string; + /** * */ diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index e22aa57ba2..386e044f9f 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -117,7 +117,7 @@ def test_plane_shape(): assert type(shape) is type(shape2) assert shape.margin == shape2.margin assert shape.name == shape2.name - assert shape.plane_normal == shape2.plane_normal + assert shape.plane_normal.almost_equal(shape2.plane_normal, 0.1) assert shape.plane_constant == shape2.plane_constant diff --git a/tests/display/test_depth_buffer.py b/tests/display/test_depth_buffer.py new file mode 100644 index 0000000000..8581fe47ea --- /dev/null +++ b/tests/display/test_depth_buffer.py @@ -0,0 +1,155 @@ +from panda3d import core +import pytest + + +@pytest.fixture(scope='module', params=[32, 24, 16]) +def depth_region(request, graphics_pipe): + """Creates and returns a DisplayRegion with a depth buffer.""" + + engine = core.GraphicsEngine() + engine.set_threading_model("") + + host_fbprops = core.FrameBufferProperties() + host_fbprops.force_hardware = True + + host = engine.make_output( + graphics_pipe, + 'host', + 0, + host_fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + ) + engine.open_windows() + + if host is None: + pytest.skip("GraphicsPipe cannot make offscreen buffers") + + fbprops = core.FrameBufferProperties() + fbprops.force_hardware = True + fbprops.depth_bits = request.param + + if fbprops.depth_bits >= 32: + fbprops.float_depth = True + + buffer = engine.make_output( + graphics_pipe, + 'buffer', + 0, + fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + host.gsg, + host + ) + engine.open_windows() + + if buffer is None: + pytest.skip("Cannot make depth buffer") + + if buffer.get_fb_properties().depth_bits != request.param: + pytest.skip("Could not make buffer with desired bit count") + + yield buffer.make_display_region() + + if buffer is not None: + engine.remove_window(buffer) + + +def render_depth_pixel(region, distance, near, far, clear=None, write=True): + """Renders a fragment at the specified distance using the specified render + settings, and returns the resulting depth value.""" + + # Set up the scene with a blank card rendering at specified distance. + scene = core.NodePath("root") + scene.set_attrib(core.DepthTestAttrib.make(core.RenderAttrib.M_always)) + scene.set_depth_write(write) + + camera = scene.attach_new_node(core.Camera("camera")) + camera.node().get_lens(0).set_near_far(near, far) + camera.node().set_cull_bounds(core.OmniBoundingVolume()) + + if distance is not None: + cm = core.CardMaker("card") + cm.set_frame(-1, 1, -1, 1) + card = scene.attach_new_node(cm.generate()) + card.set_pos(0, distance, 0) + card.set_scale(60) + + region.active = True + region.camera = camera + + if clear is not None: + region.set_clear_depth_active(True) + region.set_clear_depth(clear) + + depth_texture = core.Texture("depth") + region.window.add_render_texture(depth_texture, + core.GraphicsOutput.RTM_copy_ram, + core.GraphicsOutput.RTP_depth) + + region.window.engine.render_frame() + region.window.clear_render_textures() + + depth_texture.write("test2.png") + + col = core.LColor() + depth_texture.peek().lookup(col, 0.5, 0.5) + return col[0] + + +def test_depth_clear(depth_region): + assert 1.0 == render_depth_pixel(depth_region, None, near=1, far=10, clear=1.0) + assert 0.0 == render_depth_pixel(depth_region, None, near=1, far=10, clear=0.0) + + +def test_depth_write(depth_region): + assert 1.0 == render_depth_pixel(depth_region, 5.0, near=1, far=10, clear=1.0, write=False) + assert 0.99 > render_depth_pixel(depth_region, 5.0, near=1, far=10, clear=1.0, write=True) + + +def test_depth_far_inf(depth_region): + inf = float("inf") + assert 0.99 > render_depth_pixel(depth_region, 10.0, near=1, far=inf, clear=1.0) + + +def test_depth_near_inf(depth_region): + inf = float("inf") + assert 0.01 < render_depth_pixel(depth_region, 10.0, near=inf, far=1, clear=0.0) + + +def test_depth_clipping(depth_region): + # Get the actual depth resulting from the clear value. + clr = render_depth_pixel(depth_region, None, near=1, far=10, clear=0.5) + + # We try rendering something at various distances to make sure that the + # resulting depth value matches our expectations. + + # Too close; read clear value. + assert clr == render_depth_pixel(depth_region, 0.999, near=1, far=10, clear=0.5) + + # Too far; read clear value. + assert clr == render_depth_pixel(depth_region, 10.01, near=1, far=10, clear=0.5) + + # Just close enough; read a value close to 0.0. + assert 0.01 > render_depth_pixel(depth_region, 1.001, near=1, far=10, clear=0.5) + + # Just far enough; read 1.0. + assert 0.99 < render_depth_pixel(depth_region, 9.999, near=1, far=10, clear=0.5) + + +def test_inverted_depth_clipping(depth_region): + # Get the actual depth resulting from the clear value. + clr = render_depth_pixel(depth_region, None, near=1, far=10, clear=0.5) + + # Too close; read clear value. + assert clr == render_depth_pixel(depth_region, 0.999, near=10, far=1, clear=0.5) + + # Too far; read clear value. + assert clr == render_depth_pixel(depth_region, 10.01, near=10, far=1, clear=0.5) + + # Just close enough; read a value close to 1.0. + assert 0.99 < render_depth_pixel(depth_region, 1.001, near=10, far=1, clear=0.5) + + # Just far enough; read a value close to 0.0. + assert 0.01 > render_depth_pixel(depth_region, 9.999, near=10, far=1, clear=0.5) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index f4ff2d7ea0..91816353f6 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -1,4 +1,5 @@ from panda3d import core +import struct import pytest from _pytest.outcomes import Failed @@ -18,6 +19,7 @@ layout(r8ui) uniform writeonly uimageBuffer _triggered; void _reset() {{ imageStore(_triggered, 0, uvec4(0, 0, 0, 0)); + memoryBarrier(); }} void _assert(bool cond, int line) {{ @@ -43,6 +45,9 @@ def run_glsl_test(gsg, body, preamble="", inputs={}, version=430): if not gsg.supports_compute_shaders or not gsg.supports_glsl: pytest.skip("compute shaders not supported") + if not gsg.supports_buffer_texture: + pytest.skip("buffer textures not supported") + __tracebackhide__ = True preamble = preamble.strip() @@ -166,7 +171,7 @@ def test_glsl_int(gsg): inputs = dict( zero=0, intmax=0x7fffffff, - intmin=-0x80000000, + intmin=-0x7fffffff, ) preamble = """ uniform int zero; @@ -176,12 +181,11 @@ def test_glsl_int(gsg): code = """ assert(zero == 0); assert(intmax == 0x7fffffff); - assert(intmin == -0x80000000); + assert(intmin == -0x7fffffff); """ run_glsl_test(gsg, code, preamble, inputs) -@pytest.mark.xfail def test_glsl_uint(gsg): #TODO: fix passing uints greater than intmax inputs = dict( @@ -189,8 +193,8 @@ def test_glsl_uint(gsg): intmax=0x7fffffff, ) preamble = """ - uniform unsigned int zero; - uniform unsigned int intmax; + uniform uint zero; + uniform uint intmax; """ code = """ assert(zero == 0); @@ -275,3 +279,40 @@ def test_glsl_pta_mat4(gsg): assert(pta[1][3] == vec4(28, 29, 30, 31)); """ run_glsl_test(gsg, code, preamble, {'pta': pta}), code + + +def test_glsl_write_extract_image_buffer(gsg): + # Tests that we can write to a buffer texture on the GPU, and then extract + # the data on the CPU. We test two textures since there was in the past a + # where it would only work correctly for one texture. + tex1 = core.Texture("tex1") + tex1.set_clear_color(0) + tex1.setup_buffer_texture(1, core.Texture.T_unsigned_int, core.Texture.F_r32i, + core.GeomEnums.UH_static) + tex2 = core.Texture("tex2") + tex2.set_clear_color(0) + tex2.setup_buffer_texture(1, core.Texture.T_int, core.Texture.F_r32i, + core.GeomEnums.UH_static) + + preamble = """ + layout(r32ui) uniform uimageBuffer tex1; + layout(r32i) uniform iimageBuffer tex2; + """ + code = """ + assert(imageLoad(tex1, 0).r == 0); + assert(imageLoad(tex2, 0).r == 0); + imageStore(tex1, 0, uvec4(123)); + imageStore(tex2, 0, ivec4(-456)); + memoryBarrier(); + assert(imageLoad(tex1, 0).r == 123); + assert(imageLoad(tex2, 0).r == -456); + """ + + run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}) + + engine = core.GraphicsEngine.get_global_ptr() + assert engine.extract_texture_data(tex1, gsg) + assert engine.extract_texture_data(tex2, gsg) + + assert struct.unpack('I', tex1.get_ram_image()) == (123,) + assert struct.unpack('i', tex2.get_ram_image()) == (-456,) diff --git a/tests/egg/test_egg_transform.py b/tests/egg/test_egg_transform.py new file mode 100644 index 0000000000..70e4d17fc6 --- /dev/null +++ b/tests/egg/test_egg_transform.py @@ -0,0 +1,134 @@ +import pytest +from panda3d import core + +# Skip these tests if we can't import egg. +egg = pytest.importorskip("panda3d.egg") + + +EGG_TRANSFORM_MISSING = """ + { %s } + { +} +""" + +EGG_TRANSFORM_EMPTY = """ + { %s } + { + { + } +} +""" + +EGG_TRANSFORM_IDENT = """ + { %s } + { + { + { + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + } + } +} +""" + +EGG_TRANSFORM_MATRIX = """ + { %s } + { + { + { + 5 2 -3 4 + 5 6 7 8 + 9 1 -3 2 + 5 2 5 2 + } + } +} +""" + +COORD_SYSTEMS = { + core.CS_zup_right: "zup-right", + core.CS_yup_right: "yup-right", + core.CS_zup_left: "zup-left", + core.CS_yup_left: "yup-left", +} + +def read_egg_string(string): + """Reads an EggData from a string.""" + stream = core.StringStream(string.encode('utf-8')) + data = egg.EggData() + assert data.read(stream) + return data + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_missing(coordsys): + data = read_egg_string(EGG_TRANSFORM_MISSING % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert not child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_empty(coordsys): + data = read_egg_string(EGG_TRANSFORM_EMPTY % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert not child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_ident(coordsys): + data = read_egg_string(EGG_TRANSFORM_IDENT % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_matrix(coordsys): + data = read_egg_string(EGG_TRANSFORM_MATRIX % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + mat = core.Mat4D(5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + mat_inv = core.invert(mat) + + child, = data.get_children() + assert child.has_transform3d() + assert not child.transform_is_identity() + assert child.get_transform3d() == mat + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == mat + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == mat_inv + assert child.get_vertex_to_node() == mat_inv + assert child.get_node_to_vertex() == mat diff --git a/tests/egg2pg/test_egg_coordsys.py b/tests/egg2pg/test_egg_coordsys.py new file mode 100644 index 0000000000..b3c5583075 --- /dev/null +++ b/tests/egg2pg/test_egg_coordsys.py @@ -0,0 +1,103 @@ +import pytest +from panda3d import core + +# Skip these tests if we can't import egg. +egg = pytest.importorskip("panda3d.egg") + + +COORD_SYSTEMS = [core.CS_zup_right, core.CS_yup_right, core.CS_zup_left, core.CS_yup_left] + + +@pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS) +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_ident(egg_coordsys, coordsys): + # Ensures that an identity matrix always remains untouched. + group = egg.EggGroup("group") + group.add_matrix4(core.Mat4D.ident_mat()) + assert group.transform_is_identity() + + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == core.Mat4D.ident_mat() + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.Mat4D.ident_mat() + assert group.get_vertex_to_node() == core.Mat4D.ident_mat() + assert group.get_node_to_vertex() == core.Mat4D.ident_mat() + + data = egg.EggData() + data.set_coordinate_system(egg_coordsys) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + assert node.transform.is_identity() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_mat_unchanged(coordsys): + # Ensures that the matrix remains unchanged if coordinate system is same. + mat = (5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + group = egg.EggGroup("group") + group.add_matrix4(mat) + assert not group.transform_is_identity() + + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == mat + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.invert(mat) + assert group.get_vertex_to_node() == core.invert(mat) + assert group.get_node_to_vertex() == mat + + data = egg.EggData() + data.set_coordinate_system(coordsys) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + assert node.transform.mat == mat + + +@pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS) +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_pos3d(egg_coordsys, coordsys): + vpool = egg.EggVertexPool("vpool") + vtx = vpool.make_new_vertex(core.Point3D.rfu(-8, 0.5, 4.5, egg_coordsys)) + + point = egg.EggPoint() + point.add_vertex(vtx) + + group = egg.EggGroup("group") + group.add_translate3d(core.Point3D.rfu(1, 2, 3, egg_coordsys)) + assert not group.transform_is_identity() + group.add_child(point) + + mat = group.get_transform3d() + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == mat + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.invert(mat) + assert group.get_vertex_to_node() == core.invert(mat) + assert group.get_node_to_vertex() == mat + + assert group.get_vertex_frame_ptr() is None + assert group.get_vertex_frame_inv_ptr() is None + + data = egg.EggData() + data.set_coordinate_system(egg_coordsys) + data.add_child(vpool) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + # Ensure the node has the expected position. + assert node.transform.pos == core.Point3.rfu(1, 2, 3, coordsys) + + # Get the location of the vertex. This is a quick, hacky way to get it. + point = core.NodePath(node).get_tight_bounds()[0] + assert point == core.Point3.rfu(-8, 0.5, 4.5, coordsys) + diff --git a/tests/event/test_futures.py b/tests/event/test_futures.py index 0778605da4..e120a2ab8e 100644 --- a/tests/event/test_futures.py +++ b/tests/event/test_futures.py @@ -48,10 +48,9 @@ def test_future_wait(): fut.set_result(None) thread = threading.Thread(target=thread_main) - thread.start() - # Make sure it didn't sneakily already run the thread assert not fut.done() + thread.start() assert fut.result() is None @@ -69,10 +68,9 @@ def test_future_wait_cancel(): fut.cancel() thread = threading.Thread(target=thread_main) - thread.start() - # Make sure it didn't sneakily already run the thread assert not fut.done() + thread.start() with pytest.raises(CancelledError): fut.result() diff --git a/tests/gobj/test_geom.py b/tests/gobj/test_geom.py new file mode 100644 index 0000000000..2a5a462659 --- /dev/null +++ b/tests/gobj/test_geom.py @@ -0,0 +1,42 @@ +from panda3d import core + +empty_format = core.GeomVertexFormat.get_empty() + + +def test_geom_decompose_in_place(): + vertex_data = core.GeomVertexData("", empty_format, core.GeomEnums.UH_static) + prim = core.GeomTristrips(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + + geom = core.Geom(vertex_data) + geom.add_primitive(prim) + + geom.decompose_in_place() + + prim = geom.get_primitive(0) + assert tuple(prim.get_vertex_list()) == (0, 1, 2, 2, 1, 3) + + +def test_geom_decompose(): + vertex_data = core.GeomVertexData("", empty_format, core.GeomEnums.UH_static) + prim = core.GeomTristrips(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + + geom = core.Geom(vertex_data) + geom.add_primitive(prim) + + new_geom = geom.decompose() + + new_prim = new_geom.get_primitive(0) + assert tuple(new_prim.get_vertex_list()) == (0, 1, 2, 2, 1, 3) + + # Old primitive should still be unchanged + assert prim == geom.get_primitive(0) diff --git a/tests/gobj/test_texture_pool.py b/tests/gobj/test_texture_pool.py new file mode 100644 index 0000000000..b07e8a0cb9 --- /dev/null +++ b/tests/gobj/test_texture_pool.py @@ -0,0 +1,196 @@ +from panda3d import core +import pytest +import tempfile + +@pytest.fixture(scope='function') +def pool(): + "This fixture ensures the pool is properly emptied" + pool = core.TexturePool + pool.release_all_textures() + yield pool + pool.release_all_textures() + + +def write_image(filename, channels): + img = core.PNMImage(1, 1, channels) + img.set_xel_a(0, 0, (0.0, 0.25, 0.5, 0.75)) + assert img.write(filename) + + +@pytest.fixture(scope='session') +def image_rgb_path(): + "Generates an RGB image." + + file = tempfile.NamedTemporaryFile(suffix='-rgb.png') + write_image(file.name, 3) + yield file.name + file.close() + + +@pytest.fixture(scope='session') +def image_rgba_path(): + "Generates an RGBA image." + + file = tempfile.NamedTemporaryFile(suffix='-rgba.png') + write_image(file.name, 4) + yield file.name + file.close() + + +@pytest.fixture(scope='session') +def image_gray_path(): + "Generates a grayscale image." + + file = tempfile.NamedTemporaryFile(suffix='-gray.png') + write_image(file.name, 1) + yield file.name + file.close() + + +def test_load_texture_rgba(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba4(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 4) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba3(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 3) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 3 + + +def test_load_texture_rgba2(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 2) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 2 + + +def test_load_texture_rgba1(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 1) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 1 + + +def test_load_texture_rgb(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb4(pool, image_rgb_path): + # Will not increase this + tex = pool.load_texture(image_rgb_path, 4) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb3(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path, 3) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb2(pool, image_rgb_path): + # Cannot reduce this, since it would add an alpha channel + tex = pool.load_texture(image_rgb_path, 2) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb1(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path, 1) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 1 + + +def test_load_texture_rgba_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba4_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 4) + assert tex.num_components == 4 + + +def test_load_texture_rgba3_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 3) + assert tex.num_components == 4 + + +def test_load_texture_rgba2_alpha(pool, image_rgba_path, image_gray_path): + #FIXME: why is this not consistent with test_load_texture_rgb2_alpha? + tex = pool.load_texture(image_rgba_path, image_gray_path, 2) + assert tex.num_components == 2 + + +def test_load_texture_rgba1_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 1) + assert tex.num_components == 2 + + +def test_load_texture_rgb_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + +def test_load_texture_rgb4_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 4) + assert tex.num_components == 4 + + +def test_load_texture_rgb3_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 3) + assert tex.num_components == 4 + + +def test_load_texture_rgb2_alpha(pool, image_rgb_path, image_gray_path): + #FIXME: why is this not consistent with test_load_texture_rgba2_alpha? + tex = pool.load_texture(image_rgb_path, image_gray_path, 2) + assert tex.num_components == 4 + + +def test_load_texture_rgb1_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 1) + assert tex.num_components == 2 + + +def test_reload_texture_fewer_channels(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + tex = pool.load_texture(image_rgba_path, 3) + assert tex.num_components == 3 + + +def test_reload_texture_more_channels(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 3) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 3 + + tex = pool.load_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_reload_texture_with_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + +def test_reload_texture_without_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + tex = pool.load_texture(image_rgb_path) + assert tex.num_components == 3 diff --git a/tests/linmath/test_matrix_invert.py b/tests/linmath/test_matrix_invert.py new file mode 100644 index 0000000000..b2e6dd49bf --- /dev/null +++ b/tests/linmath/test_matrix_invert.py @@ -0,0 +1,20 @@ +import pytest +from panda3d import core + + +@pytest.mark.parametrize("type", (core.Mat4, core.Mat4D)) +def test_mat4_invert(type): + mat = type((1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 2, 3, 1)) + inv = type() + assert inv.invert_from(mat) + + assert inv == type(( 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + -1, -2, -3, 1)) + + assert (mat * inv).is_identity() + assert (inv * mat).is_identity() diff --git a/tests/mathutil/test_bounding_plane.py b/tests/mathutil/test_bounding_plane.py new file mode 100644 index 0000000000..eeb9b2b11e --- /dev/null +++ b/tests/mathutil/test_bounding_plane.py @@ -0,0 +1,64 @@ +from panda3d.core import Plane, BoundingPlane, BoundingSphere, BoundingVolume + + +def test_plane_contains_sphere(): + plane = BoundingPlane((0, 0, 1, 0)) + + # Sphere above plane + assert plane.contains(BoundingSphere((0, 0, 2), 1)) == BoundingVolume.IF_no_intersection + + # Sphere intersecting surface of plane + assert plane.contains(BoundingSphere((0, 0, 0), 1)) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Sphere below plane + assert plane.contains(BoundingSphere((0, 0, -2), 1)) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + +def test_plane_contains_plane(): + # Plane should always fully contain itself. + a = BoundingPlane((1, 0, 0, 1)) + assert a.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + # Plane with its mirror image + a = BoundingPlane((1, 0, 0, 1)) + b = BoundingPlane((-1, 0, 0, -1)) + assert a.contains(b) == BoundingVolume.IF_no_intersection + assert b.contains(a) == BoundingVolume.IF_no_intersection + + # One plane above the other + a = BoundingPlane(Plane((1, 0, 0), (1, 0, 0))) + b = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + # Opposing planes with distance between them. + a = BoundingPlane(Plane((1, 0, 0), (1, 0, 0))) + b = BoundingPlane(Plane((-1, 0, 0), (2, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_no_intersection + assert b.contains(a) == BoundingVolume.IF_no_intersection + + # Planes overlapping in the same axis. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((-1, 0, 0), (1, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Planes overlapping due to not sharing a normal vector. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((0.8, 0.6, 0), (4, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Same as above. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((-0.8, -0.6, 0), (4, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Planes pointing along different major axes. + a = BoundingPlane(Plane((1, 0, 0, 0))) + b = BoundingPlane(Plane((0, 1, 0, 0))) + c = BoundingPlane(Plane((0, 0, 1, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(c) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert a.contains(c) == BoundingVolume.IF_possible | BoundingVolume.IF_some