Merge pull request #6921 from minggo/code-fix

coding style fix
This commit is contained in:
minggo 2014-05-28 17:55:32 +08:00
commit 120aa0f24e
21 changed files with 230 additions and 249 deletions

View File

@ -263,7 +263,7 @@ AccelAmplitude* AccelAmplitude::clone() const
return a;
}
AccelAmplitude::~AccelAmplitude(void)
AccelAmplitude::~AccelAmplitude()
{
CC_SAFE_DELETE(_other);
}

View File

@ -169,7 +169,7 @@ public:
/** get amplitude rate */
inline float getRate(void) const { return _rate; }
/** set amplitude rate */
inline void setRate(float fRate) { _rate = fRate; }
inline void setRate(float rate) { _rate = rate; }
// Overrides
virtual void startWithTarget(Node *target) override;
@ -182,7 +182,7 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~AccelDeccelAmplitude();
/** initializes the action with an inner action that has the amplitude property, and a duration time */
bool initWithAction(Action *pAction, float duration);
bool initWithAction(Action *action, float duration);
protected:
float _rate;
@ -232,7 +232,7 @@ public:
static DeccelAmplitude* create(Action *action, float duration);
/** get amplitude rate */
inline float getRate(void) const { return _rate; }
inline float getRate() const { return _rate; }
/** set amplitude rate */
inline void setRate(float rate) { _rate = rate; }

View File

@ -57,7 +57,7 @@ ExtraAction* ExtraAction::create()
}
return ret;
}
ExtraAction* ExtraAction::clone(void) const
ExtraAction* ExtraAction::clone() const
{
// no copy constructor
auto a = new ExtraAction();
@ -65,7 +65,7 @@ ExtraAction* ExtraAction::clone(void) const
return a;
}
ExtraAction* ExtraAction::reverse(void) const
ExtraAction* ExtraAction::reverse() const
{
return ExtraAction::create();
}
@ -102,7 +102,7 @@ bool ActionInterval::initWithDuration(float d)
return true;
}
bool ActionInterval::isDone(void) const
bool ActionInterval::isDone() const
{
return _elapsed >= _duration;
}
@ -134,7 +134,7 @@ void ActionInterval::setAmplitudeRate(float amp)
CCASSERT(0, "");
}
float ActionInterval::getAmplitudeRate(void)
float ActionInterval::getAmplitudeRate()
{
// Abstract class needs implementation
CCASSERT(0, "");
@ -260,7 +260,7 @@ bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction
return true;
}
Sequence* Sequence::clone(void) const
Sequence* Sequence::clone() const
{
// no copy constructor
auto a = new Sequence();
@ -507,7 +507,7 @@ bool RepeatForever::initWithAction(ActionInterval *action)
return true;
}
RepeatForever *RepeatForever::clone(void) const
RepeatForever *RepeatForever::clone() const
{
// no copy constructor
auto a = new RepeatForever();
@ -909,7 +909,7 @@ bool RotateBy::initWithDuration(float duration, const Vec3& deltaAngle3D)
}
RotateBy* RotateBy::clone(void) const
RotateBy* RotateBy::clone() const
{
// no copy constructor
auto a = new RotateBy();
@ -993,7 +993,7 @@ bool MoveBy::initWithDuration(float duration, const Vec2& deltaPosition)
return false;
}
MoveBy* MoveBy::clone(void) const
MoveBy* MoveBy::clone() const
{
// no copy constructor
auto a = new MoveBy();
@ -1055,7 +1055,7 @@ bool MoveTo::initWithDuration(float duration, const Vec2& position)
return false;
}
MoveTo* MoveTo::clone(void) const
MoveTo* MoveTo::clone() const
{
// no copy constructor
auto a = new MoveTo();
@ -1107,7 +1107,7 @@ bool SkewTo::initWithDuration(float t, float sx, float sy)
return bRet;
}
SkewTo* SkewTo::clone(void) const
SkewTo* SkewTo::clone() const
{
// no copy constructor
auto a = new SkewTo();
@ -1277,7 +1277,7 @@ bool JumpBy::initWithDuration(float duration, const Vec2& position, float height
return false;
}
JumpBy* JumpBy::clone(void) const
JumpBy* JumpBy::clone() const
{
// no copy constructor
auto a = new JumpBy();
@ -1337,7 +1337,7 @@ JumpTo* JumpTo::create(float duration, const Vec2& position, float height, int j
return jumpTo;
}
JumpTo* JumpTo::clone(void) const
JumpTo* JumpTo::clone() const
{
// no copy constructor
auto a = new JumpTo();
@ -1400,7 +1400,7 @@ void BezierBy::startWithTarget(Node *target)
_previousPosition = _startPosition = target->getPosition();
}
BezierBy* BezierBy::clone(void) const
BezierBy* BezierBy::clone() const
{
// no copy constructor
auto a = new BezierBy();
@ -1441,7 +1441,7 @@ void BezierBy::update(float time)
}
}
BezierBy* BezierBy::reverse(void) const
BezierBy* BezierBy::reverse() const
{
ccBezierConfig r;
@ -1477,7 +1477,7 @@ bool BezierTo::initWithDuration(float t, const ccBezierConfig &c)
return false;
}
BezierTo* BezierTo::clone(void) const
BezierTo* BezierTo::clone() const
{
// no copy constructor
auto a = new BezierTo();
@ -1573,7 +1573,7 @@ bool ScaleTo::initWithDuration(float duration, float sx, float sy, float sz)
return false;
}
ScaleTo* ScaleTo::clone(void) const
ScaleTo* ScaleTo::clone() const
{
// no copy constructor
auto a = new ScaleTo();
@ -1641,7 +1641,7 @@ ScaleBy* ScaleBy::create(float duration, float sx, float sy, float sz)
return scaleBy;
}
ScaleBy* ScaleBy::clone(void) const
ScaleBy* ScaleBy::clone() const
{
// no copy constructor
auto a = new ScaleBy();
@ -2091,7 +2091,7 @@ ReverseTime::ReverseTime() : _other(nullptr)
}
ReverseTime::~ReverseTime(void)
ReverseTime::~ReverseTime()
{
CC_SAFE_RELEASE(_other);
}
@ -2219,7 +2219,7 @@ void Animate::startWithTarget(Node *target)
_executedLoops = 0;
}
void Animate::stop(void)
void Animate::stop()
{
if (_animation->getRestoreOriginalFrame() && _target)
{
@ -2349,7 +2349,7 @@ TargetedAction* TargetedAction::clone() const
return a;
}
TargetedAction* TargetedAction::reverse(void) const
TargetedAction* TargetedAction::reverse() const
{
// just reverse the internal action
auto a = new TargetedAction();
@ -2364,7 +2364,7 @@ void TargetedAction::startWithTarget(Node *target)
_action->startWithTarget(_forcedTarget);
}
void TargetedAction::stop(void)
void TargetedAction::stop()
{
_action->stop();
}

View File

@ -766,7 +766,7 @@ public:
// Overrides
//
virtual Blink* clone() const override;
virtual Blink* reverse(void) const override;
virtual Blink* reverse() const override;
virtual void update(float time) override;
virtual void startWithTarget(Node *target) override;
virtual void stop() override;

View File

@ -39,16 +39,16 @@ NS_CC_BEGIN
//
typedef struct _hashElement
{
struct _ccArray *actions;
Node *target;
int actionIndex;
Action *currentAction;
bool currentActionSalvaged;
bool paused;
UT_hash_handle hh;
struct _ccArray *actions;
Node *target;
int actionIndex;
Action *currentAction;
bool currentActionSalvaged;
bool paused;
UT_hash_handle hh;
} tHashElement;
ActionManager::ActionManager(void)
ActionManager::ActionManager()
: _targets(nullptr),
_currentTarget(nullptr),
_currentTargetSalvaged(false)
@ -56,7 +56,7 @@ ActionManager::ActionManager(void)
}
ActionManager::~ActionManager(void)
ActionManager::~ActionManager()
{
CCLOGINFO("deallocing ActionManager: %p", this);

View File

@ -113,7 +113,7 @@ ProgressFromTo* ProgressFromTo::clone() const
}
ProgressFromTo* ProgressFromTo::reverse(void) const
ProgressFromTo* ProgressFromTo::reverse() const
{
return ProgressFromTo::create(_duration, _to, _from);
}

