From 1250eb967beb20ef760e94ae2665bde43c3cf4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 17 Jul 2018 10:31:34 -0300 Subject: [PATCH 1/4] Replacement of PlusCallback in favor of std::functional ( just for lambdas ). --HG-- branch : dev-functional --- include/eepp/core.hpp | 2 + include/eepp/graphics/console.hpp | 2 +- include/eepp/graphics/shaderprogram.hpp | 2 +- include/eepp/graphics/sprite.hpp | 2 +- include/eepp/graphics/textureatlasloader.hpp | 2 +- include/eepp/maps/mapeditor/mapeditor.hpp | 2 +- include/eepp/maps/tilemap.hpp | 6 +-- include/eepp/math/interpolation1d.hpp | 4 +- include/eepp/math/interpolation2d.hpp | 4 +- include/eepp/network/http.hpp | 2 +- include/eepp/physics/body.hpp | 10 ++--- include/eepp/physics/space.hpp | 22 +++++----- include/eepp/scene/action.hpp | 2 +- include/eepp/scene/node.hpp | 2 +- include/eepp/system/objectloader.hpp | 2 +- include/eepp/system/resourceloader.hpp | 2 +- include/eepp/ui/tools/textureatlaseditor.hpp | 2 +- include/eepp/ui/uinode.hpp | 2 +- include/eepp/ui/uiwidgetcreator.hpp | 4 +- include/eepp/window/input.hpp | 2 +- include/eepp/window/inputtextbuffer.hpp | 2 +- include/eepp/window/window.hpp | 4 +- projects/linux/ee.creator.user | 4 +- src/eepp/graphics/shaderprogram.cpp | 2 +- src/eepp/graphics/sprite.cpp | 8 +--- src/eepp/graphics/textureatlasloader.cpp | 2 +- src/eepp/maps/mapeditor/mapeditor.cpp | 2 +- .../maps/mapeditor/maplayerproperties.cpp | 2 +- .../maps/mapeditor/maplayerproperties.hpp | 2 +- src/eepp/maps/mapeditor/uigotypenew.cpp | 4 +- src/eepp/maps/mapeditor/uigotypenew.hpp | 4 +- src/eepp/maps/mapeditor/uimap.cpp | 10 ++--- src/eepp/maps/mapeditor/uimap.hpp | 12 ++--- src/eepp/maps/mapeditor/uimaplayernew.cpp | 2 +- src/eepp/maps/mapeditor/uimaplayernew.hpp | 2 +- src/eepp/maps/mapeditor/uimapnew.cpp | 4 +- src/eepp/maps/mapeditor/uimapnew.hpp | 4 +- src/eepp/maps/tilemap.cpp | 6 +-- src/eepp/math/interpolation1d.cpp | 10 ++--- src/eepp/math/interpolation2d.cpp | 10 ++--- src/eepp/physics/body.cpp | 10 ++--- src/eepp/physics/space.cpp | 44 +++++++++---------- src/eepp/system/objectloader.cpp | 2 +- src/eepp/system/resourceloader.cpp | 2 +- src/eepp/ui/tools/textureatlaseditor.cpp | 2 +- src/eepp/ui/tools/textureatlasnew.cpp | 2 +- src/eepp/ui/tools/textureatlasnew.hpp | 2 +- src/eepp/ui/uiwidgetcreator.cpp | 4 +- src/eepp/window/inputtextbuffer.cpp | 4 +- src/eepp/window/window.cpp | 2 +- src/examples/physics/physics.cpp | 4 +- src/test/eetest.cpp | 17 ++++--- src/test/eetest.hpp | 2 +- 53 files changed, 136 insertions(+), 135 deletions(-) diff --git a/include/eepp/core.hpp b/include/eepp/core.hpp index e74cfd9b7..b1dd9a003 100644 --- a/include/eepp/core.hpp +++ b/include/eepp/core.hpp @@ -1,6 +1,8 @@ #ifndef EE_BASE_HPP #define EE_BASE_HPP +#include + #include #include diff --git a/include/eepp/graphics/console.hpp b/include/eepp/graphics/console.hpp index 392e90cf5..788b3f7f4 100755 --- a/include/eepp/graphics/console.hpp +++ b/include/eepp/graphics/console.hpp @@ -17,7 +17,7 @@ namespace EE { namespace Graphics { class EE_API Console : protected LogReaderInterface { public: //! The Console Callback return a vector of parameters ( String ) - typedef cb::Callback1& > ConsoleCallback; + typedef std::function& )> ConsoleCallback; /** Instances the console but doesn't create it, you must call Create to initialize the console. */ Console( EE::Window::Window * window = NULL ); diff --git a/include/eepp/graphics/shaderprogram.hpp b/include/eepp/graphics/shaderprogram.hpp index 9aead5856..425c01156 100644 --- a/include/eepp/graphics/shaderprogram.hpp +++ b/include/eepp/graphics/shaderprogram.hpp @@ -30,7 +30,7 @@ class EE_API ShaderProgram { /** Creates the vertex and fragment shader from an array of strings */ static ShaderProgram * New( const char ** VertexShaderData, const Uint32& NumLinesVS, const char ** FragmentShaderData, const Uint32& NumLinesFS, const std::string& Name = "" ); - typedef cb::Callback1 ShaderProgramReloadCb; + typedef std::function ShaderProgramReloadCb; virtual ~ShaderProgram(); diff --git a/include/eepp/graphics/sprite.hpp b/include/eepp/graphics/sprite.hpp index 035c8b42e..13689b2cd 100755 --- a/include/eepp/graphics/sprite.hpp +++ b/include/eepp/graphics/sprite.hpp @@ -15,7 +15,7 @@ namespace EE { namespace Graphics { class EE_API Sprite : public Drawable { public: /// Event ID - Sprite - User Data - typedef cb::Callback3< void, Uint32, Sprite *, void * > SpriteCallback; + typedef std::function SpriteCallback; /** @brief SpriteEvents The events that can be reported by the Sprite */ enum SpriteEvents { diff --git a/include/eepp/graphics/textureatlasloader.hpp b/include/eepp/graphics/textureatlasloader.hpp index 3353b2a4e..73c218b17 100644 --- a/include/eepp/graphics/textureatlasloader.hpp +++ b/include/eepp/graphics/textureatlasloader.hpp @@ -17,7 +17,7 @@ class TextureAtlas; /** @brief The Texture Atlas Loader loads any previously created Texture Atlas. */ class EE_API TextureAtlasLoader { public: - typedef cb::Callback1 GLLoadCallback; + typedef std::function GLLoadCallback; /** Creates an empty loader. The texture atlas can be loaded callin any Load* function. */ TextureAtlasLoader(); diff --git a/include/eepp/maps/mapeditor/mapeditor.hpp b/include/eepp/maps/mapeditor/mapeditor.hpp index 8dcc9d81c..04aa50b1d 100644 --- a/include/eepp/maps/mapeditor/mapeditor.hpp +++ b/include/eepp/maps/mapeditor/mapeditor.hpp @@ -35,7 +35,7 @@ class UIMap; class EE_API MapEditor { public: - typedef cb::Callback0 MapEditorCloseCb; + typedef std::function MapEditorCloseCb; static MapEditor * New( UIWindow * AttatchTo = NULL, const MapEditorCloseCb& callback = MapEditorCloseCb() ); diff --git a/include/eepp/maps/tilemap.hpp b/include/eepp/maps/tilemap.hpp index 95c4a1165..9729be8ba 100644 --- a/include/eepp/maps/tilemap.hpp +++ b/include/eepp/maps/tilemap.hpp @@ -28,9 +28,9 @@ class EE_API TileMap { public: typedef std::map PropertiesMap; typedef std::list GOTypesList; //! Special object types used in this map - typedef cb::Callback4< GameObject *, const Uint32&, const Uint32&, MapLayer *, const Uint32&> CreateGOCb; - typedef cb::Callback0 MapDrawCb; - typedef cb::Callback0 MapUpdateCb; + typedef std::function< GameObject *( const Uint32&, const Uint32&, MapLayer *, const Uint32& )> CreateGOCb; + typedef std::function MapDrawCb; + typedef std::function MapUpdateCb; TileMap(); diff --git a/include/eepp/math/interpolation1d.hpp b/include/eepp/math/interpolation1d.hpp index 6efff336a..41d90a36b 100644 --- a/include/eepp/math/interpolation1d.hpp +++ b/include/eepp/math/interpolation1d.hpp @@ -29,9 +29,9 @@ class EE_API Interpolation1d { ~Interpolation1d(); - typedef cb::Callback1 OnPathEndCallback; + typedef std::function OnPathEndCallback; - typedef cb::Callback1 OnStepCallback; + typedef std::function OnStepCallback; /** Add a new point */ Interpolation1d& add( const Float& pos, const Time& Time = Time::Zero ); diff --git a/include/eepp/math/interpolation2d.hpp b/include/eepp/math/interpolation2d.hpp index 54e4a630e..bb4034aa2 100755 --- a/include/eepp/math/interpolation2d.hpp +++ b/include/eepp/math/interpolation2d.hpp @@ -30,9 +30,9 @@ class EE_API Interpolation2d { ~Interpolation2d(); - typedef cb::Callback1 OnPathEndCallback; + typedef std::function OnPathEndCallback; - typedef cb::Callback1 OnStepCallback; + typedef std::function OnStepCallback; /** Add a new waypoint */ Interpolation2d& add(const Vector2f& pos, const Time& time = Time::Zero ); diff --git a/include/eepp/network/http.hpp b/include/eepp/network/http.hpp index ab6bfa3c3..7f631c2c7 100644 --- a/include/eepp/network/http.hpp +++ b/include/eepp/network/http.hpp @@ -307,7 +307,7 @@ class EE_API Http : NonCopyable { Response downloadRequest(const Request& request, std::string writePath, Time timeout = Time::Zero); /** Definition of the async callback response */ - typedef cb::Callback3 AsyncResponseCallback; + typedef std::function AsyncResponseCallback; /** @brief Sends the request and creates a new thread, when got the response informs the result to the callback. ** This function does not lock the caller thread. diff --git a/include/eepp/physics/body.hpp b/include/eepp/physics/body.hpp index ef7c5767d..638cf4e50 100644 --- a/include/eepp/physics/body.hpp +++ b/include/eepp/physics/body.hpp @@ -11,11 +11,11 @@ class Arbiter; class CP_API Body { public: - typedef cb::Callback3 ShapeIteratorFunc; - typedef cb::Callback3 ConstraintIteratorFunc; - typedef cb::Callback3 ArbiterIteratorFunc; - typedef cb::Callback4 BodyVelocityFunc; - typedef cb::Callback2 BodyPositionFunc; + typedef std::function ShapeIteratorFunc; + typedef std::function ConstraintIteratorFunc; + typedef std::function ArbiterIteratorFunc; + typedef std::function BodyVelocityFunc; + typedef std::function BodyPositionFunc; class ShapeIterator { public: diff --git a/include/eepp/physics/space.hpp b/include/eepp/physics/space.hpp index b89d3afac..d28c4db23 100644 --- a/include/eepp/physics/space.hpp +++ b/include/eepp/physics/space.hpp @@ -12,16 +12,16 @@ CP_NAMESPACE_BEGIN class CP_API Space { public: - typedef cb::Callback3 CollisionBeginFunc; - typedef cb::Callback3 CollisionPreSolveFunc; - typedef cb::Callback3 CollisionPostSolveFunc; - typedef cb::Callback3 CollisionSeparateFunc; - typedef cb::Callback3 PostStepCallback; - typedef cb::Callback2 BBQueryFunc; - typedef cb::Callback4 SegmentQueryFunc; - typedef cb::Callback2 PointQueryFunc; - typedef cb::Callback3 BodyIteratorFunc; - typedef cb::Callback3 ShapeIteratorFunc; + typedef std::function CollisionBeginFunc; + typedef std::function CollisionPreSolveFunc; + typedef std::function CollisionPostSolveFunc; + typedef std::function CollisionSeparateFunc; + typedef std::function PostStepCallback; + typedef std::function BBQueryFunc; + typedef std::function SegmentQueryFunc; + typedef std::function PointQueryFunc; + typedef std::function BodyIteratorFunc; + typedef std::function ShapeIteratorFunc; class CollisionHandler { public: @@ -32,7 +32,7 @@ class CP_API Space { { } - inline void Reset() { + inline void reset() { a = 0; b = 0; data = NULL; diff --git a/include/eepp/scene/action.hpp b/include/eepp/scene/action.hpp index 0c523edbc..f4ade102c 100644 --- a/include/eepp/scene/action.hpp +++ b/include/eepp/scene/action.hpp @@ -20,7 +20,7 @@ class EE_API Action { OnStep }; - typedef cb::Callback2 ActionCallback; + typedef std::function ActionCallback; Action(); diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index a2481191b..e0df180d4 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -65,7 +65,7 @@ class EE_API Node : public Transformable { public: static Node * New(); - typedef cb::Callback1 EventCallback; + typedef std::function EventCallback; Node(); diff --git a/include/eepp/system/objectloader.hpp b/include/eepp/system/objectloader.hpp index 46a67eaf1..487030a7f 100644 --- a/include/eepp/system/objectloader.hpp +++ b/include/eepp/system/objectloader.hpp @@ -10,7 +10,7 @@ namespace EE { namespace System { /** @brief Base class that defines resources to be loaded in synchronous or asynchronous mode. */ class EE_API ObjectLoader : protected Thread { public: - typedef cb::Callback1 ObjLoadCallback; + typedef std::function ObjLoadCallback; /** @brief LoaderType Definition of the Object Loaders implemented by the engine. */ enum ObjLoaderType { diff --git a/include/eepp/system/resourceloader.hpp b/include/eepp/system/resourceloader.hpp index ca558d24c..c4f5581f8 100644 --- a/include/eepp/system/resourceloader.hpp +++ b/include/eepp/system/resourceloader.hpp @@ -10,7 +10,7 @@ namespace EE { namespace System { /** @brief A simple resource loader that can load a batch of resources synchronously or asynchronously */ class EE_API ResourceLoader { public: - typedef cb::Callback1 ResLoadCallback; + typedef std::function ResLoadCallback; /** @param MaxThreads Set the maximun simultaneous threads to load resources, THREADS_AUTO will use the cpu number of cores. */ ResourceLoader( const Uint32& MaxThreads = THREADS_AUTO ); diff --git a/include/eepp/ui/tools/textureatlaseditor.hpp b/include/eepp/ui/tools/textureatlaseditor.hpp index 8d55feeb7..922896460 100644 --- a/include/eepp/ui/tools/textureatlaseditor.hpp +++ b/include/eepp/ui/tools/textureatlaseditor.hpp @@ -18,7 +18,7 @@ class TextureAtlasTextureRegionEditor; class EE_API TextureAtlasEditor { public: - typedef cb::Callback0 TGEditorCloseCb; + typedef std::function TGEditorCloseCb; static TextureAtlasEditor * New( UIWindow * AttatchTo = NULL, const TGEditorCloseCb& callback = TGEditorCloseCb() ); diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index cf7ff412f..a08c7860d 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -22,7 +22,7 @@ class EE_API UINode : public Node { public: static UINode * New(); - typedef cb::Callback1 EventCallback; + typedef std::function EventCallback; UINode(); diff --git a/include/eepp/ui/uiwidgetcreator.hpp b/include/eepp/ui/uiwidgetcreator.hpp index 2ef3db348..f6fdf1556 100644 --- a/include/eepp/ui/uiwidgetcreator.hpp +++ b/include/eepp/ui/uiwidgetcreator.hpp @@ -8,8 +8,8 @@ namespace EE { namespace UI { class EE_API UIWidgetCreator { public: - typedef cb::Callback1 CustomWidgetCb; - typedef cb::Callback0 RegisterWidgetCb; + typedef std::function CustomWidgetCb; + typedef std::function RegisterWidgetCb; static UIWidget * createFromName( std::string widgetName ); diff --git a/include/eepp/window/input.hpp b/include/eepp/window/input.hpp index 659019545..ea8426861 100644 --- a/include/eepp/window/input.hpp +++ b/include/eepp/window/input.hpp @@ -17,7 +17,7 @@ namespace EE { namespace Window { /** @brief The basic input class. For mouse and keyboard. */ class EE_API Input { public: - typedef cb::Callback1 InputCallback; + typedef std::function InputCallback; virtual ~Input(); diff --git a/include/eepp/window/inputtextbuffer.hpp b/include/eepp/window/inputtextbuffer.hpp index 19a35b672..ac8a153e0 100755 --- a/include/eepp/window/inputtextbuffer.hpp +++ b/include/eepp/window/inputtextbuffer.hpp @@ -24,7 +24,7 @@ enum INPUT_TEXTBUFFER_FLAGS { /** @brief A class to keep a buffer of the user writed text */ class EE_API InputTextBuffer { public: - typedef cb::Callback0 EnterCallback; + typedef std::function EnterCallback; InputTextBuffer( const bool& active, const bool& newLineEnabled, const bool& freeEditing, EE::Window::Window * window = NULL, const Uint32& maxLength = INPUT_LENGHT_MAX ); diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index 251772034..06c7dd6aa 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -151,8 +151,8 @@ class DisplayMode { class EE_API Window { public: - typedef cb::Callback1 WindowResizeCallback; - typedef cb::Callback1 WindowRequestCloseCallback; + typedef std::function WindowResizeCallback; + typedef std::function WindowRequestCloseCallback; Window( WindowSettings Settings, ContextSettings Context, Clipboard * Clipboard, Input * Input, CursorManager * CursorManager ); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 7d5dc0c5a..cced14bbe 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -72,7 +72,7 @@ {6d057187-158a-4883-8d5b-d470a6b6b025} 10 0 - 2 + 0 ../../make/linux diff --git a/src/eepp/graphics/shaderprogram.cpp b/src/eepp/graphics/shaderprogram.cpp index 20b028cef..2698448b0 100644 --- a/src/eepp/graphics/shaderprogram.cpp +++ b/src/eepp/graphics/shaderprogram.cpp @@ -197,7 +197,7 @@ void ShaderProgram::reload() { link(); - if ( mReloadCb.IsSet() ) { + if ( mReloadCb ) { mReloadCb( this ); } } diff --git a/src/eepp/graphics/sprite.cpp b/src/eepp/graphics/sprite.cpp index 8d130b0b3..d7ab33754 100755 --- a/src/eepp/graphics/sprite.cpp +++ b/src/eepp/graphics/sprite.cpp @@ -27,7 +27,6 @@ Sprite::Sprite() : mAnimTo( 0 ), mUserData( NULL ) { - mCb.Reset(); } Sprite::Sprite( const std::string& name, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) : @@ -47,7 +46,6 @@ Sprite::Sprite( const std::string& name, const std::string& extension, TextureAt mAnimTo( 0 ), mUserData( NULL ) { - mCb.Reset(); addFramesByPattern( name, extension, SearchInTextureAtlas ); } @@ -68,7 +66,6 @@ Sprite::Sprite( TextureRegion * TextureRegion ) : mAnimTo( 0 ), mUserData( NULL ) { - mCb.Reset(); createStatic( TextureRegion ); } @@ -89,7 +86,6 @@ Sprite::Sprite( const Uint32& TexId, const Sizef &DestSize, const Vector2i &Offs mAnimTo( 0 ), mUserData( NULL ) { - mCb.Reset(); createStatic( TexId, DestSize, Offset, TexSector ); } @@ -835,11 +831,11 @@ void Sprite::setEventsCallback(const SpriteCallback& Cb , void * UserData ) { } void Sprite::clearCallback() { - mCb.Reset(); + mCb = nullptr; } void Sprite::fireEvent( const Uint32& Event ) { - if ( SPR_FGET( SPRITE_FLAG_EVENTS_ENABLED ) && mCb.IsSet() ) { + if ( SPR_FGET( SPRITE_FLAG_EVENTS_ENABLED ) && mCb ) { mCb( Event, this, mUserData ); } } diff --git a/src/eepp/graphics/textureatlasloader.cpp b/src/eepp/graphics/textureatlasloader.cpp index 7c4ba2747..3c773a8d4 100644 --- a/src/eepp/graphics/textureatlasloader.cpp +++ b/src/eepp/graphics/textureatlasloader.cpp @@ -273,7 +273,7 @@ void TextureAtlasLoader::createTextureRegions() { mLoaded = true; - if ( mLoadCallback.IsSet() ) { + if ( mLoadCallback ) { mLoadCallback( this ); } } diff --git a/src/eepp/maps/mapeditor/mapeditor.cpp b/src/eepp/maps/mapeditor/mapeditor.cpp index 5bf346bc6..1fe21a3bb 100644 --- a/src/eepp/maps/mapeditor/mapeditor.cpp +++ b/src/eepp/maps/mapeditor/mapeditor.cpp @@ -1229,7 +1229,7 @@ void MapEditor::onLayerSelect( const Event * Event ) { } void MapEditor::windowClose( const Event * Event ) { - if ( mCloseCb.IsSet() ) + if ( mCloseCb ) mCloseCb(); eeDelete( this ); diff --git a/src/eepp/maps/mapeditor/maplayerproperties.cpp b/src/eepp/maps/mapeditor/maplayerproperties.cpp index 2a30153d8..c60174381 100644 --- a/src/eepp/maps/mapeditor/maplayerproperties.cpp +++ b/src/eepp/maps/mapeditor/maplayerproperties.cpp @@ -143,7 +143,7 @@ void MapLayerProperties::onOKClick( const Event * Event ) { mLayer->setName( mUIInput->getText().toUtf8() ); - if ( mRefreshCb.IsSet() ) { + if ( mRefreshCb ) { mRefreshCb(); } diff --git a/src/eepp/maps/mapeditor/maplayerproperties.hpp b/src/eepp/maps/mapeditor/maplayerproperties.hpp index fe6ff3aaa..43465a390 100644 --- a/src/eepp/maps/mapeditor/maplayerproperties.hpp +++ b/src/eepp/maps/mapeditor/maplayerproperties.hpp @@ -16,7 +16,7 @@ class MapEditor; class EE_API MapLayerProperties { public: - typedef cb::Callback0 RefreshLayerListCb; + typedef std::function RefreshLayerListCb; MapLayerProperties( MapLayer * Map, RefreshLayerListCb Cb = RefreshLayerListCb() ); diff --git a/src/eepp/maps/mapeditor/uigotypenew.cpp b/src/eepp/maps/mapeditor/uigotypenew.cpp index 230efd8e0..2cc138e98 100644 --- a/src/eepp/maps/mapeditor/uigotypenew.cpp +++ b/src/eepp/maps/mapeditor/uigotypenew.cpp @@ -3,7 +3,7 @@ namespace EE { namespace Maps { namespace Private { -UIGOTypeNew::UIGOTypeNew( cb::Callback2 Cb ) : +UIGOTypeNew::UIGOTypeNew( std::function Cb ) : mUITheme( NULL ), mUIWindow( NULL ), mUIInput( NULL ), @@ -57,7 +57,7 @@ UIGOTypeNew::~UIGOTypeNew() { void UIGOTypeNew::onOKClick( const Event * Event ) { if ( mUIInput->getText().size() ) { - if ( mCb.IsSet() ) + if ( mCb ) mCb( mUIInput->getText().toUtf8(), String::hash( mUIInput->getText().toUtf8() ) ); } diff --git a/src/eepp/maps/mapeditor/uigotypenew.hpp b/src/eepp/maps/mapeditor/uigotypenew.hpp index 40aa7b248..42251c91f 100644 --- a/src/eepp/maps/mapeditor/uigotypenew.hpp +++ b/src/eepp/maps/mapeditor/uigotypenew.hpp @@ -11,14 +11,14 @@ namespace EE { namespace Maps { namespace Private { class EE_API UIGOTypeNew { public: - UIGOTypeNew( cb::Callback2 Cb ); + UIGOTypeNew(std::function Cb ); virtual ~UIGOTypeNew(); protected: UITheme * mUITheme; UIWindow * mUIWindow; UITextInput * mUIInput; - cb::Callback2 mCb; + std::function mCb; void onWindowClose( const Event * Event ); diff --git a/src/eepp/maps/mapeditor/uimap.cpp b/src/eepp/maps/mapeditor/uimap.cpp index 368b22c54..534ebfec1 100644 --- a/src/eepp/maps/mapeditor/uimap.cpp +++ b/src/eepp/maps/mapeditor/uimap.cpp @@ -66,7 +66,7 @@ Uint32 UIMap::onDrag( const Vector2f& Pos ) { mDragPoint = Pos; - if ( mUpdateScrollCb.IsSet() ) { + if ( mUpdateScrollCb ) { mUpdateScrollCb(); } @@ -120,7 +120,7 @@ void UIMap::update( const Time& time ) { mSelLight->setRadius( mSelLight->getRadius() - 10 ); } - if ( mLightRadiusChangeCb.IsSet() ) + if ( mLightRadiusChangeCb ) mLightRadiusChangeCb( mSelLight ); } else if ( Flags & EE_BUTTON_RMASK ) { if ( mSelLight == mAddLight ) { @@ -192,7 +192,7 @@ void UIMap::selectPolyObj() { } } } else { - if ( mAlertCb.IsSet() ) { + if ( mAlertCb ) { mAlertCb( "No layer found", "An Object Layer must be selected first." )->setFocus(); } } @@ -321,7 +321,7 @@ void UIMap::tryToSelectLight() { mSelLight = mMap->getLightManager()->getLightOver( mMap->getMouseMapPosf(), mSelLight ); if ( NULL != mSelLight && mSelLight != tLight ) { - if ( mLightSelCb.IsSet() ) + if ( mLightSelCb ) mLightSelCb( mSelLight ); } } @@ -368,7 +368,7 @@ void UIMap::addLight( MapLight * Light ) { mMap->getLightManager()->addLight( Light ); - if ( mLightSelCb.IsSet() ) + if ( mLightSelCb ) mLightSelCb( mSelLight ); } } diff --git a/src/eepp/maps/mapeditor/uimap.hpp b/src/eepp/maps/mapeditor/uimap.hpp index 727457bcd..fc25e31ae 100644 --- a/src/eepp/maps/mapeditor/uimap.hpp +++ b/src/eepp/maps/mapeditor/uimap.hpp @@ -30,12 +30,12 @@ class EE_API UIMap : public UIWindow { INSERT_POLYLINE }; - typedef cb::Callback1 LightSelectCb; - typedef cb::Callback1 LightRadiusChangeCb; - typedef cb::Callback2 ObjAddCb; - typedef cb::Callback2 AlertCb; - typedef cb::Callback0 OnMapLoadCb; - typedef cb::Callback0 UpdateScrollCb; + typedef std::function LightSelectCb; + typedef std::function LightRadiusChangeCb; + typedef std::function ObjAddCb; + typedef std::function AlertCb; + typedef std::function OnMapLoadCb; + typedef std::function UpdateScrollCb; UIMap( UITheme * Theme, TileMap * Map = NULL ); diff --git a/src/eepp/maps/mapeditor/uimaplayernew.cpp b/src/eepp/maps/mapeditor/uimaplayernew.cpp index fa9d3327e..ca5a6ebe6 100644 --- a/src/eepp/maps/mapeditor/uimaplayernew.cpp +++ b/src/eepp/maps/mapeditor/uimaplayernew.cpp @@ -76,7 +76,7 @@ void UIMapLayerNew::onOKClick( const Event * event ) { if ( mUILayerName->getText().size() ) { mLayer = mUIMap->Map()->addLayer( mType, LAYER_FLAG_VISIBLE | LAYER_FLAG_LIGHTS_ENABLED, mUILayerName->getText() ); - if ( mNewLayerCb.IsSet() ) + if ( mNewLayerCb ) mNewLayerCb( this ); } diff --git a/src/eepp/maps/mapeditor/uimaplayernew.hpp b/src/eepp/maps/mapeditor/uimaplayernew.hpp index f79ea4fa6..58f1ea156 100644 --- a/src/eepp/maps/mapeditor/uimaplayernew.hpp +++ b/src/eepp/maps/mapeditor/uimaplayernew.hpp @@ -12,7 +12,7 @@ namespace EE { namespace Maps { namespace Private { class EE_API UIMapLayerNew { public: - typedef cb::Callback1 NewLayerCb; + typedef std::function NewLayerCb; UIMapLayerNew( UIMap * Map, EE_LAYER_TYPE Type, NewLayerCb newLayerCb = NewLayerCb() ); diff --git a/src/eepp/maps/mapeditor/uimapnew.cpp b/src/eepp/maps/mapeditor/uimapnew.cpp index 97ea9ccc6..7e82cd2df 100644 --- a/src/eepp/maps/mapeditor/uimapnew.cpp +++ b/src/eepp/maps/mapeditor/uimapnew.cpp @@ -11,7 +11,7 @@ static UITextView * createTextBox( const String& Text = "", Node * Parent = NULL return Ctrl; } -UIMapNew::UIMapNew( UIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap ) : +UIMapNew::UIMapNew( UIMap * Map, std::function NewMapCb, bool ResizeMap ) : mTheme( NULL ), mUIWindow( NULL ), mUIMap( Map ), @@ -265,7 +265,7 @@ void UIMapNew::onOKClick( const Event * Event ) { FileSystem::fileRemove( mapPath ); } - if ( mNewMapCb.IsSet() ) + if ( mNewMapCb ) mNewMapCb(); } diff --git a/src/eepp/maps/mapeditor/uimapnew.hpp b/src/eepp/maps/mapeditor/uimapnew.hpp index 3576346ae..6648df823 100644 --- a/src/eepp/maps/mapeditor/uimapnew.hpp +++ b/src/eepp/maps/mapeditor/uimapnew.hpp @@ -14,7 +14,7 @@ namespace EE { namespace Maps { namespace Private { class EE_API UIMapNew { public: - UIMapNew( UIMap * Map, cb::Callback0 NewMapCb = cb::Callback0(), bool ResizeMap = false ); + UIMapNew( UIMap * Map, std::function NewMapCb = cb::Callback0(), bool ResizeMap = false ); virtual ~UIMapNew(); protected: @@ -38,7 +38,7 @@ class EE_API UIMapNew { UITextView * mUIGreenTxt; UITextView * mUIBlueTxt; - cb::Callback0 mNewMapCb; + std::function mNewMapCb; Sizei mNewSize; bool mResizeMap; diff --git a/src/eepp/maps/tilemap.cpp b/src/eepp/maps/tilemap.cpp index 04cf41aa8..671bcbb46 100644 --- a/src/eepp/maps/tilemap.cpp +++ b/src/eepp/maps/tilemap.cpp @@ -241,7 +241,7 @@ void TileMap::draw() { mouseOverDraw(); - if ( mDrawCb.IsSet() ) + if ( mDrawCb ) mDrawCb(); GlobalBatchRenderer::instance()->draw(); @@ -448,7 +448,7 @@ void TileMap::update() { for ( Uint32 i = 0; i < mLayerCount; i++ ) mLayers[i]->update( mWindow->getElapsed() ); - if ( mUpdateCb.IsSet() ) + if ( mUpdateCb ) mUpdateCb(); } @@ -656,7 +656,7 @@ GameObject * TileMap::createGameObject( const Uint32& Type, const Uint32& Flags, } default: { - if ( mCreateGOCb.IsSet() ) { + if ( mCreateGOCb ) { return mCreateGOCb( Type, Flags, Layer, DataId ); } else { GameObjectVirtual * tVirtual; diff --git a/src/eepp/math/interpolation1d.cpp b/src/eepp/math/interpolation1d.cpp index 00b2f7c0b..00b2324de 100644 --- a/src/eepp/math/interpolation1d.cpp +++ b/src/eepp/math/interpolation1d.cpp @@ -180,26 +180,26 @@ void Interpolation1d::update( const Time& Elapsed ) { if ( mCurPoint + 1 < mPoints.size() ) { mNexP = &mPoints[ mCurPoint + 1 ]; - if ( mOnStepCallback.IsSet() ) + if ( mOnStepCallback ) mOnStepCallback(*this); } else { - if ( mOnStepCallback.IsSet() ) + if ( mOnStepCallback ) mOnStepCallback(*this); if ( mLoop ) { mNexP = &mPoints[ 0 ]; - if ( mOnPathEndCallback.IsSet() ) + if ( mOnPathEndCallback ) mOnPathEndCallback(*this); } else { mEnable = false; mEnded = true; - if ( mOnPathEndCallback.IsSet() ) { + if ( mOnPathEndCallback ) { mOnPathEndCallback(*this); if ( !mEnable ) - mOnPathEndCallback.Reset(); + mOnPathEndCallback = nullptr; } return; } diff --git a/src/eepp/math/interpolation2d.cpp b/src/eepp/math/interpolation2d.cpp index 60ab91b5a..9631158ee 100755 --- a/src/eepp/math/interpolation2d.cpp +++ b/src/eepp/math/interpolation2d.cpp @@ -201,26 +201,26 @@ void Interpolation2d::update( const Time& Elapsed ) { if ( mCurPoint + 1 < mPoints.size() ) { mNexP = &mPoints[ mCurPoint + 1 ]; - if ( mOnStepCallback.IsSet() ) + if ( mOnStepCallback ) mOnStepCallback(*this); } else { - if ( mOnStepCallback.IsSet() ) + if ( mOnStepCallback ) mOnStepCallback(*this); if ( mLoop ) { mNexP = &mPoints[ 0 ]; - if ( mOnPathEndCallback.IsSet() ) + if ( mOnPathEndCallback ) mOnPathEndCallback(*this); } else { mEnable = false; mEnded = true; - if ( mOnPathEndCallback.IsSet() ) { + if ( mOnPathEndCallback ) { mOnPathEndCallback(*this); if ( !mEnable ) - mOnPathEndCallback.Reset(); + mOnPathEndCallback = nullptr; } return; } diff --git a/src/eepp/physics/body.cpp b/src/eepp/physics/body.cpp index 92019d472..81e08c213 100644 --- a/src/eepp/physics/body.cpp +++ b/src/eepp/physics/body.cpp @@ -191,7 +191,7 @@ void Body::updatePosition( cpFloat dt ) { void Body::bodyVelocityFuncWrapper( cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt ) { Body * tBody = reinterpret_cast( body->data ); - if ( tBody->mVelocityFunc.IsSet() ) { + if ( tBody->mVelocityFunc ) { tBody->mVelocityFunc( reinterpret_cast( body->data ), tovect( gravity ), damping, dt ); } } @@ -205,7 +205,7 @@ void Body::velocityFunc( BodyVelocityFunc func ) { void Body::bodyPositionFuncWrapper( cpBody* body, cpFloat dt ) { Body * tBody = reinterpret_cast( body->data ); - if ( tBody->mPositionFunc.IsSet() ) { + if ( tBody->mPositionFunc ) { tBody->mPositionFunc( reinterpret_cast( body->data ), dt ); } } @@ -259,7 +259,7 @@ void Body::eachShape( ShapeIteratorFunc Func, void * data ) { } void Body::onEachShape( Shape * Shape, ShapeIterator * it ) { - if ( it->Func.IsSet() ) { + if ( it->Func ) { it->Func( it->Body, Shape, it->Data ); } } @@ -275,7 +275,7 @@ void Body::eachConstraint( ConstraintIteratorFunc Func, void * data ) { } void Body::onEachConstraint( Constraint * Constraint, ConstraintIterator * it ) { - if ( it->Func.IsSet() ) { + if ( it->Func ) { it->Func( this, Constraint, it->Data ); } } @@ -292,7 +292,7 @@ void Body::eachArbiter( ArbiterIteratorFunc Func, void * data ) { } void Body::onEachArbiter( Arbiter * Arbiter, ArbiterIterator * it ) { - if ( it->Func.IsSet() ) { + if ( it->Func ) { it->Func( this, Arbiter, it->Data ); } } diff --git a/src/eepp/physics/space.cpp b/src/eepp/physics/space.cpp index f6c88b632..4b369d861 100644 --- a/src/eepp/physics/space.cpp +++ b/src/eepp/physics/space.cpp @@ -423,12 +423,12 @@ cpBool Space::onCollisionBegin( Arbiter * arb, void * data ) { std::map< cpHashValue, CollisionHandler >::iterator it = mCollisions.find( hash ); CollisionHandler handler = static_cast( it->second ); - if ( it != mCollisions.end() && handler.begin.IsSet() ) { + if ( it != mCollisions.end() && handler.begin ) { return handler.begin( arb, this, handler.data ); } //} - if ( mCollisionsDefault.begin.IsSet() ) { + if ( mCollisionsDefault.begin ) { return mCollisionsDefault.begin( arb, this, mCollisionsDefault.data ); } @@ -442,12 +442,12 @@ cpBool Space::onCollisionPreSolve( Arbiter * arb, void * data ) { std::map< cpHashValue, CollisionHandler >::iterator it = mCollisions.find( hash ); CollisionHandler handler = static_cast( it->second ); - if ( it != mCollisions.end() && handler.preSolve.IsSet() ) { + if ( it != mCollisions.end() && handler.preSolve ) { return handler.preSolve( arb, this, handler.data ); } //} - if ( mCollisionsDefault.preSolve.IsSet() ) { + if ( mCollisionsDefault.preSolve ) { return mCollisionsDefault.preSolve( arb, this, mCollisionsDefault.data ); } @@ -461,13 +461,13 @@ void Space::onCollisionPostSolve( Arbiter * arb, void * data ) { std::map< cpHashValue, CollisionHandler >::iterator it = mCollisions.find( hash ); CollisionHandler handler = static_cast( it->second ); - if ( it != mCollisions.end() && handler.postSolve.IsSet() ) { + if ( it != mCollisions.end() && handler.postSolve ) { handler.postSolve( arb, this, handler.data ); return; } //} - if ( mCollisionsDefault.begin.IsSet() ) { + if ( mCollisionsDefault.begin ) { mCollisionsDefault.postSolve( arb, this, mCollisionsDefault.data ); } } @@ -479,13 +479,13 @@ void Space::onCollisionSeparate( Arbiter * arb, void * data ) { std::map< cpHashValue, CollisionHandler >::iterator it = mCollisions.find( hash ); CollisionHandler handler = static_cast( it->second ); - if ( it != mCollisions.end() && handler.separate.IsSet() ) { + if ( it != mCollisions.end() && handler.separate ) { handler.separate( arb, this, handler.data ); return; } //} - if ( mCollisionsDefault.begin.IsSet() ) { + if ( mCollisionsDefault.begin ) { mCollisionsDefault.separate( arb, this, mCollisionsDefault.data ); } } @@ -493,7 +493,7 @@ void Space::onCollisionSeparate( Arbiter * arb, void * data ) { void Space::onPostStepCallback( void * obj, void * data ) { PostStepCallbackCont * Cb = reinterpret_cast ( data ); - if ( Cb->Callback.IsSet() ) { + if ( Cb->Callback ) { Cb->Callback( this, obj, Cb->Data ); } @@ -502,19 +502,19 @@ void Space::onPostStepCallback( void * obj, void * data ) { } void Space::onBBQuery( Shape * shape, BBQuery * query ) { - if ( query->Func.IsSet() ) { + if ( query->Func ) { query->Func( shape, query->Data ); } } void Space::onSegmentQuery( Shape * shape, cpFloat t, cVect n , SegmentQuery * query ) { - if ( query->Func.IsSet() ) { + if ( query->Func ) { query->Func( shape, t, n, query->Data ); } } void Space::onPointQuery( Shape * shape, PointQuery * query ) { - if ( query->Func.IsSet() ) { + if ( query->Func ) { query->Func( shape, query->Data ); } } @@ -522,10 +522,10 @@ void Space::onPointQuery( Shape * shape, PointQuery * query ) { void Space::addCollisionHandler( const CollisionHandler& handler ) { cpHashValue hash = CP_HASH_PAIR( handler.a, handler.b ); - cpCollisionBeginFunc f1 = ( handler.begin.IsSet() ) ? &RecieverCollisionBeginFunc : NULL; - cpCollisionPreSolveFunc f2 = ( handler.preSolve.IsSet() ) ? &RecieverCollisionPreSolveFunc : NULL; - cpCollisionPostSolveFunc f3 = ( handler.postSolve.IsSet() ) ? &RecieverCollisionPostSolve : NULL; - cpCollisionSeparateFunc f4 = ( handler.separate.IsSet() ) ? &RecieverCollisionSeparateFunc : NULL; + cpCollisionBeginFunc f1 = ( handler.begin ) ? &RecieverCollisionBeginFunc : NULL; + cpCollisionPreSolveFunc f2 = ( handler.preSolve ) ? &RecieverCollisionPreSolveFunc : NULL; + cpCollisionPostSolveFunc f3 = ( handler.postSolve ) ? &RecieverCollisionPostSolve : NULL; + cpCollisionSeparateFunc f4 = ( handler.separate ) ? &RecieverCollisionSeparateFunc : NULL; cpSpaceAddCollisionHandler( mSpace, handler.a, handler.b, f1, f2, f3, f4, (void*)hash ); @@ -540,10 +540,10 @@ void Space::removeCollisionHandler( cpCollisionType a, cpCollisionType b ) { } void Space::setDefaultCollisionHandler( const CollisionHandler& handler ) { - cpCollisionBeginFunc f1 = ( handler.begin.IsSet() ) ? &RecieverCollisionBeginFunc : NULL; - cpCollisionPreSolveFunc f2 = ( handler.preSolve.IsSet() ) ? &RecieverCollisionPreSolveFunc : NULL; - cpCollisionPostSolveFunc f3 = ( handler.postSolve.IsSet() ) ? &RecieverCollisionPostSolve : NULL; - cpCollisionSeparateFunc f4 = ( handler.separate.IsSet() ) ? &RecieverCollisionSeparateFunc : NULL; + cpCollisionBeginFunc f1 = ( handler.begin ) ? &RecieverCollisionBeginFunc : NULL; + cpCollisionPreSolveFunc f2 = ( handler.preSolve ) ? &RecieverCollisionPreSolveFunc : NULL; + cpCollisionPostSolveFunc f3 = ( handler.postSolve ) ? &RecieverCollisionPostSolve : NULL; + cpCollisionSeparateFunc f4 = ( handler.separate ) ? &RecieverCollisionSeparateFunc : NULL; cpSpaceSetDefaultCollisionHandler( mSpace, f1, f2, f3, f4, NULL ); @@ -614,7 +614,7 @@ void Space::eachBody( BodyIteratorFunc Func, void * data ) { } void Space::onEachBody( Body * Body, BodyIterator * it ) { - if ( it->Func.IsSet() ) { + if ( it->Func ) { it->Func( it->Space, Body, it->Data ); } } @@ -630,7 +630,7 @@ void Space::eachShape( ShapeIteratorFunc Func, void * data ) { } void Space::onEachShape( Shape * Shape, ShapeIterator * it ) { - if ( it->Func.IsSet() ) { + if ( it->Func ) { it->Func( it->Space, Shape, it->Data ); } } diff --git a/src/eepp/system/objectloader.cpp b/src/eepp/system/objectloader.cpp index d0764216f..7816c9f77 100644 --- a/src/eepp/system/objectloader.cpp +++ b/src/eepp/system/objectloader.cpp @@ -23,7 +23,7 @@ void ObjectLoader::load() { } void ObjectLoader::load( ObjLoadCallback Cb ) { - if ( Cb.IsSet() ) { + if ( Cb ) { mLoadCbs.push_back( Cb ); } diff --git a/src/eepp/system/resourceloader.cpp b/src/eepp/system/resourceloader.cpp index ce2a5c5ba..86cd635a8 100644 --- a/src/eepp/system/resourceloader.cpp +++ b/src/eepp/system/resourceloader.cpp @@ -70,7 +70,7 @@ bool ResourceLoader::clear( const bool& ClearObjectsLoaded ) { } void ResourceLoader::load( ResLoadCallback Cb ) { - if ( Cb.IsSet() ) + if ( Cb ) mLoadCbs.push_back( Cb ); load(); diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index bf497d88d..071f1956a 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -242,7 +242,7 @@ void TextureAtlasEditor::onDestHChange( const Event * Event ) { } void TextureAtlasEditor::windowClose( const Event * Event ) { - if ( mCloseCb.IsSet() ) + if ( mCloseCb ) mCloseCb(); eeDelete( this ); diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp index 8390210b6..fbb868a11 100644 --- a/src/eepp/ui/tools/textureatlasnew.cpp +++ b/src/eepp/ui/tools/textureatlasnew.cpp @@ -179,7 +179,7 @@ void TextureAtlasNew::textureAtlasSave( const Event * Event ) { texturePacker->save( FPath, static_cast ( mSaveFileType->getListBox()->getItemSelectedIndex() ) ); - if ( mNewTGCb.IsSet() ) + if ( mNewTGCb ) mNewTGCb( texturePacker ); mUIWindow->closeWindow(); diff --git a/src/eepp/ui/tools/textureatlasnew.hpp b/src/eepp/ui/tools/textureatlasnew.hpp index 4ae79a0b8..169ffe90c 100644 --- a/src/eepp/ui/tools/textureatlasnew.hpp +++ b/src/eepp/ui/tools/textureatlasnew.hpp @@ -12,7 +12,7 @@ namespace EE { namespace UI { namespace Tools { class EE_API TextureAtlasNew { public: - typedef cb::Callback1 TGCreateCb; + typedef std::function TGCreateCb; TextureAtlasNew( TGCreateCb NewTGCb = TGCreateCb() ); diff --git a/src/eepp/ui/uiwidgetcreator.cpp b/src/eepp/ui/uiwidgetcreator.cpp index 7088f7ac6..e72afb7b5 100644 --- a/src/eepp/ui/uiwidgetcreator.cpp +++ b/src/eepp/ui/uiwidgetcreator.cpp @@ -74,11 +74,11 @@ UIWidget * UIWidgetCreator::createFromName( std::string widgetName ) { else if ( widgetName == "layout" ) return UILayout::New(); if ( registeredWidget.find( widgetName ) != registeredWidget.end() ) { - return registeredWidget[ widgetName ].Call(); + return registeredWidget[ widgetName ](); } if ( widgetCallback.find( widgetName ) != widgetCallback.end() ) { - return widgetCallback[ widgetName ].Call( widgetName ); + return widgetCallback[ widgetName ]( widgetName ); } return NULL; diff --git a/src/eepp/window/inputtextbuffer.cpp b/src/eepp/window/inputtextbuffer.cpp index 848c98fd3..1ec8f0634 100755 --- a/src/eepp/window/inputtextbuffer.cpp +++ b/src/eepp/window/inputtextbuffer.cpp @@ -385,7 +385,7 @@ void InputTextBuffer::update( InputEvent* Event ) { setChangedSinceLastUpdate( true ); } - if ( mEnterCall.IsSet() ) + if ( mEnterCall ) mEnterCall(); } else if ( c == KEY_LEFT ) { @@ -489,7 +489,7 @@ void InputTextBuffer::update( InputEvent* Event ) { if ( setSupportNewLine() && canAdd() ) mText += '\n'; - if ( mEnterCall.IsSet() ) + if ( mEnterCall ) mEnterCall(); } } diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 752912ac9..89c5439b0 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -440,7 +440,7 @@ void Window::logFailureInit( const std::string& ClassName, const std::string& Ba } void Window::onCloseRequest() { - if ( mCloseRequestCallback.IsSet() && !mCloseRequestCallback.Call( this ) ) { + if ( mCloseRequestCallback && !mCloseRequestCallback( this ) ) { return; } diff --git a/src/examples/physics/physics.cpp b/src/examples/physics/physics.cpp index fcef03af7..be6386b4a 100644 --- a/src/examples/physics/physics.cpp +++ b/src/examples/physics/physics.cpp @@ -6,7 +6,7 @@ To understand the conceptos of space, body, shapes, etc you can read the Chipmunk documentation: http://chipmunk-physics.net/release/ChipmunkLatest-Docs/ */ -typedef cb::Callback0 SceneCb; +typedef std::function SceneCb; struct physicDemo { SceneCb init; @@ -327,7 +327,7 @@ void demo3Create() { handler.separate = cb::Make3( &blockerSeparate ); mSpace->addCollisionHandler( handler ); - handler.Reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet() + handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet() handler.a = CATCH_SENSOR_TYPE; handler.b = BALL_TYPE; diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 57c8e29b5..7280edb31 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -491,15 +491,18 @@ void EETest::createBaseUI() { w->setParent( C )->setSize( 20, 20 )->setPosition( 260, 130 ); w->setBackgroundFillEnabled( true )->setColor( Color::Green ); w->setRotation( 45 ); - w->addEventListener( Event::MouseEnter, cb::Make1( [] ( const Event* event ) { + + w->addEventListener( Event::MouseEnter, [] ( const Event* event ) { static_cast( event->getNode() )->getBackground()->setColor( Color::Yellow ); - } ) ); - w->addEventListener( Event::MouseExit, cb::Make1( [] ( const Event* event ) { + } ); + + w->addEventListener( Event::MouseExit, [] ( const Event* event ) { static_cast( event->getNode() )->getBackground()->setColor( Color::Green ); - } ) ); - w->addEventListener( Event::MouseClick, cb::Make1( [] ( const Event* event ) { + } ); + + w->addEventListener( Event::MouseClick, [] ( const Event* event ) { static_cast( event->getNode() )->getBackground()->setColor( Color::Red ); - } ) ); + } ); C = reinterpret_cast ( C->getParent() ); @@ -2199,7 +2202,7 @@ void EETest::demo2Create() { handler.separate = cb::Make3( this, &EETest::blockerSeparate ); mSpace->addCollisionHandler( handler ); - handler.Reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet() + handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet() handler.a = CATCH_SENSOR_TYPE; handler.b = BALL_TYPE; diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index c41af0789..fa714d814 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -19,7 +19,7 @@ struct Emitter { class EETest : private Thread { public: - typedef cb::Callback0 SceneCb; + typedef std::function SceneCb; void init(); void update(); From 3cf22521f0d3d5bc8334371ed5d66982e2025a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 8 Sep 2018 16:49:37 -0300 Subject: [PATCH 2/4] Updated dr_libs. --HG-- branch : dev-functional --- src/thirdparty/dr_libs/dr_flac.h | 155 +++++++++++++++++++---------- src/thirdparty/dr_libs/dr_mp3.h | 162 +++++++++++++++++-------------- 2 files changed, 189 insertions(+), 128 deletions(-) diff --git a/src/thirdparty/dr_libs/dr_flac.h b/src/thirdparty/dr_libs/dr_flac.h index 93aa18259..bb7433939 100644 --- a/src/thirdparty/dr_libs/dr_flac.h +++ b/src/thirdparty/dr_libs/dr_flac.h @@ -1,5 +1,5 @@ // FLAC audio decoder. Public domain. See "unlicense" statement at the end of this file. -// dr_flac - v0.9.4 - 2018-06-14 +// dr_flac - v0.9.10 - 2018-08-07 // // David Reid - mackron@gmail.com @@ -111,7 +111,7 @@ // - This has not been tested on big-endian architectures. // - Rice codes in unencoded binary form (see https://xiph.org/flac/format.html#rice_partition) has not been tested. If anybody // knows where I can find some test files for this, let me know. -// - dr_flac is not thread-safe, but it's APIs can be called from any thread so long as you do your own synchronization. +// - dr_flac is not thread-safe, but its APIs can be called from any thread so long as you do your own synchronization. // - When using Ogg encapsulation, a corrupted metadata block will result in drflac_open_with_metadata() and drflac_open() // returning inconsistent samples. @@ -157,16 +157,10 @@ extern "C" { #endif // Check if we can enable 64-bit optimizations. -#if defined(_WIN64) +#if defined(_WIN64) || defined(_LP64) || defined(__LP64__) #define DRFLAC_64BIT #endif -#if defined(__GNUC__) -#if defined(__x86_64__) || defined(__ppc64__) -#define DRFLAC_64BIT -#endif -#endif - #ifdef DRFLAC_64BIT typedef drflac_uint64 drflac_cache_t; #else @@ -467,7 +461,7 @@ typedef struct // value specified in the STREAMINFO block. drflac_uint8 channels; - // The bits per sample. Will be set to somthing like 16, 24, etc. + // The bits per sample. Will be set to something like 16, 24, etc. drflac_uint8 bitsPerSample; // The maximum block size, in samples. This number represents the number of samples in each channel (not combined). @@ -579,7 +573,7 @@ drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, dr // See also: drflac_open_file_with_metadata(), drflac_open_memory_with_metadata(), drflac_open(), drflac_close() drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData); -// The same as drflac_open_with_metadata(), except attemps to open the stream even when a header block is not present. +// The same as drflac_open_with_metadata(), except attempts to open the stream even when a header block is not present. // // See also: drflac_open_with_metadata(), drflac_open_relaxed() drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData); @@ -754,6 +748,16 @@ const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, dr // /////////////////////////////////////////////////////////////////////////////// #ifdef DR_FLAC_IMPLEMENTATION +#ifdef __linux__ + #ifndef _BSD_SOURCE + #define _BSD_SOURCE + #endif + #ifndef __USE_BSD + #define __USE_BSD + #endif + #include +#endif + #include #include @@ -776,18 +780,32 @@ const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, dr __cpuid(info, fid); } #else - #define DRFLAC_NO_CPUID + #define DRFLAC_NO_CPUID #endif #else #if defined(__GNUC__) || defined(__clang__) static void drflac__cpuid(int info[4], int fid) { - __asm__ __volatile__ ( - "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) - ); + // It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the + // specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for + // supporting different assembly dialects. + // + // What's basically happening is that we're saving and restoring the ebx register manually. + #if defined(DRFLAC_X86) && defined(__PIC__) + __asm__ __volatile__ ( + "xchg{l} {%%}ebx, %k1;" + "cpuid;" + "xchg{l} {%%}ebx, %k1;" + : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) + ); + #else + __asm__ __volatile__ ( + "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) + ); + #endif } #else - #define DRFLAC_NO_CPUID + #define DRFLAC_NO_CPUID #endif #endif #else @@ -795,28 +813,37 @@ const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, dr #endif -#ifdef __linux__ -#define _BSD_SOURCE -#include -#endif - #if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) -#define DRFLAC_HAS_LZCNT_INTRINSIC + #define DRFLAC_HAS_LZCNT_INTRINSIC #elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) -#define DRFLAC_HAS_LZCNT_INTRINSIC + #define DRFLAC_HAS_LZCNT_INTRINSIC #elif defined(__clang__) #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl) - #define DRFLAC_HAS_LZCNT_INTRINSIC + #define DRFLAC_HAS_LZCNT_INTRINSIC #endif #endif #if defined(_MSC_VER) && _MSC_VER >= 1300 -#define DRFLAC_HAS_BYTESWAP_INTRINSIC -#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -#define DRFLAC_HAS_BYTESWAP_INTRINSIC + #define DRFLAC_HAS_BYTESWAP16_INTRINSIC + #define DRFLAC_HAS_BYTESWAP32_INTRINSIC + #define DRFLAC_HAS_BYTESWAP64_INTRINSIC #elif defined(__clang__) - #if __has_builtin(__builtin_bswap16) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64) - #define DRFLAC_HAS_BYTESWAP_INTRINSIC + #if __has_builtin(__builtin_bswap16) + #define DRFLAC_HAS_BYTESWAP16_INTRINSIC + #endif + #if __has_builtin(__builtin_bswap32) + #define DRFLAC_HAS_BYTESWAP32_INTRINSIC + #endif + #if __has_builtin(__builtin_bswap64) + #define DRFLAC_HAS_BYTESWAP64_INTRINSIC + #endif +#elif defined(__GNUC__) + #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define DRFLAC_HAS_BYTESWAP32_INTRINSIC + #define DRFLAC_HAS_BYTESWAP64_INTRINSIC + #endif + #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) + #define DRFLAC_HAS_BYTESWAP16_INTRINSIC #endif #endif @@ -914,7 +941,7 @@ static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian() static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n) { -#ifdef DRFLAC_HAS_BYTESWAP_INTRINSIC +#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC #if defined(_MSC_VER) return _byteswap_ushort(n); #elif defined(__GNUC__) || defined(__clang__) @@ -930,7 +957,7 @@ static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n) static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n) { -#ifdef DRFLAC_HAS_BYTESWAP_INTRINSIC +#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC #if defined(_MSC_VER) return _byteswap_ulong(n); #elif defined(__GNUC__) || defined(__clang__) @@ -948,7 +975,7 @@ static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n) static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n) { -#ifdef DRFLAC_HAS_BYTESWAP_INTRINSIC +#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC #if defined(_MSC_VER) return _byteswap_uint64(n); #elif defined(__GNUC__) || defined(__clang__) @@ -1438,7 +1465,7 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned i if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) { if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { - *pResultOut = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount); + *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount); bs->consumedBits += bitCount; bs->cache <<= bitCount; } else { @@ -1451,13 +1478,13 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned i // It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs); drflac_uint32 bitCountLo = bitCount - bitCountHi; - drflac_uint32 resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi); + drflac_uint32 resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi); if (!drflac__reload_cache(bs)) { return DRFLAC_FALSE; } - *pResultOut = (resultHi << bitCountLo) | DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo); + *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo); bs->consumedBits += bitCountLo; bs->cache <<= bitCountLo; return DRFLAC_TRUE; @@ -1483,6 +1510,7 @@ static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, dr return DRFLAC_TRUE; } +#ifdef DRFLAC_64BIT static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut) { drflac_assert(bitCount <= 64); @@ -1501,6 +1529,7 @@ static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, d *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo); return DRFLAC_TRUE; } +#endif // Function below is unused, but leaving it here in case I need to quickly add it again. #if 0 @@ -3175,10 +3204,10 @@ static drflac_bool32 drflac__seek_to_sample__brute_force(drflac* pFlac, drflac_u drflac_bool32 isMidFrame = DRFLAC_FALSE; - // If we are seeking foward we start from the current position. Otherwise we need to start all the way from the start of the file. + // If we are seeking forward we start from the current position. Otherwise we need to start all the way from the start of the file. drflac_uint64 runningSampleCount; if (sampleIndex >= pFlac->currentSample) { - // Seeking foward. Need to seek from the current position. + // Seeking forward. Need to seek from the current position. runningSampleCount = pFlac->currentSample; // The frame header for the first frame may not yet have been read. We need to do that if necessary. @@ -3204,7 +3233,7 @@ static drflac_bool32 drflac__seek_to_sample__brute_force(drflac* pFlac, drflac_u } } - // We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect it's + // We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect its // header. If based on the header we can determine that the frame contains the sample, we do a full decode of that frame. for (;;) { drflac_uint64 firstSampleInFrame = 0; @@ -3657,7 +3686,7 @@ drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_s // Padding doesn't have anything meaningful in it, so just skip over it, but make sure the caller is aware of it by firing the callback. if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) { - isLastBlock = DRFLAC_TRUE; // An error occured while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. + isLastBlock = DRFLAC_TRUE; // An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. } else { onMeta(pUserDataMD, &metadata); } @@ -3669,7 +3698,7 @@ drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_s // Invalid chunk. Just skip over this one. if (onMeta) { if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) { - isLastBlock = DRFLAC_TRUE; // An error occured while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. + isLastBlock = DRFLAC_TRUE; // An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. } } } break; @@ -4003,7 +4032,7 @@ drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserD // The main part of the Ogg encapsulation is the conversion from the physical Ogg bitstream to the native FLAC bitstream. It works -// in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is architecured +// in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is designed // in such a way that the core sections assume everything is delivered in native format. Therefore, for each encapsulation type // dr_flac is supporting there needs to be a layer sitting on top of the onRead and onSeek callbacks that ensures the bits read from // the physical Ogg bitstream are converted and delivered in native FLAC format. @@ -4351,13 +4380,13 @@ drflac_bool32 drflac_ogg__seek_to_sample(drflac* pFlac, drflac_uint64 sampleInde // // Another thing to consider is that using the Ogg framing system will perform direct seeking of the physical Ogg // bitstream. This is important to consider because it means we cannot read data from the drflac_bs object using the - // standard drflac__*() APIs because that will read in extra data for it's own internal caching which in turn breaks + // standard drflac__*() APIs because that will read in extra data for its own internal caching which in turn breaks // the positioning of the read pointer of the physical Ogg bitstream. Therefore, anything that would normally be read // using the native FLAC decoding APIs, such as drflac__read_next_frame_header(), need to be re-implemented so as to // avoid the use of the drflac_bs object. // // Considering these issues, I have decided to use the slower native FLAC decoding method for the following reasons: - // 1) Seeking is already partially accellerated using Ogg's paging system in the code block above. + // 1) Seeking is already partially accelerated using Ogg's paging system in the code block above. // 2) Seeking in an Ogg encapsulated FLAC stream is probably quite uncommon. // 3) Simplicity. if (!drflac__read_next_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFrame.header)) { @@ -4550,7 +4579,7 @@ drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_pro // If we get here it means we found a FLAC audio stream. We should be sitting on the first byte of the header of the next page. The next - // packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialiation phase for Ogg is to create the + // packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialization phase for Ogg is to create the // Ogg bistream object. pInit->hasMetadataBlocks = DRFLAC_TRUE; // <-- Always have at least VORBIS_COMMENT metadata block. return DRFLAC_TRUE; @@ -4699,8 +4728,8 @@ drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_p } drflac_oggbs oggbs; + drflac_zero_memory(&oggbs, sizeof(oggbs)); if (init.container == drflac_container_ogg) { - drflac_zero_memory(&oggbs, sizeof(oggbs)); oggbs.onRead = onRead; oggbs.onSeek = onSeek; oggbs.pUserData = pUserData; @@ -4758,7 +4787,7 @@ drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_p pFlac->firstFramePos = firstFramePos; - // NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has it's own accelerated seeking system). I may change this later, so I'm leaving this here for now. + // NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has its own accelerated seeking system). I may change this later, so I'm leaving this here for now. #ifndef DR_FLAC_NO_OGG if (init.container == drflac_container_ogg) { @@ -5469,15 +5498,17 @@ drflac_bool32 drflac_seek_to_sample(drflac* pFlac, drflac_uint64 sampleIndex) //// High Level APIs //// -// I couldn't figure out where SIZE_MAX was defined for VC6. If anybody knows, let me know. -#if defined(_MSC_VER) && _MSC_VER <= 1200 -#ifdef DRFLAC_64BIT -#define SIZE_MAX ((drflac_uint64)0xFFFFFFFFFFFFFFFF) +#if defined(SIZE_MAX) + #define DRFLAC_SIZE_MAX SIZE_MAX #else -#define SIZE_MAX 0xFFFFFFFF -#endif + #if defined(DRFLAC_64BIT) + #define DRFLAC_SIZE_MAX ((drflac_uint64)0xFFFFFFFFFFFFFFFF) + #else + #define DRFLAC_SIZE_MAX 0xFFFFFFFF + #endif #endif + // Using a macro as the definition of the drflac__full_decode_and_close_*() API family. Sue me. #define DRFLAC_DEFINE_FULL_DECODE_AND_CLOSE(extension, type) \ static type* drflac__full_decode_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalSampleCountOut)\ @@ -5518,7 +5549,7 @@ static type* drflac__full_decode_and_close_ ## extension (drflac* pFlac, unsigne drflac_zero_memory(pSampleData + totalSampleCount, (size_t)(sampleDataBufferSize - totalSampleCount*sizeof(type))); \ } else { \ drflac_uint64 dataSize = totalSampleCount * sizeof(type); \ - if (dataSize > SIZE_MAX) { \ + if (dataSize > DRFLAC_SIZE_MAX) { \ goto on_error; /* The decoded data is too big. */ \ } \ \ @@ -5719,6 +5750,24 @@ const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, dr // REVISION HISTORY // +// v0.9.10 - 2018-08-07 +// - Improve 64-bit detection. +// +// v0.9.9 - 2018-08-05 +// - Fix C++ build on older versions of GCC. +// +// v0.9.8 - 2018-07-24 +// - Fix compilation errors. +// +// v0.9.7 - 2018-07-05 +// - Fix a warning. +// +// v0.9.6 - 2018-06-29 +// - Fix some typos. +// +// v0.9.5 - 2018-06-23 +// - Fix some warnings. +// // v0.9.4 - 2018-06-14 // - Optimizations to seeking. // - Clean up. diff --git a/src/thirdparty/dr_libs/dr_mp3.h b/src/thirdparty/dr_libs/dr_mp3.h index c764e2ce2..5e1351481 100644 --- a/src/thirdparty/dr_libs/dr_mp3.h +++ b/src/thirdparty/dr_libs/dr_mp3.h @@ -1,5 +1,5 @@ // MP3 audio decoder. Public domain. See "unlicense" statement at the end of this file. -// dr_mp3 - v0.2.4 - 2018-05-12 +// dr_mp3 - v0.2.11 - 2018-08-08 // // David Reid - mackron@gmail.com // @@ -99,21 +99,14 @@ typedef drmp3_uint32 drmp3_bool32; // ================== typedef struct { - int frame_bytes; - int channels; - int hz; - int layer; - int bitrate_kbps; + int frame_bytes, channels, hz, layer, bitrate_kbps; } drmp3dec_frame_info; typedef struct { - float mdct_overlap[2][9*32]; - float qmf_state[15*2*32]; - int reserv; - int free_format_bytes; - unsigned char header[4]; - unsigned char reserv_buf[511]; + float mdct_overlap[2][9*32], qmf_state[15*2*32]; + int reserv, free_format_bytes; + unsigned char header[4], reserv_buf[511]; } drmp3dec; // Initializes a low level decoder. @@ -361,7 +354,7 @@ void drmp3_free(void* p); #if defined(_MSC_VER) #include #endif -#include +#include #define DRMP3_HAVE_SSE 1 #define DRMP3_HAVE_SIMD 1 #define DRMP3_VSTORE _mm_storeu_ps @@ -412,10 +405,10 @@ static int drmp3_have_simd() #ifdef MINIMP3_TEST static int g_counter; if (g_counter++ > 100) - goto test_nosimd; + return 0; #endif if (g_have_simd) - return g_have_simd - 1; + goto end; drmp3_cpuid(CPUInfo, 0); if (CPUInfo[0] > 0) { @@ -423,11 +416,9 @@ static int drmp3_have_simd() g_have_simd = (CPUInfo[3] & (1 << 26)) + 1; /* SSE2 */ return g_have_simd - 1; } -#ifdef MINIMP3_TEST -test_nosimd: -#endif - g_have_simd = 1; - return 0; + +end: + return g_have_simd - 1; #endif } #elif defined(__ARM_NEON) || defined(__aarch64__) @@ -464,44 +455,27 @@ static int drmp3_have_simd() typedef struct { const drmp3_uint8 *buf; - int pos; - int limit; + int pos, limit; } drmp3_bs; typedef struct { - drmp3_uint8 total_bands; - drmp3_uint8 stereo_bands; - drmp3_uint8 bitalloc[64]; - drmp3_uint8 scfcod[64]; float scf[3*64]; + drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64]; } drmp3_L12_scale_info; typedef struct { - drmp3_uint8 tab_offset; - drmp3_uint8 code_tab_width; - drmp3_uint8 band_count; + drmp3_uint8 tab_offset, code_tab_width, band_count; } drmp3_L12_subband_alloc; typedef struct { const drmp3_uint8 *sfbtab; - drmp3_uint16 part_23_length; - drmp3_uint16 big_values; - drmp3_uint16 scalefac_compress; - drmp3_uint8 global_gain; - drmp3_uint8 block_type; - drmp3_uint8 mixed_block_flag; - drmp3_uint8 n_long_sfb; - drmp3_uint8 n_short_sfb; - drmp3_uint8 table_select[3]; - drmp3_uint8 region_count[3]; - drmp3_uint8 subblock_gain[3]; - drmp3_uint8 preflag; - drmp3_uint8 scalefac_scale; - drmp3_uint8 count1_table; - drmp3_uint8 scfsi; + drmp3_uint16 part_23_length, big_values, scalefac_compress; + drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb; + drmp3_uint8 table_select[3], region_count[3], subblock_gain[3]; + drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi; } drmp3_L3_gr_info; typedef struct @@ -509,10 +483,8 @@ typedef struct drmp3_bs bs; drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES]; drmp3_L3_gr_info gr_info[4]; - float grbuf[2][576]; - float scf[40]; + float grbuf[2][576], scf[40], syn[18 + 15][2*32]; drmp3_uint8 ist_pos[2][39]; - float syn[18 + 15][2*32]; } drmp3dec_scratch; static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes) @@ -990,17 +962,19 @@ static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *is } } +static const float g_drmp3_pow43[129 + 16] = { + 0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f, + 0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f +}; + static float drmp3_L3_pow_43(int x) { - static const float g_pow43[129] = { - 0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f - }; float frac; int sign, mult = 256; if (x < 129) { - return g_pow43[x]; + return g_drmp3_pow43[16 + x]; } if (x < 1024) @@ -1011,31 +985,30 @@ static float drmp3_L3_pow_43(int x) sign = 2*x & 64; frac = (float)((x & 63) - sign) / ((x & ~63) + sign); - return g_pow43[(x + sign) >> 6]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult; + return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult; } static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit) { - static const float g_pow43_signed[32] = { 0,0,1,-1,2.519842f,-2.519842f,4.326749f,-4.326749f,6.349604f,-6.349604f,8.549880f,-8.549880f,10.902724f,-10.902724f,13.390518f,-13.390518f,16.000000f,-16.000000f,18.720754f,-18.720754f,21.544347f,-21.544347f,24.463781f,-24.463781f,27.473142f,-27.473142f,30.567351f,-30.567351f,33.741992f,-33.741992f,36.993181f,-36.993181f }; - static const drmp3_int16 tab0[32] = { 0, }; - static const drmp3_int16 tab1[] = { 785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256 }; - static const drmp3_int16 tab2[] = { -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288 }; - static const drmp3_int16 tab3[] = { -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288 }; - static const drmp3_int16 tab5[] = { -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258 }; - static const drmp3_int16 tab6[] = { -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259 }; - static const drmp3_int16 tab7[] = { -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258 }; - static const drmp3_int16 tab8[] = { -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258 }; - static const drmp3_int16 tab9[] = { -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259 }; - static const drmp3_int16 tab10[] = { -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258 }; - static const drmp3_int16 tab11[] = { -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290 }; - static const drmp3_int16 tab12[] = { -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259 }; - static const drmp3_int16 tab13[] = { -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258 }; - static const drmp3_int16 tab15[] = { -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259 }; - static const drmp3_int16 tab16[] = { -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258 }; - static const drmp3_int16 tab24[] = { -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 }; + static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256, + -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288, + -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288, + -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258, + -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259, + -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258, + -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258, + -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259, + -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258, + -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290, + -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259, + -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258, + -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259, + -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258, + -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 }; static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205}; static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 }; - static const drmp3_int16 * const tabindex[2*16] = { tab0,tab1,tab2,tab3,tab0,tab5,tab6,tab7,tab8,tab9,tab10,tab11,tab12,tab13,tab0,tab15,tab16,tab16,tab16,tab16,tab16,tab16,tab16,tab16,tab24,tab24,tab24,tab24,tab24,tab24,tab24,tab24 }; + static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 }; static const drmp3_uint8 g_linbits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 }; #define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - n)) @@ -1055,7 +1028,7 @@ static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *g { int tab_num = gr_info->table_select[ireg]; int sfb_cnt = gr_info->region_count[ireg++]; - const short *codebook = tabindex[tab_num]; + const short *codebook = tabs + tabindex[tab_num]; int linbits = g_linbits[tab_num]; do { @@ -1085,7 +1058,7 @@ static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *g *dst = one*drmp3_L3_pow_43(lsb)*((int32_t)bs_cache < 0 ? -1: 1); } else { - *dst = g_pow43_signed[lsb*2 + (bs_cache >> 31)]*one; + *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one; } DRMP3_FLUSH_BITS(lsb ? 1 : 0); } @@ -1942,6 +1915,11 @@ int drmp3dec_decode_frame(drmp3dec *dec, const unsigned char *mp3, int mp3_bytes info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr); info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr); + if (!pcm) + { + return drmp3_hdr_frame_samples(hdr); + } + drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE); if (DRMP3_HDR_IS_CRC(hdr)) { @@ -2006,6 +1984,16 @@ int drmp3dec_decode_frame(drmp3dec *dec, const unsigned char *mp3, int mp3_bytes // /////////////////////////////////////////////////////////////////////////////// +#if defined(SIZE_MAX) + #define DRMP3_SIZE_MAX SIZE_MAX +#else + #if defined(_WIN64) || defined(_LP64) || defined(__LP64__) + #define DRMP3_SIZE_MAX ((drmp3_uint64)0xFFFFFFFFFFFFFFFF) + #else + #define DRMP3_SIZE_MAX 0xFFFFFFFF + #endif +#endif + // Options. #ifndef DR_MP3_DEFAULT_CHANNELS #define DR_MP3_DEFAULT_CHANNELS 2 @@ -2313,8 +2301,10 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3) size_t bytesRead = pMP3->onRead(pMP3->pUserData, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize)); if (bytesRead == 0) { - pMP3->atEnd = DRMP3_TRUE; - return DRMP3_FALSE; // No data. + if (pMP3->dataSize == 0) { + pMP3->atEnd = DRMP3_TRUE; + return DRMP3_FALSE; // No data. + } } pMP3->dataSize += bytesRead; @@ -2683,7 +2673,7 @@ float* drmp3__full_decode_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp } drmp3_uint64 newFramesBufferSize = framesCapacity*pMP3->channels*sizeof(float); - if (newFramesBufferSize > SIZE_MAX) { + if (newFramesBufferSize > DRMP3_SIZE_MAX) { break; } @@ -2773,6 +2763,28 @@ void drmp3_free(void* p) // REVISION HISTORY // =============== // +// v0.2.11 - 2018-08-08 +// - Fix a bug where the last part of a file is not read. +// +// v0.2.10 - 2018-08-07 +// - Improve 64-bit detection. +// +// v0.2.9 - 2018-08-05 +// - Fix C++ build on older versions of GCC. +// - Bring up to date with minimp3. +// +// v0.2.8 - 2018-08-02 +// - Fix compilation errors with older versions of GCC. +// +// v0.2.7 - 2018-07-13 +// - Bring up to date with minimp3. +// +// v0.2.6 - 2018-07-12 +// - Bring up to date with minimp3. +// +// v0.2.5 - 2018-06-22 +// - Bring up to date with minimp3. +// // v0.2.4 - 2018-05-12 // - Bring up to date with minimp3. // From 787e68230c8a3ab55c815784f7c8014bd64c0c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 26 Nov 2018 10:39:35 -0300 Subject: [PATCH 3/4] Minor clean up. --HG-- branch : dev-functional --- include/eepp/system/virtualfilesystem.hpp | 2 +- projects/linux/ee.creator.user | 183 +++++++++++++--------- src/eepp/system/filesystem.cpp | 6 +- src/eepp/system/pak.cpp | 3 +- src/eepp/system/translator.cpp | 4 +- src/eepp/system/virtualfilesystem.cpp | 9 +- src/eepp/system/zip.cpp | 6 +- 7 files changed, 126 insertions(+), 87 deletions(-) diff --git a/include/eepp/system/virtualfilesystem.hpp b/include/eepp/system/virtualfilesystem.hpp index b84b6bd77..5fdeab204 100644 --- a/include/eepp/system/virtualfilesystem.hpp +++ b/include/eepp/system/virtualfilesystem.hpp @@ -29,7 +29,7 @@ class EE_API VirtualFileSystem : protected Container { vfsFile() {} - vfsFile( std::string path, Pack * pack ) : + vfsFile( const std::string& path, Pack * pack ) : path( path ), pack( pack ) {} diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index cced14bbe..43d03c721 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -61,6 +61,8 @@ ProjectExplorer.Project.PluginSettings + + true @@ -88,8 +90,9 @@ false - -j`nproc` eepp-test + eepp-test make + false true @@ -128,8 +131,9 @@ false - -j`nproc` -e config=release eepp-test + -e config=release eepp-test + false true Make @@ -177,8 +181,9 @@ false - -j8 + make + false true Make @@ -226,8 +231,9 @@ false - -j`nproc` -e config=release + -e config=release make + false true Make @@ -266,8 +272,9 @@ false - -j`nproc` + make.sh + false true Make @@ -306,8 +313,9 @@ false - -j`nproc` -e config=release + -e config=release make.sh + false true Make @@ -346,8 +354,9 @@ false - -j`nproc` eepp-sound + eepp-sound make + false true Make @@ -386,8 +395,9 @@ false - -j`nproc` eepp-sprites + eepp-sprites make + false true Make @@ -426,8 +436,9 @@ false - -j`nproc` eepp-fonts + eepp-fonts make + false true Make @@ -466,8 +477,9 @@ false - -j`nproc` eepp-vbo-fbo-batch + eepp-vbo-fbo-batch make + false true Make @@ -506,8 +518,9 @@ false - -j`nproc` eepp-physics + eepp-physics make + false true Make @@ -546,8 +559,9 @@ false - -j`nproc` eepp-http-request + eepp-http-request make + false true Make @@ -586,8 +600,9 @@ false - -j`nproc` eepp-static + eepp-static + false true @@ -635,8 +650,9 @@ false - -j`nproc` eeiv + eeiv make + false true Make @@ -675,8 +691,9 @@ false - -j`nproc` -e config=release eepp-static + -e config=release eepp-static + false true @@ -715,8 +732,9 @@ false - -j`nproc` eepp-shared + eepp-shared + false true @@ -755,8 +773,9 @@ false - -j`nproc` -e config=release eepp-shared + -e config=release eepp-shared + false true @@ -804,8 +823,9 @@ false - -j`nproc` eepp-ew + eepp-ew + false true Make Clone of @@ -844,8 +864,9 @@ false - -j`nproc` -e config=release eepp-ew + -e config=release eepp-ew + false true Make Clone of Make @@ -884,8 +905,9 @@ false - -j`nproc` eepp-es + eepp-es + false true Make Clone of @@ -924,8 +946,9 @@ false - -j`nproc` -e config=release eepp-es + -e config=release eepp-es + false true Make Clone of Make @@ -1015,19 +1038,20 @@ 2 - %{buildDir}../../../bin/eetest-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eetest-debug eetest-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1071,19 +1095,20 @@ 2 - %{buildDir}../../../bin/eetest - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eetest eetest-release ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1127,19 +1152,20 @@ 2 - %{buildDir}../../../bin/eephysics-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eephysics-debug eephysics-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1183,19 +1209,20 @@ 2 - %{buildDir}../../../bin/eehttp-request-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eehttp-request-debug eehttp-request-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1239,19 +1266,20 @@ 2 - %{buildDir}../../../bin/eeiv-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eeiv-debug eeiv-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1295,19 +1323,20 @@ 2 - %{buildDir}../../../bin/eepp-TextureAtlasEditor-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eepp-TextureAtlasEditor-debug eepp-TextureAtlasEditor-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1351,19 +1380,20 @@ 2 - %{buildDir}../../../bin/eepp-MapEditor-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eepp-MapEditor-debug eepp-MapEditor-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1407,19 +1437,20 @@ 2 - %{buildDir}../../../bin/eepp-UIEditor-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eepp-UIEditor-debug eepp-UIEditor-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1463,19 +1494,20 @@ 2 - %{buildDir}../../../bin/eeew-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eeew-debug eeew-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1519,19 +1551,20 @@ 2 - %{buildDir}../../../bin/eeew - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eeew eeew-release ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false false + false + %{buildDir}../../../bin/ + false @@ -1575,19 +1608,20 @@ 2 - %{buildDir}../../../bin/eees-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eees-debug eees-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1631,19 +1665,20 @@ 2 - %{buildDir}../../../bin/eees - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eees eees-release ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1687,19 +1722,20 @@ 2 - %{buildDir}../../../bin/eesound-debug - true - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eesound-debug eesound-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + true + %{buildDir}../../../bin/ + false @@ -1743,19 +1779,20 @@ 2 - %{buildDir}../../../bin/eesprites-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eesprites-debug eesprites-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1799,19 +1836,20 @@ 2 - %{buildDir}../../../bin/eefonts-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eefonts-debug eefonts-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + false @@ -1855,19 +1893,20 @@ 2 - %{buildDir}../../../bin/eevbo-fbo-batch-debug - false - %{buildDir}../../../bin/ Run %{buildDir}../../../bin/eevbo-fbo-batch-debug eevbo-fbo-batch-debug ProjectExplorer.CustomExecutableRunConfiguration + 3768 true false false false true + false + %{buildDir}../../../bin/ + 16 @@ -1878,10 +1917,10 @@ ProjectExplorer.Project.Updater.FileVersion - 18 + 20 Version - 18 + 20 diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index 871dce2f6..a9ace7b3e 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -212,9 +212,7 @@ std::string FileSystem::removeLastFolderFromPath( std::string path ) { if ( pos2 != pos ) { sstr = path.substr(0,pos) + getOSSlash(); } else { - if ( pos == pos2 ) { - sstr = path.substr(0,pos2+1); - } + sstr = path.substr(0,pos2+1); } if ( sstr.size() ) { @@ -527,7 +525,7 @@ std::string FileSystem::sizeToString( const Int64& Size ) { } bool FileSystem::changeWorkingDirectory( const std::string & path ) { - int res = -1; + int res; #ifdef EE_COMPILER_MSVC #ifdef UNICODE res = _wchdir( String::fromUtf8( path.c_str() ).toWideString().c_str() ); diff --git a/src/eepp/system/pak.cpp b/src/eepp/system/pak.cpp index e7f0936c2..760b11540 100755 --- a/src/eepp/system/pak.cpp +++ b/src/eepp/system/pak.cpp @@ -302,7 +302,6 @@ bool Pak::eraseFiles( const std::vector& paths ) { Uint32 total_offset = 0, i = 0; pakFile nPf; std::vector uEntry; - bool Remove; for ( i = 0; i < paths.size(); i++ ) { Ex = exists( paths[i] ); @@ -317,7 +316,7 @@ bool Pak::eraseFiles( const std::vector& paths ) { nPf.fs = eeNew( IOStreamFile, ( nPf.pakPath.c_str() , "wb" ) ); for ( i = 0; i < mPakFiles.size(); i++ ) { - Remove = false; + bool Remove = false; for ( Uint32 u = 0; u < files.size(); u++ ) { if ( files[u] == static_cast(i) ) diff --git a/src/eepp/system/translator.cpp b/src/eepp/system/translator.cpp index 30782319d..2c535f9bf 100644 --- a/src/eepp/system/translator.cpp +++ b/src/eepp/system/translator.cpp @@ -173,7 +173,7 @@ String Translator::getStringf( const char * key, ... ) { const char * format = str.c_str(); - int n, size = 256; + int size = 256; std::string tstr( size, '\0' ); va_list args; @@ -181,7 +181,7 @@ String Translator::getStringf( const char * key, ... ) { while (1) { va_start( args, key ); - n = vsnprintf( &tstr[0], size, format, args ); + int n = vsnprintf( &tstr[0], size, format, args ); if ( n > -1 && n < size ) { tstr.resize( n ); diff --git a/src/eepp/system/virtualfilesystem.cpp b/src/eepp/system/virtualfilesystem.cpp index 2cfaeff6a..9e51e6006 100644 --- a/src/eepp/system/virtualfilesystem.cpp +++ b/src/eepp/system/virtualfilesystem.cpp @@ -20,9 +20,10 @@ std::vector VirtualFileSystem::filesGetInPath( std::string path ) { std::vector files; std::vector paths = vfsSplitPath( path ); vfsDirectory * curDir = &mRoot; - size_t pos = 0; if ( paths.size() >= 1 ) { + size_t pos = 0; + do { if ( pos < paths.size() ) { if ( curDir->directories.find( paths[pos] ) == curDir->directories.end() ) { @@ -47,9 +48,10 @@ std::vector VirtualFileSystem::filesGetInPath( std::string path ) { Pack * VirtualFileSystem::getPackFromFile( std::string path ) { std::vector paths = vfsSplitPath( path ); vfsDirectory * curDir = &mRoot; - size_t pos = 0; if ( paths.size() >= 1 ) { + size_t pos = 0; + do { if ( pos == paths.size() - 1 ) { if ( curDir->files.find( paths[pos] ) != curDir->files.end() ) { @@ -97,9 +99,10 @@ void VirtualFileSystem::onResourceRemove( Pack * resource ) { void VirtualFileSystem::addFile( std::string path , Pack * pack ) { std::vector paths = vfsSplitPath( path ); vfsDirectory * curDir = &mRoot; - size_t pos = 0; if ( paths.size() >= 1 ) { + size_t pos = 0; + do { if ( pos == paths.size() - 1 ) { curDir->files[ paths[pos] ] = vfsFile( path, pack ); diff --git a/src/eepp/system/zip.cpp b/src/eepp/system/zip.cpp index 80c34d7d3..e7f03e844 100644 --- a/src/eepp/system/zip.cpp +++ b/src/eepp/system/zip.cpp @@ -142,7 +142,7 @@ bool Zip::eraseFiles( const std::vector& paths ) { bool Zip::extractFile( const std::string& path , const std::string& dest ) { lock(); - bool Ret = false; + bool Ret; SafeDataPointer data; @@ -161,9 +161,9 @@ bool Zip::extractFileToMemory( const std::string& path, std::vector& data bool Ret = false; Int32 Pos = exists( path ); - int Result = 0; if ( 0 == checkPack() && -1 != Pos ) { + data.clear(); struct zip_stat zs; @@ -175,7 +175,7 @@ bool Zip::extractFileToMemory( const std::string& path, std::vector& data if ( NULL != zf ) { data.resize( zs.size ); - Result = (Int32)zip_fread( zf, reinterpret_cast (&data[0]), data.size() ); + int Result = (Int32)zip_fread( zf, reinterpret_cast (&data[0]), data.size() ); zip_fclose(zf); From 75f09fdb4abc9f907550a7f4c8d1514291d54059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 26 Nov 2018 14:13:53 +0000 Subject: [PATCH 4/4] Close branch dev-functional --HG-- branch : dev-functional