View File

@ -49,7 +49,7 @@ public:
// Overrides
//
virtual ProgressTo* clone() const override;
virtual ProgressTo* reverse(void) const override;
virtual ProgressTo* reverse() const override;
virtual void startWithTarget(Node *target) override;
virtual void update(float time) override;
@ -82,7 +82,7 @@ public:
// Overrides
//
virtual ProgressFromTo* clone() const override;
virtual ProgressFromTo* reverse(void) const override;
virtual ProgressFromTo* reverse() const override;
virtual void startWithTarget(Node *target) override;
virtual void update(float time) override;

View File

@ -247,7 +247,7 @@ ShuffleTiles* ShuffleTiles::clone() const
return a;
}
ShuffleTiles::~ShuffleTiles(void)
ShuffleTiles::~ShuffleTiles()
{
CC_SAFE_DELETE_ARRAY(_tilesOrder);
CC_SAFE_DELETE_ARRAY(_tiles);
@ -255,8 +255,7 @@ ShuffleTiles::~ShuffleTiles(void)
void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
{
int i;
for( i = len - 1; i >= 0; i-- )
for (int i = len - 1; i >= 0; i-- )
{
unsigned int j = rand() % (i+1);
unsigned int v = array[i];
@ -308,14 +307,12 @@ void ShuffleTiles::startWithTarget(Node *target)
_tilesCount = _gridSize.width * _gridSize.height;
_tilesOrder = new unsigned int[_tilesCount];
int i, j;
unsigned int k;
/**
* Use k to loop. Because _tilesCount is unsigned int,
* and i is used later for int.
*/
for (k = 0; k < _tilesCount; ++k)
for (unsigned int k = 0; k < _tilesCount; ++k)
{
_tilesOrder[k] = k;
}
@ -325,9 +322,9 @@ void ShuffleTiles::startWithTarget(Node *target)
_tiles = (struct Tile *)new Tile[_tilesCount];
Tile *tileArray = (Tile*) _tiles;
for (i = 0; i < _gridSize.width; ++i)
for (int i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
for ( int j = 0; j < _gridSize.height; ++j)
{
tileArray->position = Vec2((float)i, (float)j);
tileArray->startPosition = Vec2((float)i, (float)j);
@ -339,13 +336,11 @@ void ShuffleTiles::startWithTarget(Node *target)
void ShuffleTiles::update(float time)
{
int i, j;
Tile *tileArray = (Tile*)_tiles;
for (i = 0; i < _gridSize.width; ++i)
for (int i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
for (int j = 0; j < _gridSize.height; ++j)
{
tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
placeTile(Vec2(i, j), tileArray);
@ -429,11 +424,9 @@ void FadeOutTRTiles::transformTile(const Vec2& pos, float distance)
void FadeOutTRTiles::update(float time)
{
int i, j;
for (i = 0; i < _gridSize.width; ++i)
for (int i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
for (int j = 0; j < _gridSize.height; ++j)
{
float distance = testFunc(Size(i, j), time);
if ( distance == 0 )
@ -652,8 +645,7 @@ TurnOffTiles::~TurnOffTiles(void)
void TurnOffTiles::shuffle(unsigned int *array, unsigned int len)
{
int i;
for (i = len - 1; i >= 0; i--)
for (int i = len - 1; i >= 0; i--)
{
unsigned int j = rand() % (i+1);
unsigned int v = array[i];
@ -677,8 +669,6 @@ void TurnOffTiles::turnOffTile(const Vec2& pos)
void TurnOffTiles::startWithTarget(Node *target)
{
unsigned int i;
TiledGrid3DAction::startWithTarget(target);
if (_seed != (unsigned int)-1)
@ -689,7 +679,7 @@ void TurnOffTiles::startWithTarget(Node *target)
_tilesCount = _gridSize.width * _gridSize.height;
_tilesOrder = new unsigned int[_tilesCount];
for (i = 0; i < _tilesCount; ++i)
for (unsigned int i = 0; i < _tilesCount; ++i)
{
_tilesOrder[i] = i;
}
@ -699,11 +689,10 @@ void TurnOffTiles::startWithTarget(Node *target)
void TurnOffTiles::update(float time)
{
unsigned int i, l, t;
unsigned int l = (unsigned int)(time * (float)_tilesCount);
l = (unsigned int)(time * (float)_tilesCount);
for( i = 0; i < _tilesCount; i++ )
unsigned int t = 0;
for (unsigned int i = 0; i < _tilesCount; i++ )
{
t = _tilesOrder[i];
Vec2 tilePos = Vec2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
@ -765,11 +754,9 @@ WavesTiles3D* WavesTiles3D::clone() const
void WavesTiles3D::update(float time)
{
int i, j;
for( i = 0; i < _gridSize.width; i++ )
for (int i = 0; i < _gridSize.width; i++ )
{
for( j = 0; j < _gridSize.height; j++ )
for (int j = 0; j < _gridSize.height; j++ )
{
Quad3 coords = getOriginalTile(Vec2(i, j));
@ -830,14 +817,12 @@ JumpTiles3D* JumpTiles3D::clone() const
void JumpTiles3D::update(float time)
{
int i, j;
float sinz = (sinf((float)M_PI * time * _jumps * 2) * _amplitude * _amplitudeRate );
float sinz2 = (sinf((float)M_PI * (time * _jumps * 2 + 1)) * _amplitude * _amplitudeRate );
for( i = 0; i < _gridSize.width; i++ )
for (int i = 0; i < _gridSize.width; i++ )
{
for( j = 0; j < _gridSize.height; j++ )
for (int j = 0; j < _gridSize.height; j++ )
{
Quad3 coords = getOriginalTile(Vec2(i, j));
@ -906,9 +891,7 @@ void SplitRows::startWithTarget(Node *target)
void SplitRows::update(float time)
{
unsigned int j;
for (j = 0; j < _gridSize.height; ++j)
for (unsigned int j = 0; j < _gridSize.height; ++j)
{
Quad3 coords = getOriginalTile(Vec2(0, j));
float direction = 1;
@ -971,9 +954,7 @@ void SplitCols::startWithTarget(Node *target)
void SplitCols::update(float time)
{
unsigned int i;
for (i = 0; i < _gridSize.width; ++i)
for (unsigned int i = 0; i < _gridSize.width; ++i)
{
Quad3 coords = getOriginalTile(Vec2(i, 0));
float direction = 1;

View File

@ -259,11 +259,11 @@ public:
static WavesTiles3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
/** waves amplitude */
inline float getAmplitude(void) const { return _amplitude; }
inline float getAmplitude() const { return _amplitude; }
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/** waves amplitude rate */
inline float getAmplitudeRate(void) const { return _amplitudeRate; }
inline float getAmplitudeRate() const { return _amplitudeRate; }
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Override
@ -296,11 +296,11 @@ public:
static JumpTiles3D* create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude);
/** amplitude of the sin*/
inline float getAmplitude(void) const { return _amplitude; }
inline float getAmplitude() const { return _amplitude; }
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
/** amplitude rate */
inline float getAmplitudeRate(void) const { return _amplitudeRate; }
inline float getAmplitudeRate() const { return _amplitudeRate; }
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
// Override

View File

@ -28,10 +28,10 @@ THE SOFTWARE.
NS_CC_BEGIN
ActionTween* ActionTween::create(float aDuration, const std::string& key, float from, float to)
ActionTween* ActionTween::create(float duration, const std::string& key, float from, float to)
{
ActionTween* ret = new ActionTween();
if (ret && ret->initWithDuration(aDuration, key, from, to))
if (ret && ret->initWithDuration(duration, key, from, to))
{
ret->autorelease();
}

View File

@ -83,7 +83,7 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithDuration(float duration, const std::string& key, float from, float to);
protected:
std::string _key;
std::string _key;
float _from, _to;
float _delta;
};

View File

@ -92,7 +92,7 @@ static void setGLBufferData(void *buf, GLuint bufSize)
#endif // EMSCRIPTEN
static void lazy_init( void )
static void lazy_init()
{
if( ! s_initialized ) {
@ -123,7 +123,7 @@ void free()
s_initialized = false;
}
void drawPoint( const Vec2& point )
void drawPoint(const Vec2& point)
{
lazy_init();
@ -198,7 +198,7 @@ void drawPoints( const Vec2 *points, unsigned int numberOfPoints )
}
void drawLine( const Vec2& origin, const Vec2& destination )
void drawLine(const Vec2& origin, const Vec2& destination)
{
lazy_init();
@ -231,7 +231,7 @@ void drawRect( Vec2 origin, Vec2 destination )
drawLine(Vec2(origin.x, destination.y), Vec2(origin.x, origin.y));
}
void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color )
void drawSolidRect(Vec2 origin, Vec2 destination, Color4F color)
{
Vec2 vertices[] = {
origin,
@ -243,7 +243,7 @@ void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color )
drawSolidPoly(vertices, 4, color );
}
void drawPoly( const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon )
void drawPoly(const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon)
{
lazy_init();
@ -295,7 +295,7 @@ void drawPoly( const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
}
void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color )
void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, Color4F color)
{
lazy_init();
@ -309,7 +309,7 @@ void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color
Vec2* newPoli = new Vec2[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(Vec2) == sizeof(Vec2) )
if (sizeof(Vec2) == sizeof(Vec2))
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
@ -321,7 +321,7 @@ void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color
else
{
// Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++)
for(unsigned int i = 0; i < numberOfPoints; i++)
{
newPoli[i] = Vec2( poli[i].x, poli[i].y );
}
@ -532,7 +532,7 @@ void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& contr
Vec2* vertices = new Vec2[segments + 1];
float t = 0;
for(unsigned int i = 0; i < segments; i++)
for (unsigned int i = 0; i < segments; i++)
{
vertices[i].x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x;
vertices[i].y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y;

View File

@ -85,40 +85,40 @@ namespace DrawPrimitives
void free();
/** draws a point given x and y coordinate measured in points */
void drawPoint( const Vec2& point );
void drawPoint(const Vec2& point);
/** draws an array of points.
@since v0.7.2
*/
void drawPoints( const Vec2 *points, unsigned int numberOfPoints );
void drawPoints(const Vec2 *points, unsigned int numberOfPoints);
/** draws a line given the origin and destination point measured in points */
void drawLine( const Vec2& origin, const Vec2& destination );
void drawLine(const Vec2& origin, const Vec2& destination);
/** draws a rectangle given the origin and destination point measured in points. */
void drawRect( Vec2 origin, Vec2 destination );
void drawRect(Vec2 origin, Vec2 destination);
/** draws a solid rectangle given the origin and destination point measured in points.
@since 1.1
*/
void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color );
void drawSolidRect(Vec2 origin, Vec2 destination, Color4F color);
/** draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
The polygon can be closed or open
*/
void drawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon );
void drawPoly(const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon);
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
*/
void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color );
void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, Color4F color);
/** draws a circle given the center, radius and number of segments. */
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
void drawCircle(const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
void drawCircle(const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
/** draws a solid circle given the center, radius and number of segments. */
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments);
void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments);
/** draws a quad bezier path
@warning This function could be pretty slow. Use it only for debugging purposes.
@ -136,28 +136,28 @@ namespace DrawPrimitives
@warning This function could be pretty slow. Use it only for debugging purposes.
@since v2.0
*/
void drawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments );
void drawCatmullRom(PointArray *arrayOfControlPoints, unsigned int segments);
/** draws a Cardinal Spline path.
@warning This function could be pretty slow. Use it only for debugging purposes.
@since v2.0
*/
void drawCardinalSpline( PointArray *config, float tension, unsigned int segments );
void drawCardinalSpline(PointArray *config, float tension, unsigned int segments);
/** set the drawing color with 4 unsigned bytes
@since v2.0
*/
void setDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a );
void setDrawColor4B(GLubyte r, GLubyte g, GLubyte b, GLubyte a);
/** set the drawing color with 4 floats
@since v2.0
*/
void setDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a );
void setDrawColor4F(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
/** set the point size in points. Default 1.
@since v2.0
*/
void setPointSize( GLfloat pointSize );
void setPointSize(GLfloat pointSize);
};

View File

@ -510,11 +510,11 @@ bool Node::isVisible() const
}
/// isVisible setter
void Node::setVisible(bool var)
void Node::setVisible(bool visible)
{
if(var != _visible)
if(visible != _visible)
{
_visible = var;
_visible = visible;
if(_visible) _transformUpdated = _transformDirty = _inverseDirty = true;
}
}
@ -572,9 +572,9 @@ bool Node::isRunning() const
}
/// parent setter
void Node::setParent(Node * var)
void Node::setParent(Node * parent)
{
_parent = var;
_parent = parent;
}
/// isRelativeAnchorPoint getter
@ -599,15 +599,15 @@ int Node::getTag() const
}
/// tag setter
void Node::setTag(int var)
void Node::setTag(int tag)
{
_tag = var;
_tag = tag ;
}
/// userData setter
void Node::setUserData(void *var)
void Node::setUserData(void *userData)
{
_userData = var;
_userData = userData;
}
int Node::getOrderOfArrival() const
@ -621,14 +621,14 @@ void Node::setOrderOfArrival(int orderOfArrival)
_orderOfArrival = orderOfArrival;
}
void Node::setUserObject(Ref *pUserObject)
void Node::setUserObject(Ref *userObject)
{
CC_SAFE_RETAIN(pUserObject);
CC_SAFE_RETAIN(userObject);
CC_SAFE_RELEASE(_userObject);
_userObject = pUserObject;
_userObject = userObject;
}
GLProgramState* Node::getGLProgramState()
GLProgramState* Node::getGLProgramState() const
{
return _glProgramState;
}
@ -652,7 +652,7 @@ void Node::setGLProgram(GLProgram *glProgram)
}
}
GLProgram * Node::getGLProgram()
GLProgram * Node::getGLProgram() const
{
return _glProgramState ? _glProgramState->getGLProgram() : nullptr;
}
@ -671,7 +671,7 @@ Rect Node::getBoundingBox() const
return RectApplyAffineTransform(rect, getNodeToParentAffineTransform());
}
Node * Node::create(void)
Node * Node::create()
{
Node * ret = new Node();
if (ret && ret->init())
@ -713,7 +713,7 @@ std::string Node::getDescription() const
}
// lazy allocs
void Node::childrenAlloc(void)
void Node::childrenAlloc()
{
_children.reserve(4);
}
@ -1572,25 +1572,25 @@ void Node::updateTransform()
child->updateTransform();
}
Component* Node::getComponent(const std::string& pName)
Component* Node::getComponent(const std::string& name)
{
if( _componentContainer )
return _componentContainer->get(pName);
return _componentContainer->get(name);
return nullptr;
}
bool Node::addComponent(Component *pComponent)
bool Node::addComponent(Component *component)
{
// lazy alloc
if( !_componentContainer )
_componentContainer = new ComponentContainer(this);
return _componentContainer->add(pComponent);
return _componentContainer->add(component);
}
bool Node::removeComponent(const std::string& pName)
bool Node::removeComponent(const std::string& name)
{
if( _componentContainer )
return _componentContainer->remove(pName);
return _componentContainer->remove(name);
return false;
}
@ -1699,7 +1699,7 @@ GLubyte Node::getOpacity(void) const
return _realOpacity;
}
GLubyte Node::getDisplayedOpacity(void) const
GLubyte Node::getDisplayedOpacity() const
{
return _displayedOpacity;
}

View File

@ -114,7 +114,7 @@ public:
* Allocates and initializes a node.
* @return A initialized node which is marked as "autorelease".
*/
static Node * create(void);
static Node * create();
/**
* Gets the description string. It makes debugging easier.
@ -826,10 +826,10 @@ public:
*
* @return The GLProgram (shader) currently used for this node
*/
GLProgram* getGLProgram();
CC_DEPRECATED_ATTRIBUTE GLProgram* getShaderProgram() { return getGLProgram(); }
GLProgram* getGLProgram() const;
CC_DEPRECATED_ATTRIBUTE GLProgram* getShaderProgram() const { return getGLProgram(); }
GLProgramState *getGLProgramState();
GLProgramState *getGLProgramState() const;
void setGLProgramState(GLProgramState *glProgramState);
/**
@ -1164,12 +1164,12 @@ public:
* Resumes all scheduled selectors, actions and event listeners.
* This method is called internally by onEnter
*/
CC_DEPRECATED_ATTRIBUTE void resumeSchedulerAndActions(void);
CC_DEPRECATED_ATTRIBUTE void resumeSchedulerAndActions();
/**
* Pauses all scheduled selectors, actions and event listeners..
* This method is called internally by onExit
*/
CC_DEPRECATED_ATTRIBUTE void pauseSchedulerAndActions(void);
CC_DEPRECATED_ATTRIBUTE void pauseSchedulerAndActions();
/*
* Update method will be called automatically every frame if "scheduleUpdate" is called, and the node is "live"
@ -1290,17 +1290,17 @@ public:
/**
* gets a component by its name
*/
Component* getComponent(const std::string& pName);
Component* getComponent(const std::string& name);
/**
* adds a component
*/
virtual bool addComponent(Component *pComponent);
virtual bool addComponent(Component *component);
/**
* removes a component by its name
*/
virtual bool removeComponent(const std::string& pName);
virtual bool removeComponent(const std::string& name);
/**
* removes all components
@ -1331,14 +1331,14 @@ public:
virtual bool isCascadeOpacityEnabled() const;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
virtual const Color3B& getColor(void) const;
virtual const Color3B& getColor() const;
virtual const Color3B& getDisplayedColor() const;
virtual void setColor(const Color3B& color);
virtual void updateDisplayedColor(const Color3B& parentColor);
virtual bool isCascadeColorEnabled() const;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
virtual bool isOpacityModifyRGB() const { return false; };
CC_CONSTRUCTOR_ACCESS:

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#define __ANDROID_IME_JNI_H__
extern "C" {
extern void setKeyboardStateJNI(int bOpen);
extern void setKeyboardStateJNI(int open);
extern void openKeyboardJNI();
extern void closeKeyboardJNI();
}

View File

@ -45,17 +45,17 @@ int getFontSizeAccordingHeightJni(int height) {
return ret;
}
std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) {
std::string getStringWithEllipsisJni(const char* text, float width, float fontSize) {
std::string ret;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getStringWithEllipsis", "(Ljava/lang/String;FF)Ljava/lang/String;")) {
jstring stringArg1;
if (!pszText) {
if (!text) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszText);
stringArg1 = t.env->NewStringUTF(text);
}
jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize);

View File

@ -28,6 +28,6 @@ THE SOFTWARE.
#include <string>
int getFontSizeAccordingHeightJni(int height);
std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize);
std::string getStringWithEllipsisJni(const char* text, float width, float fontSize);
#endif // __EDITBOX_JNI_H__

View File

@ -37,8 +37,8 @@ THE SOFTWARE.
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper"
EditTextCallback s_pfEditTextCallback = NULL;
void* s_ctx = NULL;
static EditTextCallback s_editTextCallback = nullptr;
static void* s_ctx = nullptr;
using namespace cocos2d;
using namespace std;
@ -61,17 +61,17 @@ extern "C" {
if (size > 0) {
jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0);
char* pBuf = (char*)malloc(size+1);
if (pBuf != NULL) {
memcpy(pBuf, data, size);
pBuf[size] = '\0';
char* buffer = (char*)malloc(size+1);
if (buffer != nullptr) {
memcpy(buffer, data, size);
buffer[size] = '\0';
// pass data to edittext's delegate
if (s_pfEditTextCallback) s_pfEditTextCallback(pBuf, s_ctx);
free(pBuf);
if (s_editTextCallback) s_editTextCallback(buffer, s_ctx);
free(buffer);
}
env->ReleaseByteArrayElements(text, data, 0);
} else {
if (s_pfEditTextCallback) s_pfEditTextCallback("", s_ctx);
if (s_editTextCallback) s_editTextCallback("", s_ctx);
}
}
}
@ -80,8 +80,8 @@ const char * getApkPath() {
return g_apkPath.c_str();
}
void showDialogJNI(const char * pszMsg, const char * pszTitle) {
if (!pszMsg) {
void showDialogJNI(const char * message, const char * title) {
if (!message) {
return;
}
@ -89,13 +89,13 @@ void showDialogJNI(const char * pszMsg, const char * pszTitle) {
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showDialog", "(Ljava/lang/String;Ljava/lang/String;)V")) {
jstring stringArg1;
if (!pszTitle) {
if (!title) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
stringArg1 = t.env->NewStringUTF(title);
}
jstring stringArg2 = t.env->NewStringUTF(pszMsg);
jstring stringArg2 = t.env->NewStringUTF(message);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);
t.env->DeleteLocalRef(stringArg1);
@ -104,27 +104,27 @@ void showDialogJNI(const char * pszMsg, const char * pszTitle) {
}
}
void showEditTextDialogJNI(const char* pszTitle, const char* pszMessage, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx) {
if (pszMessage == NULL) {
void showEditTextDialogJNI(const char* title, const char* message, int inputMode, int inputFlag, int returnType, int maxLength, EditTextCallback callback, void* ctx) {
if (message == nullptr) {
return;
}
s_pfEditTextCallback = pfEditTextCallback;
s_editTextCallback = callback;
s_ctx = ctx;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showEditTextDialog", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) {
jstring stringArg1;
if (!pszTitle) {
if (!title) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
stringArg1 = t.env->NewStringUTF(title);
}
jstring stringArg2 = t.env->NewStringUTF(pszMessage);
jstring stringArg2 = t.env->NewStringUTF(message);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2,inputMode, inputFlag, returnType, maxLength);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
@ -210,12 +210,12 @@ void disableAccelerometerJni() {
}
// functions for UserDefault
bool getBoolForKeyJNI(const char* pKey, bool defaultValue)
bool getBoolForKeyJNI(const char* key, bool defaultValue)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getBoolForKey", "(Ljava/lang/String;Z)Z")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, stringArg, defaultValue);
t.env->DeleteLocalRef(t.classID);
@ -227,12 +227,12 @@ bool getBoolForKeyJNI(const char* pKey, bool defaultValue)
return defaultValue;
}
int getIntegerForKeyJNI(const char* pKey, int defaultValue)
int getIntegerForKeyJNI(const char* key, int defaultValue)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getIntegerForKey", "(Ljava/lang/String;I)I")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
jint ret = t.env->CallStaticIntMethod(t.classID, t.methodID, stringArg, defaultValue);
t.env->DeleteLocalRef(t.classID);
@ -244,12 +244,12 @@ int getIntegerForKeyJNI(const char* pKey, int defaultValue)
return defaultValue;
}
float getFloatForKeyJNI(const char* pKey, float defaultValue)
float getFloatForKeyJNI(const char* key, float defaultValue)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getFloatForKey", "(Ljava/lang/String;F)F")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
jfloat ret = t.env->CallStaticFloatMethod(t.classID, t.methodID, stringArg, defaultValue);
t.env->DeleteLocalRef(t.classID);
@ -261,12 +261,12 @@ float getFloatForKeyJNI(const char* pKey, float defaultValue)
return defaultValue;
}
double getDoubleForKeyJNI(const char* pKey, double defaultValue)
double getDoubleForKeyJNI(const char* key, double defaultValue)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getDoubleForKey", "(Ljava/lang/String;D)D")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
jdouble ret = t.env->CallStaticDoubleMethod(t.classID, t.methodID, stringArg, defaultValue);
t.env->DeleteLocalRef(t.classID);
@ -278,13 +278,13 @@ double getDoubleForKeyJNI(const char* pKey, double defaultValue)
return defaultValue;
}
std::string getStringForKeyJNI(const char* pKey, const char* defaultValue)
std::string getStringForKeyJNI(const char* key, const char* defaultValue)
{
JniMethodInfo t;
std::string ret("");
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getStringForKey", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;")) {
jstring stringArg1 = t.env->NewStringUTF(pKey);
jstring stringArg1 = t.env->NewStringUTF(key);
jstring stringArg2 = t.env->NewStringUTF(defaultValue);
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, stringArg2);
ret = JniHelper::jstring2string(str);
@ -300,12 +300,12 @@ std::string getStringForKeyJNI(const char* pKey, const char* defaultValue)
return defaultValue;
}
void setBoolForKeyJNI(const char* pKey, bool value)
void setBoolForKeyJNI(const char* key, bool value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setBoolForKey", "(Ljava/lang/String;Z)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
@ -313,12 +313,12 @@ void setBoolForKeyJNI(const char* pKey, bool value)
}
}
void setIntegerForKeyJNI(const char* pKey, int value)
void setIntegerForKeyJNI(const char* key, int value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setIntegerForKey", "(Ljava/lang/String;I)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
@ -326,12 +326,12 @@ void setIntegerForKeyJNI(const char* pKey, int value)
}
}
void setFloatForKeyJNI(const char* pKey, float value)
void setFloatForKeyJNI(const char* key, float value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setFloatForKey", "(Ljava/lang/String;F)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
@ -339,12 +339,12 @@ void setFloatForKeyJNI(const char* pKey, float value)
}
}
void setDoubleForKeyJNI(const char* pKey, double value)
void setDoubleForKeyJNI(const char* key, double value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setDoubleForKey", "(Ljava/lang/String;D)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring stringArg = t.env->NewStringUTF(key);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
@ -352,12 +352,12 @@ void setDoubleForKeyJNI(const char* pKey, double value)
}
}
void setStringForKeyJNI(const char* pKey, const char* value)
void setStringForKeyJNI(const char* key, const char* value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setStringForKey", "(Ljava/lang/String;Ljava/lang/String;)V")) {
jstring stringArg1 = t.env->NewStringUTF(pKey);
jstring stringArg1 = t.env->NewStringUTF(key);
jstring stringArg2 = t.env->NewStringUTF(value);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);

View File

@ -27,11 +27,11 @@ THE SOFTWARE.
#include <string>
typedef void (*EditTextCallback)(const char* pText, void* ctx);
typedef void (*EditTextCallback)(const char* text, void* ctx);
extern const char * getApkPath();
extern void showDialogJNI(const char * pszMsg, const char * pszTitle);
extern void showEditTextDialogJNI(const char* pszTitle, const char* pszContent, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx);
extern void showDialogJNI(const char * message, const char * title);
extern void showEditTextDialogJNI(const char* title, const char* content, int inputMode, int inputFlag, int returnType, int maxLength, EditTextCallback callback, void* ctx);
extern void terminateProcessJNI();
extern std::string getCurrentLanguageJNI();
extern std::string getPackageNameJNI();
@ -40,15 +40,15 @@ extern void enableAccelerometerJni();
extern void disableAccelerometerJni();
extern void setAccelerometerIntervalJni(float interval);
// functions for UserDefault
extern bool getBoolForKeyJNI(const char* pKey, bool defaultValue);
extern int getIntegerForKeyJNI(const char* pKey, int defaultValue);
extern float getFloatForKeyJNI(const char* pKey, float defaultValue);
extern double getDoubleForKeyJNI(const char* pKey, double defaultValue);
extern std::string getStringForKeyJNI(const char* pKey, const char* defaultValue);
extern void setBoolForKeyJNI(const char* pKey, bool value);
extern void setIntegerForKeyJNI(const char* pKey, int value);
extern void setFloatForKeyJNI(const char* pKey, float value);
extern void setDoubleForKeyJNI(const char* pKey, double value);
extern void setStringForKeyJNI(const char* pKey, const char* value);
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
extern int getIntegerForKeyJNI(const char* key, int defaultValue);
extern float getFloatForKeyJNI(const char* key, float defaultValue);
extern double getDoubleForKeyJNI(const char* key, double defaultValue);
extern std::string getStringForKeyJNI(const char* key, const char* defaultValue);
extern void setBoolForKeyJNI(const char* key, bool value);
extern void setIntegerForKeyJNI(const char* key, int value);
extern void setFloatForKeyJNI(const char* key, float value);
extern void setDoubleForKeyJNI(const char* key, double value);
extern void setStringForKeyJNI(const char* key, const char* value);
#endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */

View File

@ -34,8 +34,8 @@ THE SOFTWARE.
static pthread_key_t g_key;
jclass _getClassID(const char *className) {
if (NULL == className) {
return NULL;
if (nullptr == className) {
return nullptr;
}
JNIEnv* env = cocos2d::JniHelper::getEnv();
@ -46,7 +46,7 @@ jclass _getClassID(const char *className) {
cocos2d::JniHelper::loadclassMethod_methodID,
_jstrClassName);
if (NULL == _clazz) {
if (nullptr == _clazz) {
LOGE("Classloader failed to find class of %s", className);
env->ExceptionClear();
}
@ -58,9 +58,9 @@ jclass _getClassID(const char *className) {
namespace cocos2d {
JavaVM* JniHelper::_psJavaVM = NULL;
jmethodID JniHelper::loadclassMethod_methodID = NULL;
jobject JniHelper::classloader = NULL;
JavaVM* JniHelper::_psJavaVM = nullptr;
jmethodID JniHelper::loadclassMethod_methodID = nullptr;
jobject JniHelper::classloader = nullptr;
JavaVM* JniHelper::getJavaVM() {
pthread_t thisthread = pthread_self();
@ -73,11 +73,11 @@ namespace cocos2d {
LOGD("JniHelper::setJavaVM(%p), pthread_self() = %ld", javaVM, thisthread);
_psJavaVM = javaVM;
pthread_key_create(&g_key, NULL);
pthread_key_create(&g_key, nullptr);
}
JNIEnv* JniHelper::cacheEnv(JavaVM* jvm) {
JNIEnv* _env = NULL;
JNIEnv* _env = nullptr;
// get jni environment
jint ret = jvm->GetEnv((void**)&_env, JNI_VERSION_1_4);
@ -94,11 +94,11 @@ namespace cocos2d {
// must call DetachCurrentThread() in future.
// see: http://developer.android.com/guide/practices/design/jni.html
if (jvm->AttachCurrentThread(&_env, NULL) < 0)
if (jvm->AttachCurrentThread(&_env, nullptr) < 0)
{
LOGE("Failed to get the environment using AttachCurrentThread()");
return NULL;
return nullptr;
} else {
// Success : Attached and obtained JNIEnv!
pthread_setspecific(g_key, _env);
@ -110,13 +110,13 @@ namespace cocos2d {
LOGE("JNI interface version 1.4 not supported");
default :
LOGE("Failed to get the environment using GetEnv()");
return NULL;
return nullptr;
}
}
JNIEnv* JniHelper::getEnv() {
JNIEnv *_env = (JNIEnv *)pthread_getspecific(g_key);
if (_env == NULL)
if (_env == nullptr)
_env = JniHelper::cacheEnv(_psJavaVM);
return _env;
}
@ -133,7 +133,7 @@ namespace cocos2d {
jobject _c = cocos2d::JniHelper::getEnv()->CallObjectMethod(activityinstance,
_getclassloaderMethod.methodID);
if (NULL == _c) {
if (nullptr == _c) {
return false;
}
@ -155,14 +155,14 @@ namespace cocos2d {
const char *className,
const char *methodName,
const char *paramCode) {
if ((NULL == className) ||
(NULL == methodName) ||
(NULL == paramCode)) {
if ((nullptr == className) ||
(nullptr == methodName) ||
(nullptr == paramCode)) {
return false;
}
JNIEnv *pEnv = JniHelper::getEnv();
if (!pEnv) {
JNIEnv *env = JniHelper::getEnv();
if (!env) {
LOGE("Failed to get JNIEnv");
return false;
}
@ -170,19 +170,19 @@ namespace cocos2d {
jclass classID = _getClassID(className);
if (! classID) {
LOGE("Failed to find class %s", className);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
jmethodID methodID = pEnv->GetStaticMethodID(classID, methodName, paramCode);
jmethodID methodID = env->GetStaticMethodID(classID, methodName, paramCode);
if (! methodID) {
LOGE("Failed to find static method id of %s", methodName);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
methodinfo.classID = classID;
methodinfo.env = pEnv;
methodinfo.env = env;
methodinfo.methodID = methodID;
return true;
}
@ -191,33 +191,33 @@ namespace cocos2d {
const char *className,
const char *methodName,
const char *paramCode) {
if ((NULL == className) ||
(NULL == methodName) ||
(NULL == paramCode)) {
if ((nullptr == className) ||
(nullptr == methodName) ||
(nullptr == paramCode)) {
return false;
}
JNIEnv *pEnv = JniHelper::getEnv();
if (!pEnv) {
JNIEnv *env = JniHelper::getEnv();
if (!env) {
return false;
}
jclass classID = pEnv->FindClass(className);
jclass classID = env->FindClass(className);
if (! classID) {
LOGE("Failed to find class %s", className);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode);
jmethodID methodID = env->GetMethodID(classID, methodName, paramCode);
if (! methodID) {
LOGE("Failed to find method id of %s", methodName);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
methodinfo.classID = classID;
methodinfo.env = pEnv;
methodinfo.env = env;
methodinfo.methodID = methodID;
return true;
@ -227,51 +227,51 @@ namespace cocos2d {
const char *className,
const char *methodName,
const char *paramCode) {
if ((NULL == className) ||
(NULL == methodName) ||
(NULL == paramCode)) {
if ((nullptr == className) ||
(nullptr == methodName) ||
(nullptr == paramCode)) {
return false;
}
JNIEnv *pEnv = JniHelper::getEnv();
if (!pEnv) {
JNIEnv *env = JniHelper::getEnv();
if (!env) {
return false;
}
jclass classID = _getClassID(className);
if (! classID) {
LOGE("Failed to find class %s", className);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode);
jmethodID methodID = env->GetMethodID(classID, methodName, paramCode);
if (! methodID) {
LOGE("Failed to find method id of %s", methodName);
pEnv->ExceptionClear();
env->ExceptionClear();
return false;
}
methodinfo.classID = classID;
methodinfo.env = pEnv;
methodinfo.env = env;
methodinfo.methodID = methodID;
return true;
}
std::string JniHelper::jstring2string(jstring jstr) {
if (jstr == NULL) {
if (jstr == nullptr) {
return "";
}
JNIEnv *pEnv = JniHelper::getEnv();
if (!pEnv) {
return NULL;
JNIEnv *env = JniHelper::getEnv();
if (!env) {
return nullptr;
}
const char* chars = pEnv->GetStringUTFChars(jstr, NULL);
const char* chars = env->GetStringUTFChars(jstr, nullptr);
std::string ret(chars);
pEnv->ReleaseStringUTFChars(jstr, chars);
env->ReleaseStringUTFChars(jstr, chars);
return ret;
}