Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git
Conflicts: indra/llrender/llpostprocess.cpp
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#include "llquaternion.h"
|
||||
#include "llpolymorph.h"
|
||||
#include "lljoint.h"
|
||||
//#include "lldarray.h"
|
||||
#include "lldarray.h"
|
||||
|
||||
class LLSkinJoint;
|
||||
class LLAvatarAppearance;
|
||||
|
||||
@@ -105,7 +105,8 @@ LLTexParamGlobalColor::LLTexParamGlobalColor(LLTexGlobalColor* tex_global_color)
|
||||
|
||||
void LLTexParamGlobalColor::onGlobalColorChanged(bool upload_bake)
|
||||
{
|
||||
mAvatarAppearance->onGlobalColorChanged(mTexGlobalColor, upload_bake);
|
||||
if (mAvatarAppearance)
|
||||
mAvatarAppearance->onGlobalColorChanged(mTexGlobalColor, upload_bake);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -269,6 +269,9 @@ public:
|
||||
static std::vector< LLCharacter* > sInstances;
|
||||
static BOOL sAllowInstancesChange ; //debug use
|
||||
|
||||
virtual void setHoverOffset(const LLVector3& hover_offset, bool send_update=true) { mHoverOffset = hover_offset; }
|
||||
const LLVector3& getHoverOffset() const { return mHoverOffset; }
|
||||
|
||||
protected:
|
||||
LLMotionController mMotionController;
|
||||
|
||||
@@ -293,6 +296,8 @@ private:
|
||||
visual_param_index_map_t mVisualParamIndexMap;
|
||||
visual_param_name_map_t mVisualParamNameMap;
|
||||
static LLStringTable sVisualParamNames;
|
||||
|
||||
LLVector3 mHoverOffset;
|
||||
};
|
||||
|
||||
#endif // LL_LLCHARACTER_H
|
||||
|
||||
@@ -31,17 +31,16 @@
|
||||
// Header Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "linked_lists.h"
|
||||
#include "v3math.h"
|
||||
#include "v4math.h"
|
||||
#include "m4math.h"
|
||||
#include "llquaternion.h"
|
||||
#include "xform.h"
|
||||
#include "lldarray.h"
|
||||
|
||||
const S32 LL_CHARACTER_MAX_JOINTS_PER_MESH = 15;
|
||||
const U32 LL_CHARACTER_MAX_JOINTS = 32; // must be divisible by 16!
|
||||
const U32 LL_CHARACTER_MAX_JOINTS = 32; // must be divisible by 4!
|
||||
const U32 LL_HAND_JOINT_NUM = 31;
|
||||
const U32 LL_FACE_JOINT_NUM = 30;
|
||||
const S32 LL_CHARACTER_MAX_PRIORITY = 7;
|
||||
@@ -84,6 +83,7 @@ protected:
|
||||
LLXformMatrix mDefaultXform;
|
||||
|
||||
LLUUID mId;
|
||||
|
||||
public:
|
||||
U32 mDirtyFlags;
|
||||
BOOL mUpdateXform;
|
||||
|
||||
@@ -1047,7 +1047,8 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
|
||||
{
|
||||
case CONSTRAINT_TARGET_TYPE_GROUND:
|
||||
target_pos = mCharacter->getPosAgentFromGlobal(constraint->mGroundPos);
|
||||
// llinfos << "Target Pos " << constraint->mGroundPos << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl;
|
||||
target_pos += mCharacter->getHoverOffset();
|
||||
// LL_INFOS() << "Target Pos " << constraint->mGroundPos << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << LL_ENDL;
|
||||
break;
|
||||
case CONSTRAINT_TARGET_TYPE_BODY:
|
||||
target_pos = mCharacter->getVolumePos(shared_data->mTargetConstraintVolume, shared_data->mTargetConstraintOffset);
|
||||
@@ -1111,7 +1112,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
|
||||
|
||||
LLVector3 source_to_target = target_pos - keyframe_source_pos;
|
||||
|
||||
S32 max_iteration_count = llmath::llround(clamp_rescale(
|
||||
S32 max_iteration_count = ll_round(clamp_rescale(
|
||||
mCharacter->getPixelArea(),
|
||||
MAX_PIXEL_AREA_CONSTRAINTS,
|
||||
MIN_PIXEL_AREA_CONSTRAINTS,
|
||||
|
||||
@@ -876,12 +876,12 @@ void LLMotionController::updateMotions(bool force_update)
|
||||
|
||||
//<singu>
|
||||
// This old code is nonsense.
|
||||
//S32 quantum_count = llmax(0, llmath::llround((update_time - time_interval) / mTimeStep)) + 1;
|
||||
// (update_time - time_interval) / mTimeStep is an integer! We need llround to get rid of floating point errors, not llfloor.
|
||||
// Moreover, just rounding off to the nearest integer with llmath::llround(update_time / mTimeStep) makes a lot more sense:
|
||||
//S32 quantum_count = llmax(0, ll_round((update_time - time_interval) / mTimeStep)) + 1;
|
||||
// (update_time - time_interval) / mTimeStep is an integer! We need ll_round to get rid of floating point errors, not llfloor.
|
||||
// Moreover, just rounding off to the nearest integer with ll_round(update_time / mTimeStep) makes a lot more sense:
|
||||
// it is the best we can do to get as close to what we should draw as possible.
|
||||
// However, mAnimTime may only be incremented; therefore make sure of that with the llmax.
|
||||
S32 quantum_count = llmax(llmath::llround(update_time / mTimeStep), llceil(mAnimTime / mTimeStep));
|
||||
S32 quantum_count = llmax(ll_round(update_time / mTimeStep), llceil(mAnimTime / mTimeStep));
|
||||
//</singu>
|
||||
if (quantum_count == mTimeStepCount)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ LLMultiGesture::LLMultiGesture()
|
||||
mReplaceText(),
|
||||
mSteps(),
|
||||
mPlaying(FALSE),
|
||||
mLocal(false),
|
||||
mCurrentStep(0),
|
||||
mDoneCallback(NULL)
|
||||
{
|
||||
@@ -63,6 +64,7 @@ LLMultiGesture::~LLMultiGesture()
|
||||
void LLMultiGesture::reset()
|
||||
{
|
||||
mPlaying = FALSE;
|
||||
mLocal = false;
|
||||
mCurrentStep = 0;
|
||||
mWaitTimer.reset();
|
||||
mWaitingTimer = FALSE;
|
||||
|
||||
@@ -79,6 +79,9 @@ public:
|
||||
// Is the gesture currently playing?
|
||||
BOOL mPlaying;
|
||||
|
||||
// Is the gesture to be played locally?
|
||||
bool mLocal;
|
||||
|
||||
// "instruction pointer" for steps
|
||||
S32 mCurrentStep;
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ set(llcommon_SOURCE_FILES
|
||||
llmetrics.cpp
|
||||
llmortician.cpp
|
||||
lloptioninterface.cpp
|
||||
llpredicate.cpp
|
||||
llprocesslauncher.cpp
|
||||
llprocessor.cpp
|
||||
llptrto.cpp
|
||||
@@ -177,7 +178,6 @@ set(llcommon_HEADER_FILES
|
||||
llformat.h
|
||||
llframetimer.h
|
||||
llhandle.h
|
||||
llhash.h
|
||||
llheartbeat.h
|
||||
llhttpstatuscodes.h
|
||||
llindexedqueue.h
|
||||
@@ -199,6 +199,7 @@ set(llcommon_HEADER_FILES
|
||||
llnametable.h
|
||||
lloptioninterface.h
|
||||
llpointer.h
|
||||
llpredicate.h
|
||||
llpreprocessor.h
|
||||
llpriqueuemap.h
|
||||
llprocesslauncher.h
|
||||
@@ -241,7 +242,6 @@ set(llcommon_HEADER_FILES
|
||||
lltypeinfolookup.h
|
||||
lluri.h
|
||||
lluuid.h
|
||||
sguuidhash.h
|
||||
llversionviewer.h.in
|
||||
llworkerthread.h
|
||||
metaclass.h
|
||||
|
||||
@@ -140,10 +140,6 @@ const U32 DEFAULT_CGI_SERVICES_PORT = 12045;
|
||||
// on a single host for map tile generation. JC
|
||||
const U32 DEFAULT_MAPSERVER_PORT = 12124;
|
||||
|
||||
// For automatic port discovery when running multiple viewers on one host
|
||||
const U32 PORT_DISCOVERY_RANGE_MIN = 13000;
|
||||
const U32 PORT_DISCOVERY_RANGE_MAX = PORT_DISCOVERY_RANGE_MIN + 50;
|
||||
|
||||
const char LAND_LAYER_CODE = 'L';
|
||||
const char WATER_LAYER_CODE = 'W';
|
||||
const char WIND_LAYER_CODE = '7';
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "boost/atomic.hpp"
|
||||
template<typename T>
|
||||
struct impl_atomic_type { typedef boost::atomic<T> type; };
|
||||
#elif defined(USE_STD_ATOMIC) && (__cplusplus >= 201103L || _MSC_VER >= 1800)
|
||||
#elif defined(USE_STD_ATOMIC) && defined(LL_CPP11)
|
||||
#include <atomic>
|
||||
template<typename T>
|
||||
struct impl_atomic_type { typedef std::atomic<T> type; };
|
||||
|
||||
@@ -3,31 +3,25 @@
|
||||
* @brief base32 encoding that returns a std::string
|
||||
* @author James Cook
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -3,31 +3,25 @@
|
||||
* @brief Wrapper for apr base64 encoding that returns a std::string
|
||||
* @author James Cook
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -36,32 +30,72 @@
|
||||
#include "llbase64.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "apr_base64.h"
|
||||
|
||||
|
||||
// static
|
||||
std::string LLBase64::encode(const U8* input, size_t input_size)
|
||||
{
|
||||
std::string output;
|
||||
if (input
|
||||
&& input_size > 0)
|
||||
{
|
||||
// Yes, it returns int.
|
||||
int b64_buffer_length = apr_base64_encode_len(input_size);
|
||||
char* b64_buffer = new char[b64_buffer_length];
|
||||
|
||||
// This is faster than apr_base64_encode() if you know
|
||||
// you're not on an EBCDIC machine. Also, the output is
|
||||
// null terminated, even though the documentation doesn't
|
||||
// specify. See apr_base64.c for details. JC
|
||||
b64_buffer_length = apr_base64_encode_binary(
|
||||
b64_buffer,
|
||||
input,
|
||||
input_size);
|
||||
output.assign(b64_buffer);
|
||||
delete[] b64_buffer;
|
||||
}
|
||||
return output;
|
||||
if (!(input && input_size > 0)) return LLStringUtil::null;
|
||||
|
||||
// Yes, it returns int.
|
||||
int b64_buffer_length = apr_base64_encode_len(input_size);
|
||||
char* b64_buffer = new char[b64_buffer_length];
|
||||
|
||||
// This is faster than apr_base64_encode() if you know
|
||||
// you're not on an EBCDIC machine. Also, the output is
|
||||
// null terminated, even though the documentation doesn't
|
||||
// specify. See apr_base64.c for details. JC
|
||||
b64_buffer_length = apr_base64_encode_binary(
|
||||
b64_buffer,
|
||||
input,
|
||||
input_size);
|
||||
std::string result;
|
||||
result.assign(b64_buffer);
|
||||
delete[] b64_buffer;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
std::string LLBase64::encode(const std::string& in_str)
|
||||
{
|
||||
size_t data_size = in_str.size();
|
||||
std::vector<U8> data;
|
||||
data.resize(data_size);
|
||||
memcpy(&data[0], in_str.c_str(), data_size);
|
||||
return encode(&data[0], data_size);
|
||||
}
|
||||
|
||||
// static
|
||||
size_t LLBase64::decode(const std::string& input, U8 * buffer, size_t buffer_size)
|
||||
{
|
||||
if (input.empty()) return 0;
|
||||
|
||||
size_t bytes_written = apr_base64_decode_binary(buffer, input.data());
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
std::string LLBase64::decode(const std::string& input)
|
||||
{
|
||||
U32 buffer_len = LLBase64::requiredDecryptionSpace(input);
|
||||
std::vector<U8> buffer(buffer_len);
|
||||
buffer_len = LLBase64::decode(input, &buffer[0], buffer_len);
|
||||
buffer.resize(buffer_len);
|
||||
return std::string(reinterpret_cast<const char*>(&buffer[0]), buffer_len);
|
||||
}
|
||||
|
||||
// static
|
||||
size_t LLBase64::requiredDecryptionSpace(const std::string& str)
|
||||
{
|
||||
size_t len = str.length();
|
||||
U32 padding = 0;
|
||||
|
||||
if (str[len - 1] == '=' && str[len - 2] == '=') //last two chars are =
|
||||
padding = 2;
|
||||
else if (str[len - 1] == '=') //last char is =
|
||||
padding = 1;
|
||||
|
||||
return len * 0.75 - padding;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,31 +3,25 @@
|
||||
* @brief Wrapper for apr base64 encoding that returns a std::string
|
||||
* @author James Cook
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -37,7 +31,11 @@
|
||||
class LL_COMMON_API LLBase64
|
||||
{
|
||||
public:
|
||||
static std::string encode(const std::string& in_str);
|
||||
static std::string encode(const U8* input, size_t input_size);
|
||||
static size_t decode(const std::string& input, U8 * buffer, size_t buffer_size);
|
||||
static std::string decode(const std::string& input);
|
||||
static size_t requiredDecryptionSpace(const std::string& str);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* @file llhash.h
|
||||
* @brief Wrapper for a hash function.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLHASH_H
|
||||
#define LL_LLHASH_H
|
||||
|
||||
#include "llpreprocessor.h" // for GCC_VERSION
|
||||
|
||||
#if (LL_WINDOWS)
|
||||
#include <hash_map>
|
||||
#include <algorithm>
|
||||
#elif LL_DARWIN || LL_LINUX
|
||||
#if GCC_VERSION >= 40300 || LL_ICC || LL_CLANG// gcc 4.3 or icc 11 and up
|
||||
# include <backward/hashtable.h>
|
||||
#elif GCC_VERSION >= 30400 // gcc 3.4 and up
|
||||
# include <ext/hashtable.h>
|
||||
#elif __GNUC__ >= 3
|
||||
# include <ext/stl_hashtable.h>
|
||||
#else
|
||||
# include <hashtable.h>
|
||||
#endif
|
||||
#elif LL_SOLARIS
|
||||
#include <ext/hashtable.h>
|
||||
#else
|
||||
#error Please define your platform.
|
||||
#endif
|
||||
|
||||
// Warning - an earlier template-based version of this routine did not do
|
||||
// the correct thing on Windows. Since this is only used to get
|
||||
// a string hash, it was converted to a regular routine and
|
||||
// unit tests added.
|
||||
|
||||
inline size_t llhash( const char * value )
|
||||
{
|
||||
#if LL_WINDOWS
|
||||
return stdext::hash_value(value);
|
||||
#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
|
||||
std::hash<const char *> H;
|
||||
return H(value);
|
||||
#elif LL_DARWIN || LL_LINUX || LL_SOLARIS
|
||||
__gnu_cxx::hash<const char *> H;
|
||||
return H(value);
|
||||
#else
|
||||
#error Please define your platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,17 @@
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llinitparam.h"
|
||||
#include "llformat.h"
|
||||
|
||||
|
||||
namespace LLInitParam
|
||||
{
|
||||
|
||||
predicate_rule_t default_parse_rules()
|
||||
{
|
||||
return ll_make_predicate(PROVIDED) && !ll_make_predicate(EMPTY);
|
||||
}
|
||||
|
||||
//
|
||||
// Param
|
||||
//
|
||||
@@ -196,6 +203,9 @@ namespace LLInitParam
|
||||
|
||||
bool BaseBlock::validateBlock(bool emit_errors) const
|
||||
{
|
||||
// only validate block when it hasn't already passed validation with current data
|
||||
if (!mValidated)
|
||||
{
|
||||
const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
||||
for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it)
|
||||
{
|
||||
@@ -209,11 +219,18 @@ namespace LLInitParam
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
mValidated = true;
|
||||
}
|
||||
return mValidated;
|
||||
}
|
||||
|
||||
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const
|
||||
bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const LLInitParam::BaseBlock* diff_block) const
|
||||
{
|
||||
bool serialized = false;
|
||||
if (!predicate_rule.check(ll_make_predicate(PROVIDED, isProvided())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// named param is one like LLView::Params::follows
|
||||
// unnamed param is like LLView::Params::rect - implicit
|
||||
const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
||||
@@ -225,10 +242,10 @@ namespace LLInitParam
|
||||
param_handle_t param_handle = (*it)->mParamHandle;
|
||||
const Param* param = getParamFromHandle(param_handle);
|
||||
ParamDescriptor::serialize_func_t serialize_func = (*it)->mSerializeFunc;
|
||||
if (serialize_func)
|
||||
if (serialize_func && predicate_rule.check(ll_make_predicate(PROVIDED, param->anyProvided())))
|
||||
{
|
||||
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
|
||||
serialize_func(*param, parser, name_stack, diff_param);
|
||||
serialized |= serialize_func(*param, parser, name_stack, predicate_rule, diff_param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +256,7 @@ namespace LLInitParam
|
||||
param_handle_t param_handle = it->second->mParamHandle;
|
||||
const Param* param = getParamFromHandle(param_handle);
|
||||
ParamDescriptor::serialize_func_t serialize_func = it->second->mSerializeFunc;
|
||||
if (serialize_func && param->anyProvided())
|
||||
if (serialize_func && predicate_rule.check(ll_make_predicate(PROVIDED, param->anyProvided())))
|
||||
{
|
||||
// Ensure this param has not already been serialized
|
||||
// Prevents <rect> from being serialized as its own tag.
|
||||
@@ -264,10 +281,17 @@ namespace LLInitParam
|
||||
|
||||
name_stack.push_back(std::make_pair(it->first, !duplicate));
|
||||
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
|
||||
serialize_func(*param, parser, name_stack, diff_param);
|
||||
serialized |= serialize_func(*param, parser, name_stack, predicate_rule, diff_param);
|
||||
name_stack.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
if (!serialized && predicate_rule.check(ll_make_predicate(EMPTY)))
|
||||
{
|
||||
serialized |= parser.writeValue(Flag(), name_stack);
|
||||
}
|
||||
// was anything serialized in this block?
|
||||
return serialized;
|
||||
}
|
||||
|
||||
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const
|
||||
|
||||
@@ -29,14 +29,17 @@
|
||||
#define LL_LLPARAM_H
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "llerror.h"
|
||||
#include "llstl.h"
|
||||
#include "llpredicate.h"
|
||||
#include "llsd.h"
|
||||
|
||||
namespace LLTypeTags
|
||||
{
|
||||
@@ -195,6 +198,8 @@ namespace LLInitParam
|
||||
return mValue;
|
||||
}
|
||||
|
||||
bool isValid() const { return true; }
|
||||
|
||||
protected:
|
||||
T mValue;
|
||||
};
|
||||
@@ -209,13 +214,11 @@ namespace LLInitParam
|
||||
typedef T value_t;
|
||||
|
||||
ParamValue()
|
||||
: T(),
|
||||
mValidated(false)
|
||||
: T()
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& other)
|
||||
: T(other),
|
||||
mValidated(false)
|
||||
: T(other)
|
||||
{}
|
||||
|
||||
void setValue(const value_t& val)
|
||||
@@ -232,9 +235,6 @@ namespace LLInitParam
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
};
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ namespace LLInitParam
|
||||
typedef self_t type_value_t;
|
||||
|
||||
TypeValuesHelper(const std::string& val)
|
||||
: base_t(val)
|
||||
: base_t::TypeValuesHelper(val) // <alchemy/> Fix invalid blah gcc
|
||||
{}
|
||||
|
||||
void operator ()(const std::string& name)
|
||||
@@ -579,6 +579,19 @@ namespace LLInitParam
|
||||
|
||||
class Param;
|
||||
|
||||
enum ESerializePredicates
|
||||
{
|
||||
PROVIDED,
|
||||
REQUIRED,
|
||||
VALID,
|
||||
HAS_DEFAULT_VALUE,
|
||||
EMPTY
|
||||
};
|
||||
|
||||
typedef LLPredicate::Rule<ESerializePredicates> predicate_rule_t;
|
||||
|
||||
LL_COMMON_API predicate_rule_t default_parse_rules();
|
||||
|
||||
// various callbacks and constraints associated with an individual param
|
||||
struct LL_COMMON_API ParamDescriptor
|
||||
{
|
||||
@@ -589,7 +602,7 @@ namespace LLInitParam
|
||||
|
||||
typedef bool(*merge_func_t)(Param&, const Param&, bool);
|
||||
typedef bool(*deserialize_func_t)(Param&, Parser&, Parser::name_stack_range_t&, bool);
|
||||
typedef void(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const Param* diff_param);
|
||||
typedef bool(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const predicate_rule_t rules, const Param* diff_param);
|
||||
typedef void(*inspect_func_t)(const Param&, Parser&, Parser::name_stack_t&, S32 min_count, S32 max_count);
|
||||
typedef bool(*validation_func_t)(const Param*);
|
||||
|
||||
@@ -829,12 +842,28 @@ namespace LLInitParam
|
||||
LOG_CLASS(BaseBlock);
|
||||
friend class Param;
|
||||
|
||||
BaseBlock()
|
||||
: mValidated(false),
|
||||
mParamProvided(false)
|
||||
{}
|
||||
|
||||
virtual ~BaseBlock() {}
|
||||
bool submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent=false);
|
||||
|
||||
param_handle_t getHandleFromParam(const Param* param) const;
|
||||
bool validateBlock(bool emit_errors = true) const;
|
||||
|
||||
bool isProvided() const
|
||||
{
|
||||
return mParamProvided;
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return validateBlock(false);
|
||||
}
|
||||
|
||||
|
||||
Param* getParamFromHandle(const param_handle_t param_handle)
|
||||
{
|
||||
if (param_handle == 0) return NULL;
|
||||
@@ -852,10 +881,19 @@ namespace LLInitParam
|
||||
void addSynonym(Param& param, const std::string& synonym);
|
||||
|
||||
// Blocks can override this to do custom tracking of changes
|
||||
virtual void paramChanged(const Param& changed_param, bool user_provided) {}
|
||||
virtual void paramChanged(const Param& changed_param, bool user_provided)
|
||||
{
|
||||
if (user_provided)
|
||||
{
|
||||
// a child param has been explicitly changed
|
||||
// so *some* aspect of this block is now provided
|
||||
mValidated = false;
|
||||
mParamProvided = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool deserializeBlock(Parser& p, Parser::name_stack_range_t& name_stack_range, bool new_name);
|
||||
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const;
|
||||
bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule, const BaseBlock* diff_block = NULL) const;
|
||||
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const;
|
||||
|
||||
virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return getBlockDescriptor(); }
|
||||
@@ -893,6 +931,9 @@ namespace LLInitParam
|
||||
return mergeBlock(block_data, source, overwrite);
|
||||
}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
bool mParamProvided;
|
||||
|
||||
private:
|
||||
const std::string& getParamName(const BlockDescriptor& block_data, const Param* paramp) const;
|
||||
};
|
||||
@@ -986,6 +1027,8 @@ namespace LLInitParam
|
||||
|
||||
bool isProvided() const { return Param::anyProvided(); }
|
||||
|
||||
bool isValid() const { return true; }
|
||||
|
||||
static bool deserializeParam(Param& param, Parser& parser, Parser::name_stack_range_t& name_stack_range, bool new_name)
|
||||
{
|
||||
self_t& typed_param = static_cast<self_t&>(param);
|
||||
@@ -1014,10 +1057,23 @@ namespace LLInitParam
|
||||
return false;
|
||||
}
|
||||
|
||||
static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param)
|
||||
static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param)
|
||||
{
|
||||
bool serialized = false;
|
||||
const self_t& typed_param = static_cast<const self_t&>(param);
|
||||
if (!typed_param.isProvided()) return;
|
||||
const self_t* diff_typed_param = static_cast<const self_t*>(diff_param);
|
||||
|
||||
LLPredicate::Value<ESerializePredicates> predicate;
|
||||
if (diff_typed_param && ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue()))
|
||||
{
|
||||
predicate.set(HAS_DEFAULT_VALUE);
|
||||
}
|
||||
|
||||
predicate.set(VALID, typed_param.isValid());
|
||||
predicate.set(PROVIDED, typed_param.anyProvided());
|
||||
predicate.set(EMPTY, false);
|
||||
|
||||
if (!predicate_rule.check(predicate)) return false;
|
||||
|
||||
if (!name_stack.empty())
|
||||
{
|
||||
@@ -1030,25 +1086,27 @@ namespace LLInitParam
|
||||
|
||||
if (!key.empty())
|
||||
{
|
||||
if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), key))
|
||||
if (!diff_typed_param || !ParamCompare<std::string>::equals(diff_typed_param->getValueName(), key))
|
||||
{
|
||||
parser.writeValue(key, name_stack);
|
||||
serialized = parser.writeValue(key, name_stack);
|
||||
}
|
||||
}
|
||||
// then try to serialize value directly
|
||||
else if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), static_cast<const self_t*>(diff_param)->getValue()))
|
||||
else if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue()))
|
||||
{
|
||||
if (!parser.writeValue(typed_param.getValue(), name_stack))
|
||||
serialized = parser.writeValue(typed_param.getValue(), name_stack);
|
||||
if (!serialized)
|
||||
{
|
||||
std::string calculated_key = typed_param.calcValueName(typed_param.getValue());
|
||||
if (calculated_key.size()
|
||||
&& (!diff_param
|
||||
&& (!diff_typed_param
|
||||
|| !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), calculated_key)))
|
||||
{
|
||||
parser.writeValue(calculated_key, name_stack);
|
||||
serialized = parser.writeValue(calculated_key, name_stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
|
||||
static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count)
|
||||
@@ -1065,7 +1123,7 @@ namespace LLInitParam
|
||||
void set(const value_t& val, bool flag_as_provided = true)
|
||||
{
|
||||
named_value_t::clearValueName();
|
||||
this->setValue(val);
|
||||
named_value_t::setValue(val);
|
||||
setProvided(flag_as_provided);
|
||||
}
|
||||
|
||||
@@ -1113,15 +1171,15 @@ namespace LLInitParam
|
||||
};
|
||||
|
||||
// parameter that is a block
|
||||
template <typename T, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<T, NAME_VALUE_LOOKUP, false, IS_A_BLOCK>
|
||||
template <typename BLOCK_T, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<BLOCK_T, NAME_VALUE_LOOKUP, false, IS_A_BLOCK>
|
||||
: public Param,
|
||||
public NAME_VALUE_LOOKUP::type_value_t
|
||||
{
|
||||
protected:
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<T>::value_t> param_value_t;
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<BLOCK_T>::value_t> param_value_t;
|
||||
typedef typename param_value_t::default_value_t default_value_t;
|
||||
typedef TypedParam<T, NAME_VALUE_LOOKUP, false, IS_A_BLOCK> self_t;
|
||||
typedef TypedParam<BLOCK_T, NAME_VALUE_LOOKUP, false, IS_A_BLOCK> self_t;
|
||||
typedef typename NAME_VALUE_LOOKUP::type_value_t named_value_t;
|
||||
public:
|
||||
using named_value_t::operator();
|
||||
@@ -1166,10 +1224,16 @@ namespace LLInitParam
|
||||
return false;
|
||||
}
|
||||
|
||||
static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param)
|
||||
static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param)
|
||||
{
|
||||
const self_t& typed_param = static_cast<const self_t&>(param);
|
||||
if (!typed_param.isProvided()) return;
|
||||
|
||||
LLPredicate::Value<ESerializePredicates> predicate;
|
||||
|
||||
predicate.set(VALID, typed_param.isValid());
|
||||
predicate.set(PROVIDED, typed_param.anyProvided());
|
||||
|
||||
if (!predicate_rule.check(predicate)) return false;
|
||||
|
||||
if (!name_stack.empty())
|
||||
{
|
||||
@@ -1182,12 +1246,15 @@ namespace LLInitParam
|
||||
if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), key))
|
||||
{
|
||||
parser.writeValue(key, name_stack);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typed_param.serializeBlock(parser, name_stack, static_cast<const self_t*>(diff_param));
|
||||
return typed_param.serializeBlock(parser, name_stack, predicate_rule, static_cast<const self_t*>(diff_param));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count)
|
||||
@@ -1209,23 +1276,19 @@ namespace LLInitParam
|
||||
// *and* the block as a whole validates
|
||||
bool isProvided() const
|
||||
{
|
||||
// only validate block when it hasn't already passed validation with current data
|
||||
if (Param::anyProvided() && !param_value_t::mValidated)
|
||||
{
|
||||
// a sub-block is "provided" when it has been filled in enough to be valid
|
||||
param_value_t::mValidated = param_value_t::validateBlock(false);
|
||||
}
|
||||
return Param::anyProvided() && param_value_t::mValidated;
|
||||
return Param::anyProvided() && isValid();
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return param_value_t::isValid();
|
||||
}
|
||||
|
||||
// assign block contents to this param-that-is-a-block
|
||||
void set(const value_t& val, bool flag_as_provided = true)
|
||||
{
|
||||
this->setValue(val);
|
||||
named_value_t::setValue(val);
|
||||
named_value_t::clearValueName();
|
||||
// force revalidation of block
|
||||
// next call to isProvided() will update provision status based on validity
|
||||
param_value_t::mValidated = false;
|
||||
setProvided(flag_as_provided);
|
||||
}
|
||||
|
||||
@@ -1242,9 +1305,6 @@ namespace LLInitParam
|
||||
|
||||
if (user_provided)
|
||||
{
|
||||
// a child param has been explicitly changed
|
||||
// so *some* aspect of this block is now provided
|
||||
param_value_t::mValidated = false;
|
||||
setProvided();
|
||||
named_value_t::clearValueName();
|
||||
}
|
||||
@@ -1296,13 +1356,13 @@ namespace LLInitParam
|
||||
};
|
||||
|
||||
// list of non-block parameters
|
||||
template <typename VALUE_TYPE, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, NOT_BLOCK>
|
||||
template <typename MULTI_VALUE_T, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<MULTI_VALUE_T, NAME_VALUE_LOOKUP, true, NOT_BLOCK>
|
||||
: public Param
|
||||
{
|
||||
protected:
|
||||
typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, NOT_BLOCK> self_t;
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<VALUE_TYPE>::value_t> param_value_t;
|
||||
typedef TypedParam<MULTI_VALUE_T, NAME_VALUE_LOOKUP, true, NOT_BLOCK> self_t;
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<MULTI_VALUE_T>::value_t> param_value_t;
|
||||
typedef typename std::vector<typename NAME_VALUE_LOOKUP::type_value_t> container_t;
|
||||
typedef container_t default_value_t;
|
||||
typedef typename NAME_VALUE_LOOKUP::type_value_t named_value_t;
|
||||
@@ -1311,7 +1371,9 @@ namespace LLInitParam
|
||||
typedef typename param_value_t::value_t value_t;
|
||||
|
||||
TypedParam(BlockDescriptor& block_descriptor, const char* name, const default_value_t& value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)
|
||||
: Param(block_descriptor.mCurrentBlockPtr)
|
||||
: Param(block_descriptor.mCurrentBlockPtr),
|
||||
mMinCount(min_count),
|
||||
mMaxCount(max_count)
|
||||
{
|
||||
std::copy(value.begin(), value.end(), std::back_inserter(mValues));
|
||||
|
||||
@@ -1322,7 +1384,13 @@ namespace LLInitParam
|
||||
}
|
||||
}
|
||||
|
||||
bool isProvided() const { return Param::anyProvided(); }
|
||||
bool isProvided() const { return Param::anyProvided() && isValid(); }
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
size_t num_elements = numValidElements();
|
||||
return mMinCount < num_elements && num_elements < mMaxCount;
|
||||
}
|
||||
|
||||
static bool deserializeParam(Param& param, Parser& parser, Parser::name_stack_range_t& name_stack_range, bool new_name)
|
||||
{
|
||||
@@ -1337,7 +1405,7 @@ namespace LLInitParam
|
||||
}
|
||||
|
||||
// no further names in stack, attempt to parse value now
|
||||
if (name_stack_range.first == name_stack_range.second)
|
||||
if (new_name_stack_range.first == new_name_stack_range.second)
|
||||
{
|
||||
std::string name;
|
||||
|
||||
@@ -1359,10 +1427,19 @@ namespace LLInitParam
|
||||
return false;
|
||||
}
|
||||
|
||||
static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param)
|
||||
static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param)
|
||||
{
|
||||
bool serialized = false;
|
||||
const self_t& typed_param = static_cast<const self_t&>(param);
|
||||
if (!typed_param.isProvided()) return;
|
||||
|
||||
LLPredicate::Value<ESerializePredicates> predicate;
|
||||
|
||||
predicate.set(REQUIRED, typed_param.mMinCount > 0);
|
||||
predicate.set(VALID, typed_param.isValid());
|
||||
predicate.set(PROVIDED, typed_param.anyProvided());
|
||||
predicate.set(EMPTY, typed_param.mValues.empty());
|
||||
|
||||
if (!predicate_rule.check(predicate)) return false;
|
||||
|
||||
for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end();
|
||||
it != end_it;
|
||||
@@ -1378,7 +1455,11 @@ namespace LLInitParam
|
||||
if (!value_written)
|
||||
{
|
||||
std::string calculated_key = it->calcValueName(it->getValue());
|
||||
if (!parser.writeValue(calculated_key, name_stack))
|
||||
if (parser.writeValue(calculated_key, name_stack))
|
||||
{
|
||||
serialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1386,19 +1467,23 @@ namespace LLInitParam
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!parser.writeValue(key, name_stack))
|
||||
if(parser.writeValue(key, name_stack))
|
||||
{
|
||||
serialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
name_stack.pop_back();
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count)
|
||||
{
|
||||
parser.inspectValue<VALUE_TYPE>(name_stack, min_count, max_count, NULL);
|
||||
parser.inspectValue<MULTI_VALUE_T>(name_stack, min_count, max_count, NULL);
|
||||
if (named_value_t::getPossibleValues())
|
||||
{
|
||||
parser.inspectValue<std::string>(name_stack, min_count, max_count, named_value_t::getPossibleValues());
|
||||
@@ -1453,7 +1538,7 @@ namespace LLInitParam
|
||||
bool empty() const { return mValues.empty(); }
|
||||
size_t size() const { return mValues.size(); }
|
||||
|
||||
U32 numValidElements() const
|
||||
size_t numValidElements() const
|
||||
{
|
||||
return mValues.size();
|
||||
}
|
||||
@@ -1483,6 +1568,8 @@ namespace LLInitParam
|
||||
}
|
||||
|
||||
container_t mValues;
|
||||
size_t mMinCount,
|
||||
mMaxCount;
|
||||
|
||||
private:
|
||||
void init( BlockDescriptor &block_descriptor, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count, const char* name )
|
||||
@@ -1500,13 +1587,13 @@ namespace LLInitParam
|
||||
};
|
||||
|
||||
// list of block parameters
|
||||
template <typename VALUE_TYPE, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, IS_A_BLOCK>
|
||||
template <typename MULTI_BLOCK_T, typename NAME_VALUE_LOOKUP>
|
||||
class TypedParam<MULTI_BLOCK_T, NAME_VALUE_LOOKUP, true, IS_A_BLOCK>
|
||||
: public Param
|
||||
{
|
||||
protected:
|
||||
typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, IS_A_BLOCK> self_t;
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<VALUE_TYPE>::value_t> param_value_t;
|
||||
typedef TypedParam<MULTI_BLOCK_T, NAME_VALUE_LOOKUP, true, IS_A_BLOCK> self_t;
|
||||
typedef ParamValue<typename LLTypeTags::Sorted<MULTI_BLOCK_T>::value_t> param_value_t;
|
||||
typedef typename std::vector<typename NAME_VALUE_LOOKUP::type_value_t> container_t;
|
||||
typedef typename NAME_VALUE_LOOKUP::type_value_t named_value_t;
|
||||
typedef container_t default_value_t;
|
||||
@@ -1516,7 +1603,9 @@ namespace LLInitParam
|
||||
typedef typename param_value_t::value_t value_t;
|
||||
|
||||
TypedParam(BlockDescriptor& block_descriptor, const char* name, const default_value_t& value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)
|
||||
: Param(block_descriptor.mCurrentBlockPtr)
|
||||
: Param(block_descriptor.mCurrentBlockPtr),
|
||||
mMinCount(min_count),
|
||||
mMaxCount(max_count)
|
||||
{
|
||||
std::copy(value.begin(), value.end(), back_inserter(mValues));
|
||||
|
||||
@@ -1526,7 +1615,14 @@ namespace LLInitParam
|
||||
}
|
||||
}
|
||||
|
||||
bool isProvided() const { return Param::anyProvided(); }
|
||||
bool isProvided() const { return Param::anyProvided() && isValid(); }
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
size_t num_elements = numValidElements();
|
||||
return mMinCount < num_elements && num_elements < mMaxCount;
|
||||
}
|
||||
|
||||
|
||||
static bool deserializeParam(Param& param, Parser& parser, Parser::name_stack_range_t& name_stack_range, bool new_name)
|
||||
{
|
||||
@@ -1549,7 +1645,7 @@ namespace LLInitParam
|
||||
}
|
||||
param_value_t& value = typed_param.mValues.back();
|
||||
|
||||
if (name_stack_range.first == name_stack_range.second)
|
||||
if (new_name_stack_range.first == new_name_stack_range.second)
|
||||
{ // try to parse a known named value
|
||||
std::string name;
|
||||
|
||||
@@ -1559,6 +1655,10 @@ namespace LLInitParam
|
||||
{
|
||||
typed_param.mValues.back().setValueName(name);
|
||||
typed_param.setProvided();
|
||||
if (new_array_value)
|
||||
{
|
||||
name_stack_range.first->second = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1583,10 +1683,18 @@ namespace LLInitParam
|
||||
return false;
|
||||
}
|
||||
|
||||
static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param)
|
||||
static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param)
|
||||
{
|
||||
bool serialized = false;
|
||||
const self_t& typed_param = static_cast<const self_t&>(param);
|
||||
if (!typed_param.isProvided()) return;
|
||||
LLPredicate::Value<ESerializePredicates> predicate;
|
||||
|
||||
predicate.set(REQUIRED, typed_param.mMinCount > 0);
|
||||
predicate.set(VALID, typed_param.isValid());
|
||||
predicate.set(PROVIDED, typed_param.anyProvided());
|
||||
predicate.set(EMPTY, typed_param.mValues.empty());
|
||||
|
||||
if (!predicate_rule.check(predicate)) return false;
|
||||
|
||||
for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end();
|
||||
it != end_it;
|
||||
@@ -1597,17 +1705,24 @@ namespace LLInitParam
|
||||
std::string key = it->getValueName();
|
||||
if (!key.empty())
|
||||
{
|
||||
parser.writeValue(key, name_stack);
|
||||
serialized |= parser.writeValue(key, name_stack);
|
||||
}
|
||||
// Not parsed via named values, write out value directly
|
||||
// NOTE: currently we don't worry about removing default values in Multiple
|
||||
// NOTE: currently we don't do diffing of Multiples
|
||||
else
|
||||
{
|
||||
it->serializeBlock(parser, name_stack, NULL);
|
||||
serialized = it->serializeBlock(parser, name_stack, predicate_rule, NULL);
|
||||
}
|
||||
|
||||
name_stack.pop_back();
|
||||
}
|
||||
|
||||
if (!serialized && predicate_rule.check(ll_make_predicate(EMPTY)))
|
||||
{
|
||||
serialized |= parser.writeValue(Flag(), name_stack);
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count)
|
||||
@@ -1670,14 +1785,14 @@ namespace LLInitParam
|
||||
bool empty() const { return mValues.empty(); }
|
||||
size_t size() const { return mValues.size(); }
|
||||
|
||||
U32 numValidElements() const
|
||||
size_t numValidElements() const
|
||||
{
|
||||
U32 count = 0;
|
||||
size_t count = 0;
|
||||
for (const_iterator it = mValues.begin(), end_it = mValues.end();
|
||||
it != end_it;
|
||||
++it)
|
||||
{
|
||||
if(it->validateBlock(false)) count++;
|
||||
if(it->isValid()) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -1709,6 +1824,8 @@ namespace LLInitParam
|
||||
}
|
||||
|
||||
container_t mValues;
|
||||
size_t mMinCount,
|
||||
mMaxCount;
|
||||
|
||||
private:
|
||||
void init( BlockDescriptor &block_descriptor, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count, const char* name )
|
||||
@@ -1937,7 +2054,7 @@ namespace LLInitParam
|
||||
|
||||
Optional& operator =(const value_t& val)
|
||||
{
|
||||
this->set(val);
|
||||
super_t::set(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1967,7 +2084,7 @@ namespace LLInitParam
|
||||
|
||||
Mandatory& operator =(const value_t& val)
|
||||
{
|
||||
this->set(val);
|
||||
super_t::set(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -2003,7 +2120,7 @@ namespace LLInitParam
|
||||
|
||||
Multiple& operator =(const container_t& val)
|
||||
{
|
||||
set(val);
|
||||
super_t::set(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -2015,7 +2132,7 @@ namespace LLInitParam
|
||||
|
||||
static bool validate(const Param* paramp)
|
||||
{
|
||||
U32 num_valid = ((super_t*)paramp)->numValidElements();
|
||||
size_t num_valid = ((super_t*)paramp)->numValidElements();
|
||||
return RANGE::minCount <= num_valid && num_valid <= RANGE::maxCount;
|
||||
}
|
||||
};
|
||||
@@ -2158,13 +2275,11 @@ namespace LLInitParam
|
||||
typedef T default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: mValue(),
|
||||
mValidated(false)
|
||||
: mValue()
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& value)
|
||||
: mValue(value),
|
||||
mValidated(false)
|
||||
: mValue(value)
|
||||
{}
|
||||
|
||||
void setValue(const value_t& val)
|
||||
@@ -2191,12 +2306,12 @@ namespace LLInitParam
|
||||
return mValue.deserializeBlock(p, name_stack_range, new_name);
|
||||
}
|
||||
|
||||
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const self_t* diff_block = NULL) const
|
||||
bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const self_t* diff_block = NULL) const
|
||||
{
|
||||
const BaseBlock* base_block = diff_block
|
||||
? &(diff_block->mValue)
|
||||
: NULL;
|
||||
mValue.serializeBlock(p, name_stack, base_block);
|
||||
return mValue.serializeBlock(p, name_stack, predicate_rule, base_block);
|
||||
}
|
||||
|
||||
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const
|
||||
@@ -2213,8 +2328,6 @@ namespace LLInitParam
|
||||
resetToDefault();
|
||||
return mValue.mergeBlock(block_data, source.getValue(), overwrite);
|
||||
}
|
||||
|
||||
|
||||
return mValue.mergeBlock(block_data, source.getValue(), overwrite);
|
||||
}
|
||||
|
||||
@@ -2223,14 +2336,17 @@ namespace LLInitParam
|
||||
return mValue.validateBlock(emit_errors);
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return validateBlock(false);
|
||||
}
|
||||
|
||||
static BlockDescriptor& getBlockDescriptor()
|
||||
{
|
||||
return value_t::getBlockDescriptor();
|
||||
}
|
||||
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
|
||||
private:
|
||||
void resetToDefault()
|
||||
{
|
||||
@@ -2251,15 +2367,13 @@ namespace LLInitParam
|
||||
typedef T default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: mValue(),
|
||||
mValidated(false)
|
||||
: mValue()
|
||||
{
|
||||
mCurParam = getBlockDescriptor().mAllParams.begin();
|
||||
}
|
||||
|
||||
ParamValue(const default_value_t& value)
|
||||
: mValue(value),
|
||||
mValidated(false)
|
||||
: mValue(value)
|
||||
{
|
||||
mCurParam = getBlockDescriptor().mAllParams.begin();
|
||||
}
|
||||
@@ -2311,12 +2425,12 @@ namespace LLInitParam
|
||||
}
|
||||
}
|
||||
|
||||
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const self_t* diff_block = NULL) const
|
||||
bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const self_t* diff_block = NULL) const
|
||||
{
|
||||
const BaseBlock* base_block = diff_block
|
||||
? &(diff_block->mValue)
|
||||
: NULL;
|
||||
mValue.serializeBlock(p, name_stack, base_block);
|
||||
return mValue.serializeBlock(p, name_stack, predicate_rule, base_block);
|
||||
}
|
||||
|
||||
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const
|
||||
@@ -2334,13 +2448,16 @@ namespace LLInitParam
|
||||
return mValue.validateBlock(emit_errors);
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return validateBlock(false);
|
||||
}
|
||||
|
||||
static BlockDescriptor& getBlockDescriptor()
|
||||
{
|
||||
return value_t::getBlockDescriptor();
|
||||
}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
|
||||
private:
|
||||
|
||||
BlockDescriptor::all_params_list_t::iterator mCurParam;
|
||||
@@ -2358,16 +2475,14 @@ namespace LLInitParam
|
||||
typedef T default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: T(),
|
||||
mValidated(false)
|
||||
: T()
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& value)
|
||||
: T(value.getValue()),
|
||||
mValidated(false)
|
||||
: T(value.getValue())
|
||||
{}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
bool isValid() const { return true; }
|
||||
};
|
||||
|
||||
template<typename T, typename BLOCK_T>
|
||||
@@ -2380,18 +2495,15 @@ namespace LLInitParam
|
||||
typedef LazyValue<T> default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: mValue(),
|
||||
mValidated(false)
|
||||
: mValue()
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& other)
|
||||
: mValue(other),
|
||||
mValidated(false)
|
||||
: mValue(other)
|
||||
{}
|
||||
|
||||
ParamValue(const T& value)
|
||||
: mValue(value),
|
||||
mValidated(false)
|
||||
: mValue(value)
|
||||
{}
|
||||
|
||||
void setValue(const value_t& val)
|
||||
@@ -2414,14 +2526,14 @@ namespace LLInitParam
|
||||
return mValue.get().deserializeBlock(p, name_stack_range, new_name);
|
||||
}
|
||||
|
||||
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const self_t* diff_block = NULL) const
|
||||
bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const self_t* diff_block = NULL) const
|
||||
{
|
||||
if (mValue.empty()) return;
|
||||
if (mValue.empty()) return false;
|
||||
|
||||
const BaseBlock* base_block = (diff_block && !diff_block->mValue.empty())
|
||||
? &(diff_block->mValue.get().getValue())
|
||||
: NULL;
|
||||
mValue.get().serializeBlock(p, name_stack, base_block);
|
||||
return mValue.get().serializeBlock(p, name_stack, predicate_rule, base_block);
|
||||
}
|
||||
|
||||
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const
|
||||
@@ -2439,13 +2551,16 @@ namespace LLInitParam
|
||||
return mValue.empty() || mValue.get().validateBlock(emit_errors);
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return validateBlock(false);
|
||||
}
|
||||
|
||||
static BlockDescriptor& getBlockDescriptor()
|
||||
{
|
||||
return value_t::getBlockDescriptor();
|
||||
}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
|
||||
private:
|
||||
LazyValue<T> mValue;
|
||||
};
|
||||
@@ -2460,18 +2575,15 @@ namespace LLInitParam
|
||||
typedef LazyValue<T> default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: mValue(),
|
||||
mValidated(false)
|
||||
: mValue()
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& other)
|
||||
: mValue(other),
|
||||
mValidated(false)
|
||||
: mValue(other)
|
||||
{}
|
||||
|
||||
ParamValue(const T& value)
|
||||
: mValue(value),
|
||||
mValidated(false)
|
||||
: mValue(value)
|
||||
{}
|
||||
|
||||
void setValue(const value_t& val)
|
||||
@@ -2489,7 +2601,10 @@ namespace LLInitParam
|
||||
return mValue.get().getValue();
|
||||
}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
bool isValid() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
LazyValue<T> mValue;
|
||||
@@ -2504,12 +2619,10 @@ namespace LLInitParam
|
||||
typedef LLSD default_value_t;
|
||||
|
||||
ParamValue()
|
||||
: mValidated(false)
|
||||
{}
|
||||
|
||||
ParamValue(const default_value_t& other)
|
||||
: mValue(other),
|
||||
mValidated(false)
|
||||
: mValue(other)
|
||||
{}
|
||||
|
||||
void setValue(const value_t& val) { mValue = val; }
|
||||
@@ -2519,16 +2632,13 @@ namespace LLInitParam
|
||||
|
||||
// block param interface
|
||||
LL_COMMON_API bool deserializeBlock(Parser& p, Parser::name_stack_range_t& name_stack_range, bool new_name);
|
||||
LL_COMMON_API void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const;
|
||||
LL_COMMON_API bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block = NULL) const;
|
||||
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const
|
||||
{
|
||||
//TODO: implement LLSD params as schema type Any
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
|
||||
private:
|
||||
static void serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack);
|
||||
|
||||
@@ -2547,9 +2657,9 @@ namespace LLInitParam
|
||||
BLOCK_AUTHORITATIVE // mValue is derived from the block parameters, which are authoritative
|
||||
} EValueAge;
|
||||
|
||||
typedef ParamValue<T> derived_t;
|
||||
typedef TypeValues<T> derived_t;
|
||||
typedef CustomParamValue<T> self_t;
|
||||
typedef Block<derived_t> block_t;
|
||||
typedef Block<ParamValue<T> > block_t;
|
||||
typedef T default_value_t;
|
||||
typedef T value_t;
|
||||
typedef void baseblock_base_class_t;
|
||||
@@ -2557,8 +2667,7 @@ namespace LLInitParam
|
||||
|
||||
CustomParamValue(const default_value_t& value = T())
|
||||
: mValue(value),
|
||||
mValueAge(VALUE_AUTHORITATIVE),
|
||||
mValidated(false)
|
||||
mValueAge(VALUE_AUTHORITATIVE)
|
||||
{}
|
||||
|
||||
bool deserializeBlock(Parser& parser, Parser::name_stack_range_t& name_stack_range, bool new_name)
|
||||
@@ -2580,16 +2689,30 @@ namespace LLInitParam
|
||||
return typed_param.BaseBlock::deserializeBlock(parser, name_stack_range, new_name);
|
||||
}
|
||||
|
||||
void serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const
|
||||
bool serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block = NULL) const
|
||||
{
|
||||
const derived_t& typed_param = static_cast<const derived_t&>(*this);
|
||||
const derived_t* diff_param = static_cast<const derived_t*>(diff_block);
|
||||
|
||||
//std::string key = typed_param.getValueName();
|
||||
|
||||
//// first try to write out name of name/value pair
|
||||
//if (!key.empty())
|
||||
//{
|
||||
// if (!diff_param || !ParamCompare<std::string>::equals(diff_param->getValueName(), key))
|
||||
// {
|
||||
// return parser.writeValue(key, name_stack);
|
||||
// }
|
||||
//}
|
||||
// then try to serialize value directly
|
||||
if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), diff_param->getValue()))
|
||||
{
|
||||
|
||||
if (!parser.writeValue(typed_param.getValue(), name_stack))
|
||||
if (parser.writeValue(typed_param.getValue(), name_stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//RN: *always* serialize provided components of BlockValue (don't pass diff_param on),
|
||||
// since these tend to be viewed as the constructor arguments for the value T. It seems
|
||||
@@ -2606,14 +2729,15 @@ namespace LLInitParam
|
||||
// and serialize those params
|
||||
derived_t copy(typed_param);
|
||||
copy.updateBlockFromValue(true);
|
||||
copy.block_t::serializeBlock(parser, name_stack, NULL);
|
||||
return copy.block_t::serializeBlock(parser, name_stack, predicate_rule, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
block_t::serializeBlock(parser, name_stack, NULL);
|
||||
return block_t::serializeBlock(parser, name_stack, predicate_rule, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool validateBlock(bool emit_errors = true) const
|
||||
@@ -2705,8 +2829,6 @@ namespace LLInitParam
|
||||
return block_t::mergeBlock(block_data, source, overwrite);
|
||||
}
|
||||
|
||||
mutable bool mValidated; // lazy validation flag
|
||||
|
||||
private:
|
||||
mutable T mValue;
|
||||
mutable EValueAge mValueAge;
|
||||
|
||||
41
indra/llcommon/llpredicate.cpp
Normal file
41
indra/llcommon/llpredicate.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file llpredicate.cpp
|
||||
* @brief abstraction for filtering objects by predicates, with arbitrary boolean expressions
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llpredicate.h"
|
||||
|
||||
namespace LLPredicate
|
||||
{
|
||||
const U32 cPredicateFlagsFromEnum[5] =
|
||||
{
|
||||
0xAAAAaaaa, // 10101010101010101010101010101010
|
||||
0xCCCCcccc, // 11001100110011001100110011001100
|
||||
0xF0F0F0F0, // 11110000111100001111000011110000
|
||||
0xFF00FF00, // 11111111000000001111111100000000
|
||||
0xFFFF0000 // 11111111111111110000000000000000
|
||||
};
|
||||
}
|
||||
|
||||
210
indra/llcommon/llpredicate.h
Normal file
210
indra/llcommon/llpredicate.h
Normal file
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* @file llpredicate.h
|
||||
* @brief abstraction for filtering objects by predicates, with arbitrary boolean expressions
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPREDICATE_H
|
||||
#define LL_LLPREDICATE_H
|
||||
|
||||
#include "llerror.h"
|
||||
|
||||
namespace LLPredicate
|
||||
{
|
||||
template<typename ENUM> class Rule;
|
||||
|
||||
extern LL_COMMON_API const U32 cPredicateFlagsFromEnum[5];
|
||||
|
||||
template<typename ENUM>
|
||||
class Value
|
||||
{
|
||||
public:
|
||||
typedef U32 predicate_flag_t;
|
||||
static const S32 cMaxEnum = 5;
|
||||
|
||||
Value(ENUM e, bool predicate_value = true)
|
||||
: mPredicateFlags(predicate_value ? cPredicateFlagsFromEnum[e] : ~cPredicateFlagsFromEnum[e])
|
||||
{
|
||||
llassert(0 <= e && e < cMaxEnum);
|
||||
}
|
||||
|
||||
Value()
|
||||
: mPredicateFlags(0xFFFFffff)
|
||||
{}
|
||||
|
||||
Value operator!() const
|
||||
{
|
||||
Value new_value;
|
||||
new_value.mPredicateFlags = ~mPredicateFlags;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
Value operator &&(const Value other) const
|
||||
{
|
||||
Value new_value;
|
||||
new_value.mPredicateFlags = mPredicateFlags & other.mPredicateFlags;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
Value operator ||(const Value other) const
|
||||
{
|
||||
Value new_value;
|
||||
new_value.mPredicateFlags = mPredicateFlags | other.mPredicateFlags;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
void set(ENUM e, bool value = true)
|
||||
{
|
||||
llassert(0 <= e && e < cMaxEnum);
|
||||
predicate_flag_t flags_to_modify;
|
||||
predicate_flag_t mask = cPredicateFlagsFromEnum[e];
|
||||
if (value)
|
||||
{ // add predicate "e" to flags that don't contain it already
|
||||
flags_to_modify = (mPredicateFlags & ~mask);
|
||||
// clear flags not containing e
|
||||
mPredicateFlags &= mask;
|
||||
// add back flags shifted to contain e
|
||||
mPredicateFlags |= flags_to_modify << (0x1 << e);
|
||||
}
|
||||
else
|
||||
{ // remove predicate "e" from flags that contain it
|
||||
flags_to_modify = (mPredicateFlags & mask);
|
||||
// clear flags containing e
|
||||
mPredicateFlags &= ~mask;
|
||||
// add back flags shifted to not contain e
|
||||
mPredicateFlags |= flags_to_modify >> (0x1 << e);
|
||||
}
|
||||
}
|
||||
|
||||
void forget(ENUM e)
|
||||
{
|
||||
set(e, true);
|
||||
U32 flags_with_predicate = mPredicateFlags;
|
||||
set(e, false);
|
||||
// ambiguous value is result of adding and removing predicate at the same time!
|
||||
mPredicateFlags |= flags_with_predicate;
|
||||
}
|
||||
|
||||
bool allSet() const
|
||||
{
|
||||
return mPredicateFlags == ~0;
|
||||
}
|
||||
|
||||
bool noneSet() const
|
||||
{
|
||||
return mPredicateFlags == 0;
|
||||
}
|
||||
|
||||
bool someSet() const
|
||||
{
|
||||
return mPredicateFlags != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
predicate_flag_t mPredicateFlags;
|
||||
};
|
||||
|
||||
template<typename ENUM>
|
||||
class Rule
|
||||
{
|
||||
public:
|
||||
Rule(ENUM value)
|
||||
: mRule(value)
|
||||
{}
|
||||
|
||||
Rule(const Value<ENUM> other)
|
||||
: mRule(other)
|
||||
{}
|
||||
|
||||
Rule()
|
||||
{}
|
||||
|
||||
void require(ENUM e, bool match)
|
||||
{
|
||||
mRule.set(e, match);
|
||||
}
|
||||
|
||||
void allow(ENUM e)
|
||||
{
|
||||
mRule.forget(e);
|
||||
}
|
||||
|
||||
bool check(const Value<ENUM> value) const
|
||||
{
|
||||
return (mRule && value).someSet();
|
||||
}
|
||||
|
||||
bool requires(const Value<ENUM> value) const
|
||||
{
|
||||
return (mRule && value).someSet() && (!mRule && value).noneSet();
|
||||
}
|
||||
|
||||
bool isAmbivalent(const Value<ENUM> value) const
|
||||
{
|
||||
return (mRule && value).someSet() && (!mRule && value).someSet();
|
||||
}
|
||||
|
||||
bool acceptsAll() const
|
||||
{
|
||||
return mRule.allSet();
|
||||
}
|
||||
|
||||
bool acceptsNone() const
|
||||
{
|
||||
return mRule.noneSet();
|
||||
}
|
||||
|
||||
Rule operator!() const
|
||||
{
|
||||
Rule new_rule;
|
||||
new_rule.mRule = !mRule;
|
||||
return new_rule;
|
||||
}
|
||||
|
||||
Rule operator &&(const Rule other) const
|
||||
{
|
||||
Rule new_rule;
|
||||
new_rule.mRule = mRule && other.mRule;
|
||||
return new_rule;
|
||||
}
|
||||
|
||||
Rule operator ||(const Rule other) const
|
||||
{
|
||||
Rule new_rule;
|
||||
new_rule.mRule = mRule || other.mRule;
|
||||
return new_rule;
|
||||
}
|
||||
|
||||
private:
|
||||
Value<ENUM> mRule;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename ENUM>
|
||||
LLPredicate::Value<ENUM> ll_make_predicate(ENUM e, bool predicate_value = true)
|
||||
{
|
||||
return LLPredicate::Value<ENUM>(e, predicate_value);
|
||||
}
|
||||
|
||||
|
||||
#endif // LL_LLPREDICATE_H
|
||||
@@ -80,8 +80,8 @@
|
||||
#define LL_CLANG 1
|
||||
#endif
|
||||
#elif defined (__ICC)
|
||||
#ifndef LL_ICC
|
||||
#define LL_ICC 1
|
||||
#ifndef LL_INTELC
|
||||
#define LL_INTELC 1
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
@@ -94,9 +94,6 @@
|
||||
#ifndef LL_MSVC
|
||||
#define LL_MSVC 1
|
||||
#endif
|
||||
#if _MSC_VER < 1400
|
||||
#define LL_MSVC7 //Visual C++ 2003 or earlier
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Deal with minor differences on Unixy OSes.
|
||||
@@ -112,6 +109,16 @@
|
||||
|
||||
#endif
|
||||
|
||||
// Check for C++11 support
|
||||
#if __cplusplus >= 201100L || _MSC_VER >= 1800
|
||||
# define LL_CPP11
|
||||
#endif
|
||||
|
||||
#if LL_WINDOWS
|
||||
# define LL_THREAD_LOCAL __declspec(thread)
|
||||
#else
|
||||
# define LL_THREAD_LOCAL __thread
|
||||
#endif
|
||||
|
||||
// Static linking with apr on windows needs to be declared.
|
||||
#if LL_WINDOWS && !LL_COMMON_LINK_SHARED
|
||||
@@ -142,7 +149,7 @@
|
||||
#pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual"
|
||||
#pragma warning( 3 : 4266 ) // 'function' : no override available for virtual member function from base 'type'; function is hidden
|
||||
#pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored
|
||||
#pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
|
||||
//#pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
|
||||
#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
|
||||
#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
#pragma warning( disable : 4996 ) // warning: deprecated
|
||||
@@ -161,6 +168,12 @@
|
||||
|
||||
#pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class
|
||||
#pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class
|
||||
//#pragma warning (disable : 4018) // '<' : signed/unsigned mismatch
|
||||
|
||||
#if _WIN64
|
||||
#pragma warning (disable : 4267) // member needs to have dll-interface to be used by clients of class
|
||||
#endif
|
||||
|
||||
#endif // LL_MSVC
|
||||
|
||||
#if LL_WINDOWS
|
||||
@@ -198,4 +211,23 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LL_WINDOWS) || __cplusplus >= 201103L
|
||||
# define LL_TYPEOF(exp) decltype(exp)
|
||||
#else
|
||||
# define LL_TYPEOF(exp) typeof(exp)
|
||||
#endif
|
||||
|
||||
#define LL_TO_STRING_HELPER(x) #x
|
||||
#define LL_TO_STRING(x) LL_TO_STRING_HELPER(x)
|
||||
#define LL_FILE_LINENO_MSG(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg
|
||||
#define LL_GLUE_IMPL(x, y) x##y
|
||||
#define LL_GLUE_TOKENS(x, y) LL_GLUE_IMPL(x, y)
|
||||
|
||||
#if LL_WINDOWS
|
||||
#define LL_COMPILE_TIME_MESSAGE(msg) __pragma(message(LL_FILE_LINENO_MSG(msg)))
|
||||
#else
|
||||
// no way to get gcc 4.2 to print a user-defined diagnostic message only when a macro is used
|
||||
#define LL_COMPILE_TIME_MESSAGE(msg)
|
||||
#endif
|
||||
|
||||
#endif // not LL_LINDEN_PREPROCESSOR_H
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
# define LL_X86 1
|
||||
#elif LL_MSVC && _M_IX86
|
||||
# define LL_X86 1
|
||||
#elif LL_GNUC || LL_ICC || LL_CLANG && ( defined(__amd64__) || defined(__x86_64__) )
|
||||
#elif LL_GNUC || LL_CLANG || LL_INTELC && ( defined(__amd64__) || defined(__x86_64__) )
|
||||
# define LL_X86_64 1
|
||||
# define LL_X86 1
|
||||
#elif LL_GNUC || LL_ICC || LL_CLANG && ( defined(__i386__) )
|
||||
#elif LL_GNUC || LL_CLANG || LL_INTELC && ( defined(__i386__) )
|
||||
# define LL_X86 1
|
||||
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
|
||||
# define LL_PPC 1
|
||||
@@ -202,6 +202,7 @@ namespace
|
||||
case 6: return "AMD K7";
|
||||
case 0xF: return "AMD K8";
|
||||
case 0x10: return "AMD K8L";
|
||||
case 0x15: return "AMD Bulldozer";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
@@ -418,8 +419,8 @@ static F64 calculate_cpu_frequency(U32 measure_msecs)
|
||||
HANDLE hThread = GetCurrentThread();
|
||||
unsigned long dwCurPriorityClass = GetPriorityClass(hProcess);
|
||||
int iCurThreadPriority = GetThreadPriority(hThread);
|
||||
unsigned long dwProcessMask, dwSystemMask, dwNewMask = 1;
|
||||
GetProcessAffinityMask(hProcess, (PDWORD_PTR)&dwProcessMask, (PDWORD_PTR)&dwSystemMask);
|
||||
DWORD_PTR dwProcessMask, dwSystemMask, dwNewMask = 1; // <alchemy/>
|
||||
GetProcessAffinityMask(hProcess, &dwProcessMask, &dwSystemMask);
|
||||
|
||||
SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS);
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Must turn on conditional declarations in header file so definitions end up
|
||||
// with proper linkage.
|
||||
#define LLSD_DEBUG_INFO
|
||||
#include "linden_common.h"
|
||||
#include "llsd.h"
|
||||
|
||||
@@ -31,6 +34,7 @@
|
||||
#include "../llmath/llmath.h"
|
||||
#include "llformat.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "stringize.h"
|
||||
|
||||
#ifndef LL_RELEASE_FOR_DOWNLOAD
|
||||
#define NAME_UNNAMED_NAMESPACE
|
||||
@@ -50,6 +54,18 @@ namespace
|
||||
using namespace LLSDUnnamedNamespace;
|
||||
#endif
|
||||
|
||||
namespace llsd
|
||||
{
|
||||
|
||||
// statics
|
||||
S32 sLLSDAllocationCount = 0;
|
||||
S32 sLLSDNetObjects = 0;
|
||||
|
||||
} // namespace llsd
|
||||
|
||||
#define ALLOC_LLSD_OBJECT { llsd::sLLSDNetObjects++; llsd::sLLSDAllocationCount++; }
|
||||
#define FREE_LLSD_OBJECT { llsd::sLLSDNetObjects--; }
|
||||
|
||||
class LLSD::Impl
|
||||
/**< This class is the abstract base class of the implementation of LLSD
|
||||
It provides the reference counting implementation, and the default
|
||||
@@ -58,13 +74,10 @@ class LLSD::Impl
|
||||
|
||||
*/
|
||||
{
|
||||
private:
|
||||
U32 mUseCount;
|
||||
|
||||
protected:
|
||||
Impl();
|
||||
|
||||
enum StaticAllocationMarker { STATIC };
|
||||
enum StaticAllocationMarker { STATIC_USAGE_COUNT = 0xFFFFFFFF };
|
||||
Impl(StaticAllocationMarker);
|
||||
///< This constructor is used for static objects and causes the
|
||||
// suppresses adjusting the debugging counters when they are
|
||||
@@ -72,8 +85,10 @@ protected:
|
||||
|
||||
virtual ~Impl();
|
||||
|
||||
bool shared() const { return mUseCount > 1; }
|
||||
bool shared() const { return (mUseCount > 1) && (mUseCount != STATIC_USAGE_COUNT); }
|
||||
|
||||
U32 mUseCount;
|
||||
|
||||
public:
|
||||
static void reset(Impl*& var, Impl* impl);
|
||||
///< safely set var to refer to the new impl (possibly shared)
|
||||
@@ -111,7 +126,9 @@ public:
|
||||
virtual UUID asUUID() const { return LLUUID(); }
|
||||
virtual Date asDate() const { return LLDate(); }
|
||||
virtual URI asURI() const { return LLURI(); }
|
||||
virtual Binary asBinary() const { return std::vector<U8>(); }
|
||||
virtual const Binary& asBinary() const { static const std::vector<U8> empty; return empty; }
|
||||
|
||||
virtual const String& asStringRef() const { static const std::string empty; return empty; }
|
||||
|
||||
virtual bool has(const String&) const { return false; }
|
||||
virtual LLSD get(const String&) const { return LLSD(); }
|
||||
@@ -128,6 +145,18 @@ public:
|
||||
virtual LLSD::array_const_iterator beginArray() const { return endArray(); }
|
||||
virtual LLSD::array_const_iterator endArray() const { static const std::vector<LLSD> empty; return empty.end(); }
|
||||
|
||||
virtual void dumpStats() const;
|
||||
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
|
||||
// Container subclasses contain LLSD objects, rather than directly
|
||||
// containing Impl objects. This helper forwards through LLSD.
|
||||
void calcStats(const LLSD& llsd, S32 type_counts[], S32 share_counts[]) const
|
||||
{
|
||||
safe(llsd.impl).calcStats(type_counts, share_counts);
|
||||
}
|
||||
|
||||
static const Impl& getImpl(const LLSD& llsd) { return safe(llsd.impl); }
|
||||
static Impl& getImpl(LLSD& llsd) { return safe(llsd.impl); }
|
||||
|
||||
static const LLSD& undef();
|
||||
|
||||
static U32 sAllocationCount;
|
||||
@@ -242,6 +271,8 @@ namespace
|
||||
virtual LLSD::UUID asUUID() const { return LLUUID(mValue); }
|
||||
virtual LLSD::Date asDate() const { return LLDate(mValue); }
|
||||
virtual LLSD::URI asURI() const { return LLURI(mValue); }
|
||||
virtual int size() const { return mValue.size(); }
|
||||
virtual const LLSD::String& asStringRef() const { return mValue; }
|
||||
};
|
||||
|
||||
LLSD::Integer ImplString::asInteger() const
|
||||
@@ -320,7 +351,7 @@ namespace
|
||||
public:
|
||||
ImplBinary(const LLSD::Binary& v) : Base(v) { }
|
||||
|
||||
virtual LLSD::Binary asBinary() const{ return mValue; }
|
||||
virtual const LLSD::Binary& asBinary() const{ return mValue; }
|
||||
};
|
||||
|
||||
|
||||
@@ -360,6 +391,9 @@ namespace
|
||||
LLSD::map_iterator endMap() { return mData.end(); }
|
||||
virtual LLSD::map_const_iterator beginMap() const { return mData.begin(); }
|
||||
virtual LLSD::map_const_iterator endMap() const { return mData.end(); }
|
||||
|
||||
virtual void dumpStats() const;
|
||||
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
|
||||
};
|
||||
|
||||
ImplMap& ImplMap::makeMap(LLSD::Impl*& var)
|
||||
@@ -414,6 +448,34 @@ namespace
|
||||
return i->second;
|
||||
}
|
||||
|
||||
void ImplMap::dumpStats() const
|
||||
{
|
||||
std::cout << "Map size: " << mData.size() << std::endl;
|
||||
|
||||
std::cout << "LLSD Net Objects: " << llsd::sLLSDNetObjects << std::endl;
|
||||
std::cout << "LLSD allocations: " << llsd::sLLSDAllocationCount << std::endl;
|
||||
|
||||
std::cout << "LLSD::Impl Net Objects: " << sOutstandingCount << std::endl;
|
||||
std::cout << "LLSD::Impl allocations: " << sAllocationCount << std::endl;
|
||||
|
||||
Impl::dumpStats();
|
||||
}
|
||||
|
||||
void ImplMap::calcStats(S32 type_counts[], S32 share_counts[]) const
|
||||
{
|
||||
LLSD::map_const_iterator iter = beginMap();
|
||||
while (iter != endMap())
|
||||
{
|
||||
//std::cout << " " << (*iter).first << ": " << (*iter).second << std::endl;
|
||||
Impl::calcStats((*iter).second, type_counts, share_counts);
|
||||
iter++;
|
||||
}
|
||||
|
||||
// Add in the values for this map
|
||||
Impl::calcStats(type_counts, share_counts);
|
||||
}
|
||||
|
||||
|
||||
class ImplArray : public LLSD::Impl
|
||||
{
|
||||
private:
|
||||
@@ -447,8 +509,12 @@ namespace
|
||||
|
||||
LLSD::array_iterator beginArray() { return mData.begin(); }
|
||||
LLSD::array_iterator endArray() { return mData.end(); }
|
||||
LLSD::reverse_array_iterator rbeginArray() { return mData.rbegin(); }
|
||||
LLSD::reverse_array_iterator rendArray() { return mData.rend(); }
|
||||
virtual LLSD::array_const_iterator beginArray() const { return mData.begin(); }
|
||||
virtual LLSD::array_const_iterator endArray() const { return mData.end(); }
|
||||
|
||||
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
|
||||
};
|
||||
|
||||
ImplArray& ImplArray::makeArray(Impl*& var)
|
||||
@@ -544,6 +610,19 @@ namespace
|
||||
|
||||
return mData[index];
|
||||
}
|
||||
|
||||
void ImplArray::calcStats(S32 type_counts[], S32 share_counts[]) const
|
||||
{
|
||||
LLSD::array_const_iterator iter = beginArray();
|
||||
while (iter != endArray())
|
||||
{ // Add values for all items held in the array
|
||||
Impl::calcStats((*iter), type_counts, share_counts);
|
||||
iter++;
|
||||
}
|
||||
|
||||
// Add in the values for this array
|
||||
Impl::calcStats(type_counts, share_counts);
|
||||
}
|
||||
}
|
||||
|
||||
LLSD::Impl::Impl()
|
||||
@@ -565,8 +644,11 @@ LLSD::Impl::~Impl()
|
||||
|
||||
void LLSD::Impl::reset(Impl*& var, Impl* impl)
|
||||
{
|
||||
if (impl) ++impl->mUseCount;
|
||||
if (var && --var->mUseCount == 0)
|
||||
if (impl && impl->mUseCount != STATIC_USAGE_COUNT)
|
||||
{
|
||||
++impl->mUseCount;
|
||||
}
|
||||
if (var && var->mUseCount != STATIC_USAGE_COUNT && --var->mUseCount == 0)
|
||||
{
|
||||
delete var;
|
||||
}
|
||||
@@ -575,13 +657,13 @@ void LLSD::Impl::reset(Impl*& var, Impl* impl)
|
||||
|
||||
LLSD::Impl& LLSD::Impl::safe(Impl* impl)
|
||||
{
|
||||
static Impl theUndefined(STATIC);
|
||||
static Impl theUndefined(STATIC_USAGE_COUNT);
|
||||
return impl ? *impl : theUndefined;
|
||||
}
|
||||
|
||||
const LLSD::Impl& LLSD::Impl::safe(const Impl* impl)
|
||||
{
|
||||
static Impl theUndefined(STATIC);
|
||||
static Impl theUndefined(STATIC_USAGE_COUNT);
|
||||
return impl ? *impl : theUndefined;
|
||||
}
|
||||
|
||||
@@ -657,6 +739,43 @@ const LLSD& LLSD::Impl::undef()
|
||||
return immutableUndefined;
|
||||
}
|
||||
|
||||
void LLSD::Impl::dumpStats() const
|
||||
{
|
||||
S32 type_counts[LLSD::TypeLLSDNumTypes + 1];
|
||||
memset(&type_counts, 0, sizeof(type_counts));
|
||||
|
||||
S32 share_counts[LLSD::TypeLLSDNumTypes + 1];
|
||||
memset(&share_counts, 0, sizeof(share_counts));
|
||||
|
||||
// Add info from all the values this object has
|
||||
calcStats(type_counts, share_counts);
|
||||
|
||||
S32 type_index = LLSD::TypeLLSDTypeBegin;
|
||||
while (type_index != LLSD::TypeLLSDTypeEnd)
|
||||
{
|
||||
std::cout << LLSD::typeString((LLSD::Type)type_index) << " type "
|
||||
<< type_counts[type_index] << " objects, "
|
||||
<< share_counts[type_index] << " shared"
|
||||
<< std::endl;
|
||||
type_index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLSD::Impl::calcStats(S32 type_counts[], S32 share_counts[]) const
|
||||
{
|
||||
S32 tp = S32(type());
|
||||
if (0 <= tp && tp < LLSD::TypeLLSDNumTypes)
|
||||
{
|
||||
type_counts[tp]++;
|
||||
if (shared())
|
||||
{
|
||||
share_counts[tp]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U32 LLSD::Impl::sAllocationCount = 0;
|
||||
U32 LLSD::Impl::sOutstandingCount = 0;
|
||||
|
||||
@@ -682,10 +801,10 @@ namespace
|
||||
}
|
||||
|
||||
|
||||
LLSD::LLSD() : impl(0) { }
|
||||
LLSD::~LLSD() { Impl::reset(impl, 0); }
|
||||
LLSD::LLSD() : impl(0) { ALLOC_LLSD_OBJECT; }
|
||||
LLSD::~LLSD() { FREE_LLSD_OBJECT; Impl::reset(impl, 0); }
|
||||
|
||||
LLSD::LLSD(const LLSD& other) : impl(0) { assign(other); }
|
||||
LLSD::LLSD(const LLSD& other) : impl(0) { ALLOC_LLSD_OBJECT; assign(other); }
|
||||
void LLSD::assign(const LLSD& other) { Impl::assign(impl, other.impl); }
|
||||
|
||||
|
||||
@@ -693,18 +812,18 @@ void LLSD::clear() { Impl::assignUndefined(impl); }
|
||||
|
||||
LLSD::Type LLSD::type() const { return safe(impl).type(); }
|
||||
|
||||
// Scaler Constructors
|
||||
LLSD::LLSD(Boolean v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(Integer v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(Real v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const UUID& v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const String& v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const Date& v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const URI& v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const Binary& v) : impl(0) { assign(v); }
|
||||
// Scalar Constructors
|
||||
LLSD::LLSD(Boolean v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(Integer v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(Real v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(const UUID& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(const String& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(const Date& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(const URI& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
LLSD::LLSD(const Binary& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
|
||||
// Convenience Constructors
|
||||
LLSD::LLSD(F32 v) : impl(0) { assign((Real)v); }
|
||||
LLSD::LLSD(F32 v) : impl(0) { ALLOC_LLSD_OBJECT; assign((Real)v); }
|
||||
|
||||
// Scalar Assignment
|
||||
void LLSD::assign(Boolean v) { safe(impl).assign(impl, v); }
|
||||
@@ -724,10 +843,12 @@ LLSD::String LLSD::asString() const { return safe(impl).asString(); }
|
||||
LLSD::UUID LLSD::asUUID() const { return safe(impl).asUUID(); }
|
||||
LLSD::Date LLSD::asDate() const { return safe(impl).asDate(); }
|
||||
LLSD::URI LLSD::asURI() const { return safe(impl).asURI(); }
|
||||
LLSD::Binary LLSD::asBinary() const { return safe(impl).asBinary(); }
|
||||
const LLSD::Binary& LLSD::asBinary() const { return safe(impl).asBinary(); }
|
||||
|
||||
const LLSD::String& LLSD::asStringRef() const { return safe(impl).asStringRef(); }
|
||||
|
||||
// const char * helpers
|
||||
LLSD::LLSD(const char* v) : impl(0) { assign(v); }
|
||||
LLSD::LLSD(const char* v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
|
||||
void LLSD::assign(const char* v)
|
||||
{
|
||||
if(v) assign(std::string(v));
|
||||
@@ -785,9 +906,6 @@ LLSD& LLSD::operator[](Integer i)
|
||||
const LLSD& LLSD::operator[](Integer i) const
|
||||
{ return safe(impl).ref(i); }
|
||||
|
||||
U32 LLSD::allocationCount() { return Impl::sAllocationCount; }
|
||||
U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; }
|
||||
|
||||
static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat)
|
||||
{
|
||||
// sStorage is used to hold the string representation of the llsd last
|
||||
@@ -802,15 +920,9 @@ static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat)
|
||||
{
|
||||
std::ostringstream out;
|
||||
if (useXMLFormat)
|
||||
{
|
||||
LLSDXMLStreamer xml_streamer(llsd);
|
||||
out << xml_streamer;
|
||||
}
|
||||
out << LLSDXMLStreamer(llsd);
|
||||
else
|
||||
{
|
||||
LLSDNotationStreamer notation_streamer(llsd);
|
||||
out << notation_streamer;
|
||||
}
|
||||
out << LLSDNotationStreamer(llsd);
|
||||
out_string = out.str();
|
||||
}
|
||||
int len = out_string.length();
|
||||
@@ -841,3 +953,41 @@ LLSD::array_iterator LLSD::beginArray() { return makeArray(impl).beginArray();
|
||||
LLSD::array_iterator LLSD::endArray() { return makeArray(impl).endArray(); }
|
||||
LLSD::array_const_iterator LLSD::beginArray() const{ return safe(impl).beginArray(); }
|
||||
LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray(); }
|
||||
|
||||
LLSD::reverse_array_iterator LLSD::rbeginArray() { return makeArray(impl).rbeginArray(); }
|
||||
LLSD::reverse_array_iterator LLSD::rendArray() { return makeArray(impl).rendArray(); }
|
||||
|
||||
namespace llsd
|
||||
{
|
||||
|
||||
U32 allocationCount() { return LLSD::Impl::sAllocationCount; }
|
||||
U32 outstandingCount() { return LLSD::Impl::sOutstandingCount; }
|
||||
|
||||
// Diagnostic dump of contents in an LLSD object
|
||||
void dumpStats(const LLSD& llsd) { LLSD::Impl::getImpl(llsd).dumpStats(); }
|
||||
|
||||
} // namespace llsd
|
||||
|
||||
// static
|
||||
std::string LLSD::typeString(Type type)
|
||||
{
|
||||
static const char * sTypeNameArray[] = {
|
||||
"Undefined",
|
||||
"Boolean",
|
||||
"Integer",
|
||||
"Real",
|
||||
"String",
|
||||
"UUID",
|
||||
"Date",
|
||||
"URI",
|
||||
"Binary",
|
||||
"Map",
|
||||
"Array"
|
||||
};
|
||||
|
||||
if (0 <= type && type < LL_ARRAY_SIZE(sTypeNameArray))
|
||||
{
|
||||
return sTypeNameArray[type];
|
||||
}
|
||||
return STRINGIZE("** invalid type value " << type);
|
||||
}
|
||||
|
||||
@@ -251,7 +251,10 @@ public:
|
||||
UUID asUUID() const;
|
||||
Date asDate() const;
|
||||
URI asURI() const;
|
||||
Binary asBinary() const;
|
||||
const Binary& asBinary() const;
|
||||
|
||||
// asStringRef on any non-string type will return a ref to an empty string.
|
||||
const String& asStringRef() const;
|
||||
|
||||
operator Boolean() const { return asBoolean(); }
|
||||
operator Integer() const { return asInteger(); }
|
||||
@@ -323,11 +326,15 @@ public:
|
||||
|
||||
typedef std::vector<LLSD>::iterator array_iterator;
|
||||
typedef std::vector<LLSD>::const_iterator array_const_iterator;
|
||||
typedef std::vector<LLSD>::reverse_iterator reverse_array_iterator;
|
||||
|
||||
array_iterator beginArray();
|
||||
array_iterator endArray();
|
||||
array_const_iterator beginArray() const;
|
||||
array_const_iterator endArray() const;
|
||||
|
||||
reverse_array_iterator rbeginArray();
|
||||
reverse_array_iterator rendArray();
|
||||
//@}
|
||||
|
||||
/** @name Type Testing */
|
||||
@@ -390,13 +397,7 @@ public:
|
||||
class Impl;
|
||||
private:
|
||||
Impl* impl;
|
||||
//@}
|
||||
|
||||
/** @name Unit Testing Interface */
|
||||
//@{
|
||||
public:
|
||||
static U32 allocationCount(); ///< how many Impls have been made
|
||||
static U32 outstandingCount(); ///< how many Impls are still alive
|
||||
friend class LLSD::Impl;
|
||||
//@}
|
||||
|
||||
private:
|
||||
@@ -408,6 +409,10 @@ private:
|
||||
/// Returns Notation version of llsd -- only to be called from debugger
|
||||
static const char *dump(const LLSD &llsd);
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
||||
static std::string typeString(Type type); // Return human-readable type as a string
|
||||
};
|
||||
|
||||
struct llsd_select_bool : public std::unary_function<LLSD, LLSD::Boolean>
|
||||
@@ -455,6 +460,29 @@ struct llsd_select_string : public std::unary_function<LLSD, LLSD::String>
|
||||
|
||||
LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLSD& llsd);
|
||||
|
||||
namespace llsd
|
||||
{
|
||||
|
||||
#ifdef LLSD_DEBUG_INFO
|
||||
/** @name Unit Testing Interface */
|
||||
//@{
|
||||
LL_COMMON_API void dumpStats(const LLSD&); ///< Output information on object and usage
|
||||
|
||||
/// @warn THE FOLLOWING COUNTS WILL NOT BE ACCURATE IN A MULTI-THREADED
|
||||
/// ENVIRONMENT.
|
||||
///
|
||||
/// These counts track LLSD::Impl (hidden) objects.
|
||||
LL_COMMON_API U32 allocationCount(); ///< how many Impls have been made
|
||||
LL_COMMON_API U32 outstandingCount(); ///< how many Impls are still alive
|
||||
|
||||
/// These counts track LLSD (public) objects.
|
||||
LL_COMMON_API extern S32 sLLSDAllocationCount; ///< Number of LLSD objects ever created
|
||||
LL_COMMON_API extern S32 sLLSDNetObjects; ///< Number of LLSD objects that exist
|
||||
#endif
|
||||
//@}
|
||||
|
||||
} // namespace llsd
|
||||
|
||||
/** QUESTIONS & TO DOS
|
||||
- Would Binary be more convenient as unsigned char* buffer semantics?
|
||||
- Should Binary be convertible to/from String, and if so how?
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// Project includes
|
||||
#include "llsdparam.h"
|
||||
#include "llsdutil.h"
|
||||
#include "boost/bind.hpp"
|
||||
|
||||
static LLInitParam::Parser::parser_read_func_map_t sReadFuncs;
|
||||
static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs;
|
||||
@@ -42,7 +43,8 @@ LLFastTimer::DeclareTimer FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion")
|
||||
// LLParamSDParser
|
||||
//
|
||||
LLParamSDParser::LLParamSDParser()
|
||||
: Parser(sReadFuncs, sWriteFuncs, sInspectFuncs)
|
||||
: Parser(sReadFuncs, sWriteFuncs, sInspectFuncs),
|
||||
mCurReadSD(NULL), mCurWriteSD(NULL), mWriteRootSD(NULL)
|
||||
{
|
||||
using boost::bind;
|
||||
|
||||
@@ -102,13 +104,13 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool
|
||||
//readSDValues(sd, block);
|
||||
}
|
||||
|
||||
void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block)
|
||||
void LLParamSDParser::writeSDImpl(LLSD& sd, const LLInitParam::BaseBlock& block, const LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block)
|
||||
{
|
||||
mNameStack.clear();
|
||||
mWriteRootSD = &sd;
|
||||
|
||||
name_stack_t name_stack;
|
||||
block.serializeBlock(*this, name_stack);
|
||||
block.serializeBlock(*this, name_stack, rules, diff_block);
|
||||
}
|
||||
|
||||
/*virtual*/ std::string LLParamSDParser::getCurrentElementName()
|
||||
@@ -329,13 +331,14 @@ namespace LLInitParam
|
||||
p.writeValue<LLSD::String>(sd.asString(), name_stack);
|
||||
}
|
||||
|
||||
void ParamValue<LLSD, NOT_BLOCK>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const
|
||||
bool ParamValue<LLSD, NOT_BLOCK>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack_range, const predicate_rule_t predicate_rule, const BaseBlock* diff_block) const
|
||||
{
|
||||
// attempt to write LLSD out directly
|
||||
if (!p.writeValue<LLSD>(mValue, name_stack))
|
||||
if (!p.writeValue<LLSD>(mValue, name_stack_range))
|
||||
{
|
||||
// otherwise read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc)
|
||||
LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, name_stack);
|
||||
LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, name_stack_range);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "llinitparam.h"
|
||||
#include "boost/function.hpp"
|
||||
#include "llfasttimer.h"
|
||||
|
||||
struct LL_COMMON_API LLParamSDParserUtilities
|
||||
{
|
||||
@@ -50,11 +51,28 @@ typedef LLInitParam::Parser parser_t;
|
||||
public:
|
||||
LLParamSDParser();
|
||||
void readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent = false);
|
||||
void writeSD(LLSD& sd, const LLInitParam::BaseBlock& block);
|
||||
template<typename BLOCK>
|
||||
void writeSD(LLSD& sd,
|
||||
const BLOCK& block,
|
||||
const LLInitParam::predicate_rule_t rules = LLInitParam::default_parse_rules(),
|
||||
const LLInitParam::BaseBlock* diff_block = NULL)
|
||||
{
|
||||
if (!diff_block
|
||||
&& !rules.isAmbivalent(LLInitParam::HAS_DEFAULT_VALUE))
|
||||
{
|
||||
diff_block = &LLInitParam::defaultValue<BLOCK>();
|
||||
}
|
||||
writeSDImpl(sd, block, rules, diff_block);
|
||||
}
|
||||
|
||||
/*virtual*/ std::string getCurrentElementName();
|
||||
|
||||
private:
|
||||
void writeSDImpl(LLSD& sd,
|
||||
const LLInitParam::BaseBlock& block,
|
||||
const LLInitParam::predicate_rule_t,
|
||||
const LLInitParam::BaseBlock* diff_block);
|
||||
|
||||
void submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack);
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
#include "llsdserialize.h"
|
||||
#include "llpointer.h"
|
||||
#include "llstreamtools.h" // for fullread
|
||||
#include "llbase64.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "apr_base64.h"
|
||||
|
||||
#ifdef LL_STANDALONE
|
||||
# include <zlib.h>
|
||||
@@ -43,6 +43,7 @@
|
||||
#if !LL_WINDOWS
|
||||
#include <netinet/in.h> // htonl & ntohl
|
||||
#endif
|
||||
#include "apr_general.h" // for strncasecmp
|
||||
|
||||
#include "lldate.h"
|
||||
#include "llsd.h"
|
||||
@@ -648,7 +649,7 @@ S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data) const
|
||||
default:
|
||||
parse_count = PARSE_FAILURE;
|
||||
llinfos << "Unrecognized character while parsing: int(" << (int)c
|
||||
<< ")" << llendl;
|
||||
<< ")" << LL_ENDL;
|
||||
break;
|
||||
}
|
||||
if(PARSE_FAILURE == parse_count)
|
||||
@@ -807,12 +808,12 @@ bool LLSDNotationParser::parseBinary(std::istream& istr, LLSD& data) const
|
||||
get(istr, *(coded_stream.rdbuf()), '\"');
|
||||
c = get(istr);
|
||||
std::string encoded(coded_stream.str());
|
||||
S32 len = apr_base64_decode_len(encoded.c_str());
|
||||
size_t len = LLBase64::requiredDecryptionSpace(encoded);
|
||||
std::vector<U8> value;
|
||||
if(len)
|
||||
{
|
||||
value.resize(len);
|
||||
len = apr_base64_decode_binary(&value[0], encoded.c_str());
|
||||
len = LLBase64::decode(encoded, &value[0], len);
|
||||
value.resize(len);
|
||||
}
|
||||
data = value;
|
||||
@@ -873,7 +874,7 @@ S32 LLSDBinaryParser::doParse(std::istream& istr, LLSD& data) const
|
||||
{
|
||||
/**
|
||||
* Undefined: '!'<br>
|
||||
* Boolean: 't' for true 'f' for false<br>
|
||||
* Boolean: '1' for true '0' for false<br>
|
||||
* Integer: 'i' + 4 bytes network byte order<br>
|
||||
* Real: 'r' + 8 bytes IEEE double<br>
|
||||
* UUID: 'u' + 16 byte unsigned integer<br>
|
||||
@@ -999,7 +1000,7 @@ S32 LLSDBinaryParser::doParse(std::istream& istr, LLSD& data) const
|
||||
if(istr.fail())
|
||||
{
|
||||
llinfos << "STREAM FAILURE reading binary (notation-style) string."
|
||||
<< llendl;
|
||||
<< LL_ENDL;
|
||||
parse_count = PARSE_FAILURE;
|
||||
}
|
||||
break;
|
||||
@@ -1088,7 +1089,7 @@ S32 LLSDBinaryParser::doParse(std::istream& istr, LLSD& data) const
|
||||
default:
|
||||
parse_count = PARSE_FAILURE;
|
||||
llinfos << "Unrecognized character while parsing: int(" << (int)c
|
||||
<< ")" << llendl;
|
||||
<< ")" << LL_ENDL;
|
||||
break;
|
||||
}
|
||||
if(PARSE_FAILURE == parse_count)
|
||||
@@ -1260,13 +1261,38 @@ std::string LLSDNotationFormatter::escapeString(const std::string& in)
|
||||
|
||||
// virtual
|
||||
S32 LLSDNotationFormatter::format(const LLSD& data, std::ostream& ostr, U32 options) const
|
||||
{
|
||||
S32 rv = format_impl(data, ostr, options, 0);
|
||||
return rv;
|
||||
}
|
||||
|
||||
S32 LLSDNotationFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const
|
||||
{
|
||||
S32 format_count = 1;
|
||||
std::string pre;
|
||||
std::string post;
|
||||
|
||||
if (options & LLSDFormatter::OPTIONS_PRETTY)
|
||||
{
|
||||
for (U32 i = 0; i < level; i++)
|
||||
{
|
||||
pre += " ";
|
||||
}
|
||||
post = "\n";
|
||||
}
|
||||
|
||||
switch(data.type())
|
||||
{
|
||||
case LLSD::TypeMap:
|
||||
{
|
||||
if (0 != level) ostr << post << pre;
|
||||
ostr << "{";
|
||||
std::string inner_pre;
|
||||
if (options & LLSDFormatter::OPTIONS_PRETTY)
|
||||
{
|
||||
inner_pre = pre + " ";
|
||||
}
|
||||
|
||||
bool need_comma = false;
|
||||
LLSD::map_const_iterator iter = data.beginMap();
|
||||
LLSD::map_const_iterator end = data.endMap();
|
||||
@@ -1274,18 +1300,18 @@ S32 LLSDNotationFormatter::format(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
{
|
||||
if(need_comma) ostr << ",";
|
||||
need_comma = true;
|
||||
ostr << '\'';
|
||||
ostr << post << inner_pre << '\'';
|
||||
serialize_string((*iter).first, ostr);
|
||||
ostr << "':";
|
||||
format_count += format((*iter).second, ostr);
|
||||
format_count += format_impl((*iter).second, ostr, options, level + 2);
|
||||
}
|
||||
ostr << "}";
|
||||
ostr << post << pre << "}";
|
||||
break;
|
||||
}
|
||||
|
||||
case LLSD::TypeArray:
|
||||
{
|
||||
ostr << "[";
|
||||
ostr << post << pre << "[";
|
||||
bool need_comma = false;
|
||||
LLSD::array_const_iterator iter = data.beginArray();
|
||||
LLSD::array_const_iterator end = data.endArray();
|
||||
@@ -1293,7 +1319,7 @@ S32 LLSDNotationFormatter::format(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
{
|
||||
if(need_comma) ostr << ",";
|
||||
need_comma = true;
|
||||
format_count += format(*iter, ostr);
|
||||
format_count += format_impl(*iter, ostr, options, level + 1);
|
||||
}
|
||||
ostr << "]";
|
||||
break;
|
||||
@@ -1343,7 +1369,7 @@ S32 LLSDNotationFormatter::format(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
|
||||
case LLSD::TypeString:
|
||||
ostr << '\'';
|
||||
serialize_string(data.asString(), ostr);
|
||||
serialize_string(data.asStringRef(), ostr);
|
||||
ostr << '\'';
|
||||
break;
|
||||
|
||||
@@ -1360,9 +1386,26 @@ S32 LLSDNotationFormatter::format(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
case LLSD::TypeBinary:
|
||||
{
|
||||
// *FIX: memory inefficient.
|
||||
std::vector<U8> buffer = data.asBinary();
|
||||
const std::vector<U8>& buffer = data.asBinary();
|
||||
ostr << "b(" << buffer.size() << ")\"";
|
||||
if(buffer.size()) ostr.write((const char*)&buffer[0], buffer.size());
|
||||
if(buffer.size())
|
||||
{
|
||||
if (options & LLSDFormatter::OPTIONS_PRETTY_BINARY)
|
||||
{
|
||||
std::ios_base::fmtflags old_flags = ostr.flags();
|
||||
ostr.setf( std::ios::hex, std::ios::basefield );
|
||||
ostr << "0x";
|
||||
for (size_t i = 0; i < buffer.size(); i++)
|
||||
{
|
||||
ostr << (int) buffer[i];
|
||||
}
|
||||
ostr.flags(old_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ostr.write((const char*)&buffer[0], buffer.size());
|
||||
}
|
||||
}
|
||||
ostr << "\"";
|
||||
break;
|
||||
}
|
||||
@@ -1460,7 +1503,7 @@ S32 LLSDBinaryFormatter::format(const LLSD& data, std::ostream& ostr, U32 option
|
||||
|
||||
case LLSD::TypeString:
|
||||
ostr.put('s');
|
||||
formatString(data.asString(), ostr);
|
||||
formatString(data.asStringRef(), ostr);
|
||||
break;
|
||||
|
||||
case LLSD::TypeDate:
|
||||
@@ -1478,9 +1521,8 @@ S32 LLSDBinaryFormatter::format(const LLSD& data, std::ostream& ostr, U32 option
|
||||
|
||||
case LLSD::TypeBinary:
|
||||
{
|
||||
// *FIX: memory inefficient.
|
||||
ostr.put('b');
|
||||
std::vector<U8> buffer = data.asBinary();
|
||||
const std::vector<U8>& buffer = data.asBinary();
|
||||
U32 size_nbo = htonl(buffer.size());
|
||||
ostr.write((const char*)(&size_nbo), sizeof(U32));
|
||||
if(buffer.size()) ostr.write((const char*)&buffer[0], buffer.size());
|
||||
@@ -2080,6 +2122,7 @@ std::string zip_llsd(LLSD& data)
|
||||
return result;
|
||||
}
|
||||
|
||||
// <alchemy>
|
||||
//decompress a block of LLSD from provided istream
|
||||
// not very efficient -- creats a copy of decompressed LLSD block in memory
|
||||
// and deserializes from that copy using LLSDSerialize
|
||||
@@ -2109,13 +2152,6 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
if (ret == Z_STREAM_ERROR)
|
||||
{
|
||||
inflateEnd(&strm);
|
||||
free(result);
|
||||
delete [] in;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
@@ -2123,6 +2159,7 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
|
||||
ret = Z_DATA_ERROR;
|
||||
case Z_DATA_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
case Z_STREAM_ERROR:
|
||||
inflateEnd(&strm);
|
||||
free(result);
|
||||
delete [] in;
|
||||
@@ -2172,6 +2209,7 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
|
||||
free(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
//This unzip function will only work with a gzip header and trailer - while the contents
|
||||
//of the actual compressed data is the same for either format (gzip vs zlib ), the headers
|
||||
//and trailers are different for the formats.
|
||||
@@ -2201,27 +2239,19 @@ U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize, std::istream& is, S32
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
if (ret == Z_STREAM_ERROR)
|
||||
{
|
||||
inflateEnd(&strm);
|
||||
free(result);
|
||||
delete [] in;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case Z_NEED_DICT:
|
||||
ret = Z_DATA_ERROR;
|
||||
case Z_DATA_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
case Z_STREAM_ERROR:
|
||||
inflateEnd(&strm);
|
||||
free(result);
|
||||
delete [] in;
|
||||
valid = false;
|
||||
break;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U32 have = CHUNK-strm.avail_out;
|
||||
|
||||
result = (U8*) realloc(result, cur_size + have);
|
||||
@@ -2248,5 +2278,5 @@ U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize, std::istream& is, S32
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// </alchemy>
|
||||
|
||||
|
||||
@@ -4,31 +4,25 @@
|
||||
* @date 2006-02-26
|
||||
* @brief Declaration of parsers and formatters for LLSD
|
||||
*
|
||||
* $LicenseInfo:firstyear=2006&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2006-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2006&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -306,7 +300,7 @@ public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
LLSDXMLParser();
|
||||
LLSDXMLParser(bool emit_errors=true);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -422,7 +416,8 @@ public:
|
||||
typedef enum e_formatter_options_type
|
||||
{
|
||||
OPTIONS_NONE = 0,
|
||||
OPTIONS_PRETTY = 1
|
||||
OPTIONS_PRETTY = 1,
|
||||
OPTIONS_PRETTY_BINARY = 2
|
||||
} EFormatterOptions;
|
||||
|
||||
/**
|
||||
@@ -513,6 +508,17 @@ public:
|
||||
* @return Returns The number of LLSD objects fomatted out
|
||||
*/
|
||||
virtual S32 format(const LLSD& data, std::ostream& ostr, U32 options = LLSDFormatter::OPTIONS_NONE) const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief Implementation to format the data. This is called recursively.
|
||||
*
|
||||
* @param data The data to write.
|
||||
* @param ostr The destination stream for the data.
|
||||
* @return Returns The number of LLSD objects fomatted out
|
||||
*/
|
||||
S32 format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -638,6 +644,11 @@ protected:
|
||||
* params << "[{'version':i1}," << LLSDOStreamer<LLSDNotationFormatter>(sd)
|
||||
* << "]";
|
||||
* </code>
|
||||
*
|
||||
* *NOTE - formerly this class inherited from its template parameter Formatter,
|
||||
* but all instantiations passed in LLRefCount subclasses. This conflicted with
|
||||
* the auto allocation intended for this class template (demonstrated in the
|
||||
* example above). -brad
|
||||
*/
|
||||
template <class Formatter>
|
||||
class LLSDOStreamer
|
||||
@@ -721,6 +732,18 @@ public:
|
||||
LLPointer<LLSDNotationFormatter> f = new LLSDNotationFormatter;
|
||||
return f->format(sd, str, LLSDFormatter::OPTIONS_NONE);
|
||||
}
|
||||
static S32 toPrettyNotation(const LLSD& sd, std::ostream& str)
|
||||
{
|
||||
LLPointer<LLSDNotationFormatter> f = new LLSDNotationFormatter;
|
||||
return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY);
|
||||
}
|
||||
static S32 toPrettyBinaryNotation(const LLSD& sd, std::ostream& str)
|
||||
{
|
||||
LLPointer<LLSDNotationFormatter> f = new LLSDNotationFormatter;
|
||||
return f->format(sd, str,
|
||||
LLSDFormatter::OPTIONS_PRETTY |
|
||||
LLSDFormatter::OPTIONS_PRETTY_BINARY);
|
||||
}
|
||||
static S32 fromNotation(LLSD& sd, std::istream& str, S32 max_bytes)
|
||||
{
|
||||
LLPointer<LLSDNotationParser> p = new LLSDNotationParser;
|
||||
@@ -748,25 +771,25 @@ public:
|
||||
return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY);
|
||||
}
|
||||
|
||||
static S32 fromXMLEmbedded(LLSD& sd, std::istream& str)
|
||||
static S32 fromXMLEmbedded(LLSD& sd, std::istream& str, bool emit_errors=true)
|
||||
{
|
||||
// no need for max_bytes since xml formatting is not
|
||||
// subvertable by bad sizes.
|
||||
LLPointer<LLSDXMLParser> p = new LLSDXMLParser;
|
||||
LLPointer<LLSDXMLParser> p = new LLSDXMLParser(emit_errors);
|
||||
return p->parse(str, sd, LLSDSerialize::SIZE_UNLIMITED);
|
||||
}
|
||||
// Line oriented parser, 30% faster than fromXML(), but can
|
||||
// only be used when you know you have the complete XML
|
||||
// document available in the stream.
|
||||
static S32 fromXMLDocument(LLSD& sd, std::istream& str)
|
||||
static S32 fromXMLDocument(LLSD& sd, std::istream& str, bool emit_errors=true)
|
||||
{
|
||||
LLPointer<LLSDXMLParser> p = new LLSDXMLParser();
|
||||
LLPointer<LLSDXMLParser> p = new LLSDXMLParser(emit_errors);
|
||||
return p->parseLines(str, sd);
|
||||
}
|
||||
static S32 fromXML(LLSD& sd, std::istream& str)
|
||||
static S32 fromXML(LLSD& sd, std::istream& str, bool emit_errors=true)
|
||||
{
|
||||
return fromXMLEmbedded(sd, str);
|
||||
// return fromXMLDocument(sd, str);
|
||||
return fromXMLEmbedded(sd, str, emit_errors);
|
||||
// return fromXMLDocument(sd, str, emit_errors);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llsdserialize_xml.h"
|
||||
#include "llbase64.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
|
||||
#include "apr_base64.h"
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
extern "C"
|
||||
@@ -133,11 +133,7 @@ S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
case LLSD::TypeBoolean:
|
||||
ostr << pre << "<boolean>";
|
||||
if(mBoolAlpha ||
|
||||
#if( LL_WINDOWS || __GNUC__ > 2)
|
||||
(ostr.flags() & std::ios::boolalpha)
|
||||
#else
|
||||
(ostr.flags() & 0x0100)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
ostr << (data.asBoolean() ? "true" : "false");
|
||||
@@ -172,8 +168,8 @@ S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
break;
|
||||
|
||||
case LLSD::TypeString:
|
||||
if(data.asString().empty()) ostr << pre << "<string />" << post;
|
||||
else ostr << pre << "<string>" << escapeString(data.asString()) <<"</string>" << post;
|
||||
if(data.asStringRef().empty()) ostr << pre << "<string />" << post;
|
||||
else ostr << pre << "<string>" << escapeString(data.asStringRef()) <<"</string>" << post;
|
||||
break;
|
||||
|
||||
case LLSD::TypeDate:
|
||||
@@ -186,24 +182,15 @@ S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 opti
|
||||
|
||||
case LLSD::TypeBinary:
|
||||
{
|
||||
LLSD::Binary buffer = data.asBinary();
|
||||
const LLSD::Binary& buffer = data.asBinary();
|
||||
if(buffer.empty())
|
||||
{
|
||||
ostr << pre << "<binary />" << post;
|
||||
}
|
||||
else
|
||||
{
|
||||
// *FIX: memory inefficient.
|
||||
// *TODO: convert to use LLBase64
|
||||
ostr << pre << "<binary encoding=\"base64\">";
|
||||
int b64_buffer_length = apr_base64_encode_len(buffer.size());
|
||||
char* b64_buffer = new char[b64_buffer_length];
|
||||
b64_buffer_length = apr_base64_encode_binary(
|
||||
b64_buffer,
|
||||
&buffer[0],
|
||||
buffer.size());
|
||||
ostr.write(b64_buffer, b64_buffer_length - 1);
|
||||
delete[] b64_buffer;
|
||||
ostr << LLBase64::encode(&buffer[0], buffer.size());
|
||||
ostr << "</binary>" << post;
|
||||
}
|
||||
break;
|
||||
@@ -254,7 +241,7 @@ std::string LLSDXMLFormatter::escapeString(const std::string& in)
|
||||
class LLSDXMLParser::Impl
|
||||
{
|
||||
public:
|
||||
Impl();
|
||||
Impl(bool emit_errors);
|
||||
~Impl();
|
||||
|
||||
S32 parse(std::istream& input, LLSD& data);
|
||||
@@ -298,6 +285,7 @@ private:
|
||||
|
||||
static const XML_Char* findAttribute(const XML_Char* name, const XML_Char** pairs);
|
||||
|
||||
bool mEmitErrors;
|
||||
|
||||
XML_Parser mParser;
|
||||
|
||||
@@ -319,7 +307,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
LLSDXMLParser::Impl::Impl()
|
||||
LLSDXMLParser::Impl::Impl(bool emit_errors)
|
||||
: mEmitErrors(emit_errors)
|
||||
{
|
||||
mParser = XML_ParserCreate(NULL);
|
||||
reset();
|
||||
@@ -348,9 +337,10 @@ void clear_eol(std::istream& input)
|
||||
static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize)
|
||||
{
|
||||
unsigned count = 0;
|
||||
char c;
|
||||
while (count < bufsize && input.good())
|
||||
{
|
||||
char c = input.get();
|
||||
input.get(c);
|
||||
buf[count++] = c;
|
||||
if (is_eol(c))
|
||||
break;
|
||||
@@ -377,13 +367,10 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data)
|
||||
{
|
||||
break;
|
||||
}
|
||||
count = get_till_eol(input, (char *)buffer, BUFFER_SIZE);
|
||||
if (!count)
|
||||
{
|
||||
|
||||
count = get_till_eol(input, (char *)buffer, BUFFER_SIZE);
|
||||
if (!count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
status = XML_ParseBuffer(mParser, count, false);
|
||||
|
||||
@@ -406,7 +393,10 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data)
|
||||
{
|
||||
((char*) buffer)[count ? count - 1 : 0] = '\0';
|
||||
}
|
||||
llinfos << "LLSDXMLParser::Impl::parse: XML_STATUS_ERROR parsing:" << (char*) buffer << llendl;
|
||||
if (mEmitErrors)
|
||||
{
|
||||
llinfos << "LLSDXMLParser::Impl::parse: XML_STATUS_ERROR parsing:" << (char*) buffer << llendl;
|
||||
}
|
||||
data = LLSD();
|
||||
return LLSDParser::PARSE_FAILURE;
|
||||
}
|
||||
@@ -484,7 +474,10 @@ S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data)
|
||||
if (status == XML_STATUS_ERROR
|
||||
&& !mGracefullStop)
|
||||
{
|
||||
llinfos << "LLSDXMLParser::Impl::parseLines: XML_STATUS_ERROR" << llendl;
|
||||
if (mEmitErrors)
|
||||
{
|
||||
llinfos << "LLSDXMLParser::Impl::parseLines: XML_STATUS_ERROR" << llendl;
|
||||
}
|
||||
return LLSDParser::PARSE_FAILURE;
|
||||
}
|
||||
|
||||
@@ -508,12 +501,7 @@ void LLSDXMLParser::Impl::reset()
|
||||
|
||||
mSkipping = false;
|
||||
|
||||
#if( LL_WINDOWS || __GNUC__ > 2)
|
||||
mCurrentKey.clear();
|
||||
#else
|
||||
mCurrentKey = std::string();
|
||||
#endif
|
||||
|
||||
|
||||
XML_ParserReset(mParser, "utf-8");
|
||||
XML_SetUserData(mParser, this);
|
||||
@@ -641,11 +629,7 @@ void LLSDXMLParser::Impl::startElementHandler(const XML_Char* name, const XML_Ch
|
||||
LLSD& newElement = map[mCurrentKey];
|
||||
mStack.push_back(&newElement);
|
||||
|
||||
#if( LL_WINDOWS || __GNUC__ > 2)
|
||||
mCurrentKey.clear();
|
||||
#else
|
||||
mCurrentKey = std::string();
|
||||
#endif
|
||||
}
|
||||
else if (mStack.back()->isArray())
|
||||
{
|
||||
@@ -787,10 +771,10 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name)
|
||||
boost::regex r;
|
||||
r.assign("\\s");
|
||||
std::string stripped = boost::regex_replace(mCurrentContent, r, "");
|
||||
S32 len = apr_base64_decode_len(stripped.c_str());
|
||||
size_t len = LLBase64::requiredDecryptionSpace(stripped);
|
||||
std::vector<U8> data;
|
||||
data.resize(len);
|
||||
len = apr_base64_decode_binary(&data[0], stripped.c_str());
|
||||
len = LLBase64::decode(stripped, &data[0], len);
|
||||
data.resize(len);
|
||||
value = data;
|
||||
break;
|
||||
@@ -910,7 +894,7 @@ LLSDXMLParser::Impl::Element LLSDXMLParser::Impl::readElement(const XML_Char* na
|
||||
/**
|
||||
* LLSDXMLParser
|
||||
*/
|
||||
LLSDXMLParser::LLSDXMLParser() : impl(* new Impl)
|
||||
LLSDXMLParser::LLSDXMLParser(bool emit_errors /* = true */) : impl(* new Impl(emit_errors))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,31 +4,25 @@
|
||||
* @date 2006-05-24
|
||||
* @brief Implementation of classes, functions, etc, for using structured data.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2006&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2006-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2006&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -188,7 +182,7 @@ char* ll_pretty_print_sd_ptr(const LLSD* sd)
|
||||
|
||||
char* ll_pretty_print_sd(const LLSD& sd)
|
||||
{
|
||||
const U32 bufferSize = 10 * 1024;
|
||||
const U32 bufferSize = 100 * 1024;
|
||||
static char buffer[bufferSize];
|
||||
std::ostringstream stream;
|
||||
//stream.rdbuf()->pubsetbuf(buffer, bufferSize);
|
||||
@@ -578,7 +572,7 @@ std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::str
|
||||
return match_types(prototype.type(), TypeVector(), data.type(), pfx);
|
||||
}
|
||||
|
||||
bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits)
|
||||
bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits)
|
||||
{
|
||||
// We're comparing strict equality of LLSD representation rather than
|
||||
// performing any conversions. So if the types aren't equal, the LLSD
|
||||
@@ -598,7 +592,7 @@ bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits)
|
||||
case LLSD::TypeReal:
|
||||
// This is where the 'bits' argument comes in handy. If passed
|
||||
// explicitly, it means to use is_approx_equal_fraction() to compare.
|
||||
if (bits != -1)
|
||||
if (bits >= 0)
|
||||
{
|
||||
return is_approx_equal_fraction(lhs.asReal(), rhs.asReal(), bits);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#ifndef LL_LLSDUTIL_H
|
||||
#define LL_LLSDUTIL_H
|
||||
|
||||
class LLSD;
|
||||
#include "llsd.h"
|
||||
|
||||
// U32
|
||||
LL_COMMON_API LLSD ll_sd_from_U32(const U32);
|
||||
@@ -126,7 +126,7 @@ LL_COMMON_API std::string llsd_matches(const LLSD& prototype, const LLSD& data,
|
||||
/// Deep equality. If you want to compare LLSD::Real values for approximate
|
||||
/// equality rather than bitwise equality, pass @a bits as for
|
||||
/// is_approx_equal_fraction().
|
||||
LL_COMMON_API bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits=-1);
|
||||
LL_COMMON_API bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits=-1);
|
||||
|
||||
// Simple function to copy data out of input & output iterators if
|
||||
// there is no need for casting.
|
||||
|
||||
@@ -102,10 +102,10 @@ private:
|
||||
// stores pointer to singleton instance
|
||||
struct SingletonLifetimeManager
|
||||
{
|
||||
SingletonLifetimeManager()
|
||||
/*SingletonLifetimeManager()
|
||||
{
|
||||
construct();
|
||||
}
|
||||
}*/
|
||||
|
||||
static void construct()
|
||||
{
|
||||
@@ -115,14 +115,14 @@ private:
|
||||
sData.mInitState = INITIALIZING;
|
||||
}
|
||||
|
||||
~SingletonLifetimeManager()
|
||||
/*~SingletonLifetimeManager()
|
||||
{
|
||||
SingletonData& sData(getData());
|
||||
if (sData.mInitState != DELETED)
|
||||
{
|
||||
deleteSingleton();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -178,33 +178,28 @@ public:
|
||||
|
||||
static DERIVED_TYPE* getInstance()
|
||||
{
|
||||
static SingletonLifetimeManager sLifeTimeMgr;
|
||||
//static SingletonLifetimeManager sLifeTimeMgr;
|
||||
SingletonData& sData(getData());
|
||||
|
||||
switch (sData.mInitState)
|
||||
{
|
||||
case UNINITIALIZED:
|
||||
// should never be uninitialized at this point
|
||||
llassert(false);
|
||||
return NULL;
|
||||
case CONSTRUCTING:
|
||||
llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << LL_ENDL;
|
||||
return NULL;
|
||||
case INITIALIZING:
|
||||
// go ahead and flag ourselves as initialized so we can be reentrant during initialization
|
||||
sData.mInitState = INITIALIZED;
|
||||
// initialize singleton after constructing it so that it can reference other singletons which in turn depend on it,
|
||||
// thus breaking cyclic dependencies
|
||||
sData.mInstance->initSingleton();
|
||||
llwarns << "Using singleton " << typeid(DERIVED_TYPE).name() << " during its own initialization, before its initialization completed!" << LL_ENDL;
|
||||
return sData.mInstance;
|
||||
case INITIALIZED:
|
||||
return sData.mInstance;
|
||||
case DELETED:
|
||||
llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << LL_ENDL;
|
||||
case UNINITIALIZED:
|
||||
// This must be the first time we get here.
|
||||
SingletonLifetimeManager::construct();
|
||||
// same as first time construction
|
||||
sData.mInitState = INITIALIZED;
|
||||
// Singu note: LL sets the state to INITIALIZED here *already* - which avoids the warning below, but is clearly total bullshit.
|
||||
sData.mInstance->initSingleton();
|
||||
sData.mInitState = INITIALIZED;
|
||||
return sData.mInstance;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "llprocessor.h"
|
||||
#include "llerrorcontrol.h"
|
||||
#include "llevents.h"
|
||||
#include "llformat.h"
|
||||
#include "lltimer.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llsdutil.h"
|
||||
@@ -80,6 +81,7 @@ using namespace llsd;
|
||||
# include <sys/sysinfo.h>
|
||||
# include <stdexcept>
|
||||
const char MEMINFO_FILE[] = "/proc/meminfo";
|
||||
# include <gnu/libc-version.h>
|
||||
#elif LL_SOLARIS
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
@@ -107,6 +109,9 @@ static const F32 MEM_INFO_THROTTLE = 20;
|
||||
static const F32 MEM_INFO_WINDOW = 10*60;
|
||||
|
||||
#if LL_WINDOWS
|
||||
// We cannot trust GetVersionEx function on Win8.1 , we should check this value when creating OS string
|
||||
static const U32 WINNT_WINBLUE = 0x0603;
|
||||
|
||||
#ifndef DLLVERSIONINFO
|
||||
typedef struct _DllVersionInfo
|
||||
{
|
||||
@@ -175,13 +180,67 @@ bool get_shell32_dll_version(DWORD& major, DWORD& minor, DWORD& build_number)
|
||||
}
|
||||
#endif // LL_WINDOWS
|
||||
|
||||
// Wrap boost::regex_match() with a function that doesn't throw.
|
||||
template <typename S, typename M, typename R>
|
||||
static bool regex_match_no_exc(const S& string, M& match, const R& regex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::regex_match(string, match, regex);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
LL_WARNS("LLMemoryInfo") << "error matching with '" << regex.str() << "': "
|
||||
<< e.what() << ":\n'" << string << "'" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap boost::regex_search() with a function that doesn't throw.
|
||||
template <typename S, typename M, typename R>
|
||||
static bool regex_search_no_exc(const S& string, M& match, const R& regex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::regex_search(string, match, regex);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
LL_WARNS("LLMemoryInfo") << "error searching with '" << regex.str() << "': "
|
||||
<< e.what() << ":\n'" << string << "'" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if LL_WINDOWS
|
||||
// GetVersionEx should not works correct with Windows 8.1 and the later version. We need to check this case
|
||||
static bool check_for_version(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
|
||||
{
|
||||
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
|
||||
DWORDLONG const dwlConditionMask = VerSetConditionMask(
|
||||
VerSetConditionMask(
|
||||
VerSetConditionMask(
|
||||
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||
VER_MINORVERSION, VER_GREATER_EQUAL),
|
||||
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||
|
||||
osvi.dwMajorVersion = wMajorVersion;
|
||||
osvi.dwMinorVersion = wMinorVersion;
|
||||
osvi.wServicePackMajor = wServicePackMajor;
|
||||
|
||||
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
LLOSInfo::LLOSInfo() :
|
||||
mMajorVer(0), mMinorVer(0), mBuild(0)
|
||||
mMajorVer(0), mMinorVer(0), mBuild(0), mOSVersionString("")
|
||||
{
|
||||
|
||||
#if LL_WINDOWS
|
||||
OSVERSIONINFOEX osvi;
|
||||
BOOL bOsVersionInfoEx;
|
||||
BOOL bShouldUseShellVersion = false;
|
||||
|
||||
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
@@ -244,10 +303,18 @@ LLOSInfo::LLOSInfo() :
|
||||
}
|
||||
else if(osvi.dwMinorVersion == 2)
|
||||
{
|
||||
if (check_for_version(HIBYTE(WINNT_WINBLUE), LOBYTE(WINNT_WINBLUE), 0))
|
||||
{
|
||||
mOSStringSimple = "Microsoft Windows 8.1 ";
|
||||
bShouldUseShellVersion = true; // GetVersionEx failed, going to use shell version
|
||||
}
|
||||
else
|
||||
{
|
||||
if(osvi.wProductType == VER_NT_WORKSTATION)
|
||||
mOSStringSimple = "Microsoft Windows 8 ";
|
||||
else
|
||||
mOSStringSimple = "Windows Server 2012 ";
|
||||
}
|
||||
}
|
||||
|
||||
///get native system info if available..
|
||||
@@ -314,9 +381,8 @@ LLOSInfo::LLOSInfo() :
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpstr = llformat("%s (Build %d)",
|
||||
csdversion.c_str(),
|
||||
(osvi.dwBuildNumber & 0xffff));
|
||||
tmpstr = !bShouldUseShellVersion ? llformat("%s (Build %d)", csdversion.c_str(), (osvi.dwBuildNumber & 0xffff)):
|
||||
llformat("%s (Build %d)", csdversion.c_str(), shell32_build);
|
||||
}
|
||||
|
||||
mOSString = mOSStringSimple + tmpstr;
|
||||
@@ -352,7 +418,7 @@ LLOSInfo::LLOSInfo() :
|
||||
std::string compatibility_mode;
|
||||
if(got_shell32_version)
|
||||
{
|
||||
if(osvi.dwMajorVersion != shell32_major || osvi.dwMinorVersion != shell32_minor)
|
||||
if((osvi.dwMajorVersion != shell32_major || osvi.dwMinorVersion != shell32_minor) && !bShouldUseShellVersion)
|
||||
{
|
||||
compatibility_mode = llformat(" compatibility mode. real ver: %d.%d (Build %d)",
|
||||
shell32_major,
|
||||
@@ -412,6 +478,102 @@ LLOSInfo::LLOSInfo() :
|
||||
mOSString = mOSStringSimple;
|
||||
}
|
||||
|
||||
#elif LL_LINUX
|
||||
|
||||
struct utsname un;
|
||||
if(uname(&un) != -1)
|
||||
{
|
||||
mOSStringSimple.append(un.sysname);
|
||||
mOSStringSimple.append(" ");
|
||||
mOSStringSimple.append(un.release);
|
||||
|
||||
mOSString = mOSStringSimple;
|
||||
mOSString.append(" ");
|
||||
mOSString.append(un.version);
|
||||
mOSString.append(" ");
|
||||
mOSString.append(un.machine);
|
||||
|
||||
// Simplify 'Simple'
|
||||
std::string ostype = mOSStringSimple.substr(0, mOSStringSimple.find_first_of(" ", 0));
|
||||
if (ostype == "Linux")
|
||||
{
|
||||
// Only care about major and minor Linux versions, truncate at second '.'
|
||||
std::string::size_type idx1 = mOSStringSimple.find_first_of(".", 0);
|
||||
std::string::size_type idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos;
|
||||
std::string simple = mOSStringSimple.substr(0, idx2);
|
||||
if (simple.length() > 0)
|
||||
mOSStringSimple = simple;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mOSStringSimple.append("Unable to collect OS info");
|
||||
mOSString = mOSStringSimple;
|
||||
}
|
||||
|
||||
const char OS_VERSION_MATCH_EXPRESSION[] = "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?";
|
||||
boost::regex os_version_parse(OS_VERSION_MATCH_EXPRESSION);
|
||||
boost::smatch matched;
|
||||
|
||||
std::string glibc_version(gnu_get_libc_version());
|
||||
if ( regex_match_no_exc(glibc_version, matched, os_version_parse) )
|
||||
{
|
||||
LL_INFOS("AppInit") << "Using glibc version '" << glibc_version << "' as OS version" << LL_ENDL;
|
||||
|
||||
std::string version_value;
|
||||
|
||||
if ( matched[1].matched ) // Major version
|
||||
{
|
||||
version_value.assign(matched[1].first, matched[1].second);
|
||||
if (sscanf(version_value.c_str(), "%d", &mMajorVer) != 1)
|
||||
{
|
||||
LL_WARNS("AppInit") << "failed to parse major version '" << version_value << "' as a number" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_ERRS("AppInit")
|
||||
<< "OS version regex '" << OS_VERSION_MATCH_EXPRESSION
|
||||
<< "' returned true, but major version [1] did not match"
|
||||
<< LL_ENDL;
|
||||
}
|
||||
|
||||
if ( matched[2].matched ) // Minor version
|
||||
{
|
||||
version_value.assign(matched[2].first, matched[2].second);
|
||||
if (sscanf(version_value.c_str(), "%d", &mMinorVer) != 1)
|
||||
{
|
||||
LL_ERRS("AppInit") << "failed to parse minor version '" << version_value << "' as a number" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_ERRS("AppInit")
|
||||
<< "OS version regex '" << OS_VERSION_MATCH_EXPRESSION
|
||||
<< "' returned true, but minor version [1] did not match"
|
||||
<< LL_ENDL;
|
||||
}
|
||||
|
||||
if ( matched[4].matched ) // Build version (optional) - note that [3] includes the '.'
|
||||
{
|
||||
version_value.assign(matched[4].first, matched[4].second);
|
||||
if (sscanf(version_value.c_str(), "%d", &mBuild) != 1)
|
||||
{
|
||||
LL_ERRS("AppInit") << "failed to parse build version '" << version_value << "' as a number" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_INFOS("AppInit")
|
||||
<< "OS build version not provided; using zero"
|
||||
<< LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("AppInit") << "glibc version '" << glibc_version << "' cannot be parsed to three numbers; using all zeros" << LL_ENDL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct utsname un;
|
||||
@@ -444,8 +606,13 @@ LLOSInfo::LLOSInfo() :
|
||||
mOSStringSimple.append("Unable to collect OS info");
|
||||
mOSString = mOSStringSimple;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::stringstream dotted_version_string;
|
||||
dotted_version_string << mMajorVer << "." << mMinorVer << "." << mBuild;
|
||||
mOSVersionString.append(dotted_version_string.str());
|
||||
|
||||
}
|
||||
|
||||
#ifndef LL_WINDOWS
|
||||
@@ -496,6 +663,11 @@ const std::string& LLOSInfo::getOSStringSimple() const
|
||||
return mOSStringSimple;
|
||||
}
|
||||
|
||||
const std::string& LLOSInfo::getOSVersionString() const
|
||||
{
|
||||
return mOSVersionString;
|
||||
}
|
||||
|
||||
const S32 STATUS_SIZE = 8192;
|
||||
|
||||
//static
|
||||
@@ -687,38 +859,6 @@ private:
|
||||
LLSD mStats;
|
||||
};
|
||||
|
||||
// Wrap boost::regex_match() with a function that doesn't throw.
|
||||
template <typename S, typename M, typename R>
|
||||
static bool regex_match_no_exc(const S& string, M& match, const R& regex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::regex_match(string, match, regex);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
LL_WARNS("LLMemoryInfo") << "error matching with '" << regex.str() << "': "
|
||||
<< e.what() << ":\n'" << string << "'" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap boost::regex_search() with a function that doesn't throw.
|
||||
template <typename S, typename M, typename R>
|
||||
static bool regex_search_no_exc(const S& string, M& match, const R& regex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::regex_search(string, match, regex);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
LL_WARNS("LLMemoryInfo") << "error searching with '" << regex.str() << "': "
|
||||
<< e.what() << ":\n'" << string << "'" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LLMemoryInfo::LLMemoryInfo()
|
||||
{
|
||||
refresh();
|
||||
@@ -1288,9 +1428,14 @@ public:
|
||||
LL_CONT << "slowest framerate for last " << int(prevSize * MEM_INFO_THROTTLE)
|
||||
<< " seconds ";
|
||||
}
|
||||
LL_CONT << std::fixed << std::setprecision(1) << framerate << std::setprecision(6) << '\n'
|
||||
<< LLMemoryInfo() << LL_ENDL;
|
||||
|
||||
std::streamsize precision = LL_CONT.precision(); // <alchemy/>
|
||||
|
||||
LL_CONT << std::fixed << std::setprecision(1) << framerate << '\n'
|
||||
<< LLMemoryInfo();
|
||||
|
||||
LL_CONT.precision(precision);
|
||||
LL_CONT << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
// use an LLCPUInfo object:
|
||||
//
|
||||
// LLCPUInfo info;
|
||||
// llinfos << info << llendl;
|
||||
// LL_INFOS() << info << LL_ENDL;
|
||||
//
|
||||
|
||||
#include "llsd.h"
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
@@ -48,6 +49,8 @@ public:
|
||||
const std::string& getOSString() const;
|
||||
const std::string& getOSStringSimple() const;
|
||||
|
||||
const std::string& getOSVersionString() const;
|
||||
|
||||
S32 mMajorVer;
|
||||
S32 mMinorVer;
|
||||
S32 mBuild;
|
||||
@@ -61,6 +64,7 @@ public:
|
||||
private:
|
||||
std::string mOSString;
|
||||
std::string mOSStringSimple;
|
||||
std::string mOSVersionString;
|
||||
};
|
||||
|
||||
|
||||
@@ -101,7 +105,7 @@ class LL_COMMON_API LLMemoryInfo
|
||||
Here's how you use an LLMemoryInfo:
|
||||
|
||||
LLMemoryInfo info;
|
||||
<br> llinfos << info << llendl;
|
||||
<br> LL_INFOS() << info << LL_ENDL;
|
||||
*/
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -201,7 +201,7 @@ protected:
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
typedef boost::recursive_mutex LLMutexImpl;
|
||||
typedef boost::condition_variable_any LLConditionVariableImpl;
|
||||
#elif defined(USE_STD_MUTEX) && (__cplusplus >= 201103L || _MSC_VER >= 1800)
|
||||
#elif defined(USE_STD_MUTEX) && LL_CPP11
|
||||
#include <mutex>
|
||||
typedef std::recursive_mutex LLMutexImpl;
|
||||
typedef std::condition_variable_any LLConditionVariableImpl;
|
||||
@@ -224,6 +224,7 @@ typedef apr_thread_cond_t* impl_cond_handle_type;
|
||||
#define NEEDS_MUTEX_RECURSION
|
||||
//END
|
||||
#endif
|
||||
#include "llfasttimer.h"
|
||||
|
||||
#ifdef NEEDS_MUTEX_IMPL
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#include "u64.h"
|
||||
|
||||
#include "lldate.h"
|
||||
|
||||
#if LL_WINDOWS
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <winsock2.h>
|
||||
@@ -192,7 +190,7 @@ U64 get_clock_count()
|
||||
return clock_count.QuadPart - offset;
|
||||
}
|
||||
|
||||
F64 calc_clock_frequency(void)
|
||||
F64 calc_clock_frequency()
|
||||
{
|
||||
__int64 freq;
|
||||
QueryPerformanceFrequency((LARGE_INTEGER *) &freq);
|
||||
@@ -203,9 +201,9 @@ F64 calc_clock_frequency(void)
|
||||
|
||||
#if LL_LINUX || LL_DARWIN || LL_SOLARIS
|
||||
// Both Linux and Mac use gettimeofday for accurate time
|
||||
F64 calc_clock_frequency(void)
|
||||
F64 calc_clock_frequency()
|
||||
{
|
||||
return 1000000.0; // microseconds, so 1 Mhz.
|
||||
return 1000000.0; // microseconds, so 1 MHz.
|
||||
}
|
||||
|
||||
U64 get_clock_count()
|
||||
@@ -229,7 +227,7 @@ void update_clock_frequencies()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// returns a U64 number that represents the number of
|
||||
// microseconds since the unix epoch - Jan 1, 1970
|
||||
// microseconds since the Unix epoch - Jan 1, 1970
|
||||
U64 totalTime()
|
||||
{
|
||||
U64 current_clock_count = get_clock_count();
|
||||
@@ -450,7 +448,7 @@ BOOL LLTimer::knownBadTimer()
|
||||
{
|
||||
if (!wcscmp(pci_id, bad_pci_list[check]))
|
||||
{
|
||||
// llwarns << "unreliable PCI chipset found!! " << pci_id << endl;
|
||||
// LL_WARNS() << "unreliable PCI chipset found!! " << pci_id << endl;
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -569,6 +567,3 @@ void timeStructToFormattedString(struct tm * time, std::string format, std::stri
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
protected:
|
||||
U64 mLastClockCount;
|
||||
U64 mExpirationTicks;
|
||||
BOOL mStarted;
|
||||
bool mStarted;
|
||||
|
||||
public:
|
||||
LLTimer();
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
F32 getElapsedTimeF32() const; // Returns elapsed time in seconds
|
||||
F64 getElapsedTimeF64() const; // Returns elapsed time in seconds
|
||||
|
||||
BOOL getStarted() const { return mStarted; }
|
||||
bool getStarted() const { return mStarted; }
|
||||
|
||||
|
||||
static U64 getCurrentClockCount(); // Returns the raw clockticks
|
||||
|
||||
@@ -716,7 +716,7 @@ void LLUUID::getCurrentTime(uuid_time_t *timestamp)
|
||||
getSystemTime(&time_last);
|
||||
uuids_this_tick = uuids_per_tick;
|
||||
init = TRUE;
|
||||
mMutex = new LLMutex;
|
||||
mMutex = new LLMutex();
|
||||
}
|
||||
|
||||
uuid_time_t time_now = {0,0};
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include "stdtypes.h"
|
||||
#include "llpreprocessor.h"
|
||||
|
||||
@@ -116,6 +118,19 @@ public:
|
||||
U16 getCRC16() const;
|
||||
U32 getCRC32() const;
|
||||
|
||||
inline size_t hash() const
|
||||
{
|
||||
size_t seed = 0;
|
||||
for (U8 i = 0; i < 4; ++i)
|
||||
{
|
||||
seed ^= static_cast<size_t>(mData[i * 4]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
seed ^= static_cast<size_t>(mData[i * 4 + 1]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
seed ^= static_cast<size_t>(mData[i * 4 + 2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
seed ^= static_cast<size_t>(mData[i * 4 + 3]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
|
||||
static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal.
|
||||
|
||||
static const LLUUID null;
|
||||
@@ -129,8 +144,6 @@ public:
|
||||
U8 mData[UUID_BYTES];
|
||||
};
|
||||
|
||||
typedef std::vector<LLUUID> uuid_vec_t;
|
||||
|
||||
// Construct
|
||||
inline LLUUID::LLUUID()
|
||||
{
|
||||
@@ -141,38 +154,20 @@ inline LLUUID::LLUUID()
|
||||
// Faster than copying from memory
|
||||
inline void LLUUID::setNull()
|
||||
{
|
||||
U32 *word = (U32 *)mData;
|
||||
word[0] = 0;
|
||||
word[1] = 0;
|
||||
word[2] = 0;
|
||||
word[3] = 0;
|
||||
memset(mData, 0, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
|
||||
// Compare
|
||||
inline bool LLUUID::operator==(const LLUUID& rhs) const
|
||||
{
|
||||
U32 *tmp = (U32 *)mData;
|
||||
U32 *rhstmp = (U32 *)rhs.mData;
|
||||
// Note: binary & to avoid branching
|
||||
return
|
||||
(tmp[0] == rhstmp[0]) &
|
||||
(tmp[1] == rhstmp[1]) &
|
||||
(tmp[2] == rhstmp[2]) &
|
||||
(tmp[3] == rhstmp[3]);
|
||||
return !memcmp(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
|
||||
inline bool LLUUID::operator!=(const LLUUID& rhs) const
|
||||
{
|
||||
U32 *tmp = (U32 *)mData;
|
||||
U32 *rhstmp = (U32 *)rhs.mData;
|
||||
// Note: binary | to avoid branching
|
||||
return
|
||||
(tmp[0] != rhstmp[0]) |
|
||||
(tmp[1] != rhstmp[1]) |
|
||||
(tmp[2] != rhstmp[2]) |
|
||||
(tmp[3] != rhstmp[3]);
|
||||
return !!memcmp(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -187,28 +182,20 @@ inline LLUUID::operator bool() const
|
||||
|
||||
inline BOOL LLUUID::notNull() const
|
||||
{
|
||||
U32 *word = (U32 *)mData;
|
||||
return (word[0] | word[1] | word[2] | word[3]) > 0;
|
||||
return !!memcmp(mData, null.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
// Faster than == LLUUID::null because doesn't require
|
||||
// as much memory access.
|
||||
inline BOOL LLUUID::isNull() const
|
||||
{
|
||||
U32 *word = (U32 *)mData;
|
||||
// If all bits are zero, return !0 == TRUE
|
||||
return !(word[0] | word[1] | word[2] | word[3]);
|
||||
return !memcmp(mData, null.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
inline LLUUID::LLUUID(const LLUUID& rhs)
|
||||
{
|
||||
U32 *tmp = (U32 *)mData;
|
||||
U32 *rhstmp = (U32 *)rhs.mData;
|
||||
tmp[0] = rhstmp[0];
|
||||
tmp[1] = rhstmp[1];
|
||||
tmp[2] = rhstmp[2];
|
||||
tmp[3] = rhstmp[3];
|
||||
memcpy(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
inline LLUUID::~LLUUID()
|
||||
@@ -218,14 +205,7 @@ inline LLUUID::~LLUUID()
|
||||
// Assignment
|
||||
inline LLUUID& LLUUID::operator=(const LLUUID& rhs)
|
||||
{
|
||||
// No need to check the case where this==&rhs. The branch is slower than the write.
|
||||
U32 *tmp = (U32 *)mData;
|
||||
U32 *rhstmp = (U32 *)rhs.mData;
|
||||
tmp[0] = rhstmp[0];
|
||||
tmp[1] = rhstmp[1];
|
||||
tmp[2] = rhstmp[2];
|
||||
tmp[3] = rhstmp[3];
|
||||
|
||||
memcpy(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -298,13 +278,25 @@ inline U16 LLUUID::getCRC16() const
|
||||
|
||||
inline U32 LLUUID::getCRC32() const
|
||||
{
|
||||
U32 *tmp = (U32*)mData;
|
||||
return tmp[0] + tmp[1] + tmp[2] + tmp[3];
|
||||
// <alchemy/>
|
||||
U32 ret = 0;
|
||||
for(U32 i = 0;i < 4;++i)
|
||||
{
|
||||
ret += (mData[i*4]) | (mData[i*4+1]) << 8 | (mData[i*4+2]) << 16 | (mData[i*4+3]) << 24;
|
||||
}
|
||||
return ret;
|
||||
// </alchemy>
|
||||
}
|
||||
|
||||
typedef std::vector<LLUUID> uuid_vec_t;
|
||||
typedef std::set<LLUUID> uuid_set_t;
|
||||
|
||||
// Helper structure for ordering lluuids in stl containers.
|
||||
// eg: std::map<LLUUID, LLWidget*, lluuid_less> widget_map;
|
||||
// Helper structure for ordering lluuids in stl containers. eg:
|
||||
// std::map<LLUUID, LLWidget*, lluuid_less> widget_map;
|
||||
//
|
||||
// (isn't this the default behavior anyway? I think we could
|
||||
// everywhere replace these with uuid_set_t, but someone should
|
||||
// verify.)
|
||||
struct lluuid_less
|
||||
{
|
||||
bool operator()(const LLUUID& lhs, const LLUUID& rhs) const
|
||||
@@ -315,6 +307,31 @@ struct lluuid_less
|
||||
|
||||
typedef std::set<LLUUID, lluuid_less> uuid_list_t;
|
||||
|
||||
|
||||
#ifdef LL_CPP11
|
||||
namespace std {
|
||||
template <> struct hash<LLUUID>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const LLUUID & id) const
|
||||
{
|
||||
return id.hash();
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
template<> class hash<LLUUID>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const LLUUID& id) const
|
||||
{
|
||||
return id.hash();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Sub-classes for keeping transaction IDs and asset IDs
|
||||
* straight.
|
||||
@@ -331,3 +348,5 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/* Copyright (C) 2013 Siana Gearz
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef SGUUIDHASH_H
|
||||
#define SGUUIDHASH_H
|
||||
|
||||
#include "lluuid.h"
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
namespace boost {
|
||||
template<> class hash<LLUUID> {
|
||||
public:
|
||||
size_t operator()(const LLUUID& id ) const
|
||||
{
|
||||
return *reinterpret_cast<const size_t*>(id.mData);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1178,13 +1178,13 @@ void LLImageRaw::copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixe
|
||||
a *= norm_factor; // skip conditional
|
||||
|
||||
S32 t4 = x * out_pixel_step * components;
|
||||
out[t4 + 0] = U8(llmath::llround(r));
|
||||
out[t4 + 0] = U8(ll_round(r));
|
||||
if (components >= 2)
|
||||
out[t4 + 1] = U8(llmath::llround(g));
|
||||
out[t4 + 1] = U8(ll_round(g));
|
||||
if (components >= 3)
|
||||
out[t4 + 2] = U8(llmath::llround(b));
|
||||
out[t4 + 2] = U8(ll_round(b));
|
||||
if( components == 4)
|
||||
out[t4 + 3] = U8(llmath::llround(a));
|
||||
out[t4 + 3] = U8(ll_round(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1259,10 +1259,10 @@ void LLImageRaw::compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S3
|
||||
b *= norm_factor;
|
||||
a *= norm_factor;
|
||||
|
||||
in_scaled_r = U8(llmath::llround(r));
|
||||
in_scaled_g = U8(llmath::llround(g));
|
||||
in_scaled_b = U8(llmath::llround(b));
|
||||
in_scaled_a = U8(llmath::llround(a));
|
||||
in_scaled_r = U8(ll_round(r));
|
||||
in_scaled_g = U8(ll_round(g));
|
||||
in_scaled_b = U8(ll_round(b));
|
||||
in_scaled_a = U8(ll_round(a));
|
||||
}
|
||||
|
||||
if( in_scaled_a )
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#ifndef LLMATH_H
|
||||
#define LLMATH_H
|
||||
|
||||
#include "llpreprocessor.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
@@ -39,6 +41,7 @@
|
||||
// llcommon depend on llmath.
|
||||
#include "is_approx_equal_fraction.h"
|
||||
|
||||
|
||||
// work around for Windows & older gcc non-standard function names.
|
||||
#if LL_WINDOWS
|
||||
#include <float.h>
|
||||
@@ -153,7 +156,7 @@ inline F64 llabs(const F64 a)
|
||||
|
||||
inline S32 lltrunc( F32 f )
|
||||
{
|
||||
#if LL_WINDOWS && !defined( __INTEL_COMPILER ) && !defined(_WIN64)
|
||||
#if LL_WINDOWS && !defined( __INTEL_COMPILER ) && !defined(_WIN64) && !(_MSC_VER >= 1800)
|
||||
// Avoids changing the floating point control word.
|
||||
// Add or subtract 0.5 - epsilon and then round
|
||||
const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
|
||||
@@ -167,15 +170,22 @@ inline S32 lltrunc( F32 f )
|
||||
fistp result
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
#ifdef LL_CPP11
|
||||
return (S32)trunc(f);
|
||||
#else
|
||||
return (S32)f;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
inline S32 lltrunc( F64 f )
|
||||
{
|
||||
|
||||
#ifdef LL_CPP11
|
||||
return (S32)trunc(f);
|
||||
#else
|
||||
return (S32)f;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline S32 llfloor( F32 f )
|
||||
@@ -204,36 +214,32 @@ inline S32 llceil( F32 f )
|
||||
return (S32)ceil(f);
|
||||
}
|
||||
|
||||
|
||||
namespace llmath
|
||||
// Use this round. Does an arithmetic round (0.5 always rounds up)
|
||||
inline S32 ll_round(const F32 val)
|
||||
{
|
||||
// Use this round. Does an arithmetic round (0.5 always rounds up)
|
||||
inline S32 llround(const F32 val)
|
||||
{
|
||||
#if __cplusplus >= 201103L || _MSC_VER >= 1800
|
||||
return S32(std::round(val));
|
||||
#ifdef LL_CPP11
|
||||
return (S32)round(val);
|
||||
#else
|
||||
return llfloor(val + 0.5f);
|
||||
return llfloor(val + 0.5f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline F32 llround(F32 val, F32 nearest)
|
||||
{
|
||||
#if __cplusplus >= 201103L || _MSC_VER >= 1800
|
||||
return F32(std::round(val * (1.0f / nearest))) * nearest;
|
||||
inline F32 ll_round(F32 val, F32 nearest)
|
||||
{
|
||||
#ifdef LL_CPP11
|
||||
return F32(round(val * (1.0f / nearest))) * nearest;
|
||||
#else
|
||||
return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
|
||||
return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline F64 llround(F64 val, F64 nearest)
|
||||
{
|
||||
#if __cplusplus >= 201103L || _MSC_VER >= 1800
|
||||
return F64(std::round(val * (1.0 / nearest))) * nearest;
|
||||
inline F64 ll_round(F64 val, F64 nearest)
|
||||
{
|
||||
#ifdef LL_CPP11
|
||||
return F64(round(val * (1.0 / nearest))) * nearest;
|
||||
#else
|
||||
return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
|
||||
return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// these provide minimum peak error
|
||||
@@ -281,7 +287,7 @@ const S32 LL_SHIFT_AMOUNT = 16; //16.16 fixed point represe
|
||||
#define LL_MAN_INDEX 1
|
||||
#endif
|
||||
|
||||
/* Deprecated: use llmath::llround(), lltrunc(), or llfloor() instead
|
||||
/* Deprecated: use ll_round(), lltrunc(), or llfloor() instead
|
||||
// ================================================================================================
|
||||
// Real2Int
|
||||
// ================================================================================================
|
||||
@@ -323,7 +329,7 @@ static union
|
||||
#define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer
|
||||
#define LL_EXP_C (60801) // this value of C good for -4 < y < 4
|
||||
|
||||
#define LL_FAST_EXP(y) (LLECO.n.i = llmath::llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
|
||||
#define LL_FAST_EXP(y) (LLECO.n.i = ll_round(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
|
||||
|
||||
|
||||
|
||||
@@ -342,8 +348,8 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
|
||||
bar *= 10.f;
|
||||
}
|
||||
|
||||
//F32 new_foo = (F32)llmath::llround(foo * bar);
|
||||
// the llmath::llround() implementation sucks. Don't us it.
|
||||
//F32 new_foo = (F32)ll_round(foo * bar);
|
||||
// the ll_round() implementation sucks. Don't us it.
|
||||
|
||||
F32 sign = (foo > 0.f) ? 1.f : -1.f;
|
||||
F32 new_foo = F32( S64(foo * bar + sign * 0.5f));
|
||||
|
||||
@@ -52,7 +52,7 @@ inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
|
||||
val /= (upper - lower);
|
||||
|
||||
// round the value. Sreturn the U16
|
||||
return (U16)(llmath::llround(val*U16MAX));
|
||||
return (U16)(ll_round(val*U16MAX));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
|
||||
val /= (upper - lower);
|
||||
|
||||
// return the rounded U8
|
||||
return (U8)(llmath::llround(val*U8MAX));
|
||||
return (U8)(ll_round(val*U8MAX));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -560,7 +560,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3
|
||||
|
||||
// Scale to have size "match" scale. Compensates to get object to generally fill bounding box.
|
||||
|
||||
S32 total_sides = llmath::llround(sides / ang_scale); // Total number of sides all around
|
||||
S32 total_sides = ll_round(sides / ang_scale); // Total number of sides all around
|
||||
|
||||
if (total_sides < 8)
|
||||
{
|
||||
|
||||
@@ -125,10 +125,10 @@ LLColor4 LLColor4::cyan6(0.2f, 0.6f, 0.6f, 1.0f);
|
||||
LLColor4::operator const LLColor4U() const
|
||||
{
|
||||
return LLColor4U(
|
||||
(U8)llclampb(llmath::llround(mV[VRED]*255.f)),
|
||||
(U8)llclampb(llmath::llround(mV[VGREEN]*255.f)),
|
||||
(U8)llclampb(llmath::llround(mV[VBLUE]*255.f)),
|
||||
(U8)llclampb(llmath::llround(mV[VALPHA]*255.f)));
|
||||
(U8)llclampb(ll_round(mV[VRED]*255.f)),
|
||||
(U8)llclampb(ll_round(mV[VGREEN]*255.f)),
|
||||
(U8)llclampb(ll_round(mV[VBLUE]*255.f)),
|
||||
(U8)llclampb(ll_round(mV[VALPHA]*255.f)));
|
||||
}
|
||||
|
||||
LLColor4::LLColor4(const LLColor3 &vec, F32 a)
|
||||
|
||||
@@ -353,10 +353,10 @@ inline LLColor4U LLColor4U::multAll(const F32 k)
|
||||
{
|
||||
// Round to nearest
|
||||
return LLColor4U(
|
||||
(U8)llmath::llround(mV[VX] * k),
|
||||
(U8)llmath::llround(mV[VY] * k),
|
||||
(U8)llmath::llround(mV[VZ] * k),
|
||||
(U8)llmath::llround(mV[VW] * k));
|
||||
(U8)ll_round(mV[VX] * k),
|
||||
(U8)ll_round(mV[VY] * k),
|
||||
(U8)ll_round(mV[VZ] * k),
|
||||
(U8)ll_round(mV[VW] * k));
|
||||
}
|
||||
/*
|
||||
inline LLColor4U operator*(const LLColor4U &a, U8 k)
|
||||
@@ -471,7 +471,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
|
||||
color_scale_factor /= max_color;
|
||||
}
|
||||
const S32 MAX_COLOR = 255;
|
||||
S32 r = llmath::llround(color.mV[0] * color_scale_factor);
|
||||
S32 r = ll_round(color.mV[0] * color_scale_factor);
|
||||
if (r > MAX_COLOR)
|
||||
{
|
||||
r = MAX_COLOR;
|
||||
@@ -482,7 +482,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
|
||||
}
|
||||
mV[0] = r;
|
||||
|
||||
S32 g = llmath::llround(color.mV[1] * color_scale_factor);
|
||||
S32 g = ll_round(color.mV[1] * color_scale_factor);
|
||||
if (g > MAX_COLOR)
|
||||
{
|
||||
g = MAX_COLOR;
|
||||
@@ -493,7 +493,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
|
||||
}
|
||||
mV[1] = g;
|
||||
|
||||
S32 b = llmath::llround(color.mV[2] * color_scale_factor);
|
||||
S32 b = ll_round(color.mV[2] * color_scale_factor);
|
||||
if (b > MAX_COLOR)
|
||||
{
|
||||
b = MAX_COLOR;
|
||||
@@ -505,7 +505,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
|
||||
mV[2] = b;
|
||||
|
||||
// Alpha shouldn't be scaled, just clamped...
|
||||
S32 a = llmath::llround(color.mV[3] * MAX_COLOR);
|
||||
S32 a = ll_round(color.mV[3] * MAX_COLOR);
|
||||
if (a > MAX_COLOR)
|
||||
{
|
||||
a = MAX_COLOR;
|
||||
@@ -527,7 +527,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)
|
||||
}
|
||||
|
||||
const S32 MAX_COLOR = 255;
|
||||
S32 r = llmath::llround(color.mV[0] * color_scale_factor);
|
||||
S32 r = ll_round(color.mV[0] * color_scale_factor);
|
||||
if (r > MAX_COLOR)
|
||||
{
|
||||
r = MAX_COLOR;
|
||||
@@ -539,7 +539,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)
|
||||
}
|
||||
mV[0] = r;
|
||||
|
||||
S32 g = llmath::llround(color.mV[1] * color_scale_factor);
|
||||
S32 g = ll_round(color.mV[1] * color_scale_factor);
|
||||
if (g > MAX_COLOR)
|
||||
{
|
||||
g = MAX_COLOR;
|
||||
@@ -551,7 +551,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)
|
||||
}
|
||||
mV[1] = g;
|
||||
|
||||
S32 b = llmath::llround(color.mV[2] * color_scale_factor);
|
||||
S32 b = ll_round(color.mV[2] * color_scale_factor);
|
||||
if (b > MAX_COLOR)
|
||||
{
|
||||
b = MAX_COLOR;
|
||||
|
||||
@@ -200,7 +200,7 @@ std::string LLMail::buildSMTPTransaction(
|
||||
if(!from_address || !to_address)
|
||||
{
|
||||
llinfos << "send_mail build_smtp_transaction reject: missing to and/or"
|
||||
<< " from address." << llendl;
|
||||
<< " from address." << LL_ENDL;
|
||||
return std::string();
|
||||
}
|
||||
if(!valid_subject_chars(subject))
|
||||
@@ -208,7 +208,7 @@ std::string LLMail::buildSMTPTransaction(
|
||||
llinfos << "send_mail build_smtp_transaction reject: bad subject header: "
|
||||
<< "to=<" << to_address
|
||||
<< ">, from=<" << from_address << ">"
|
||||
<< llendl;
|
||||
<< LL_ENDL;
|
||||
return std::string();
|
||||
}
|
||||
std::ostringstream from_fmt;
|
||||
@@ -266,7 +266,7 @@ bool LLMail::send(
|
||||
if(!from_address || !to_address)
|
||||
{
|
||||
llinfos << "send_mail reject: missing to and/or from address."
|
||||
<< llendl;
|
||||
<< LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ bool LLMail::send(
|
||||
std::string good_string = "\n..\n";
|
||||
while (1)
|
||||
{
|
||||
int index = message.find(bad_string);
|
||||
size_t index = message.find(bad_string);
|
||||
if (index == std::string::npos) break;
|
||||
message.replace(index, bad_string.size(), good_string);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ bool LLMail::send(
|
||||
{
|
||||
llinfos << "send_mail reject: mail system is disabled: to=<"
|
||||
<< to_address << ">, from=<" << from_address
|
||||
<< ">" << llendl;
|
||||
<< ">" << LL_ENDL;
|
||||
// Any future interface to SMTP should return this as an
|
||||
// error. --mark
|
||||
return true;
|
||||
@@ -314,7 +314,7 @@ bool LLMail::send(
|
||||
{
|
||||
llwarns << "send_mail reject: mail system not initialized: to=<"
|
||||
<< to_address << ">, from=<" << from_address
|
||||
<< ">" << llendl;
|
||||
<< ">" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ bool LLMail::send(
|
||||
{
|
||||
llwarns << "send_mail reject: SMTP connect failure: to=<"
|
||||
<< to_address << ">, from=<" << from_address
|
||||
<< ">" << llendl;
|
||||
<< ">" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -342,20 +342,20 @@ bool LLMail::send(
|
||||
<< "to=<" << to_address
|
||||
<< ">, from=<" << from_address << ">"
|
||||
<< ", bytes=" << original_size
|
||||
<< ", sent=" << send_size << llendl;
|
||||
<< ", sent=" << send_size << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
if(send_size >= LL_MAX_KNOWN_GOOD_MAIL_SIZE)
|
||||
{
|
||||
llwarns << "send_mail message has been shown to fail in testing "
|
||||
<< "when sending messages larger than " << LL_MAX_KNOWN_GOOD_MAIL_SIZE
|
||||
<< " bytes. The next log about success is potentially a lie." << llendl;
|
||||
<< " bytes. The next log about success is potentially a lie." << LL_ENDL;
|
||||
}
|
||||
lldebugs << "send_mail success: "
|
||||
<< "to=<" << to_address
|
||||
<< ">, from=<" << from_address << ">"
|
||||
<< ", bytes=" << original_size
|
||||
<< ", sent=" << send_size << llendl;
|
||||
<< ", sent=" << send_size << LL_ENDL;
|
||||
|
||||
#if LL_LOG_ENTIRE_MAIL_MESSAGE_ON_SEND
|
||||
llinfos << rfc2822_msg.str() << llendl;
|
||||
|
||||
@@ -26,25 +26,13 @@
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llhash.h"
|
||||
|
||||
#include "llmessagethrottle.h"
|
||||
#include "llframetimer.h"
|
||||
#include "fix_macros.h"
|
||||
|
||||
// This is used for the stl search_n function.
|
||||
#if _MSC_VER >= 1500 // VC9 has a bug in search_n
|
||||
struct eq_message_throttle_entry : public std::binary_function< LLMessageThrottleEntry, LLMessageThrottleEntry, bool >
|
||||
{
|
||||
bool operator()(const LLMessageThrottleEntry& a, const LLMessageThrottleEntry& b) const
|
||||
{
|
||||
return a.getHash() == b.getHash();
|
||||
}
|
||||
};
|
||||
#else
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
bool eq_message_throttle_entry(LLMessageThrottleEntry a, LLMessageThrottleEntry b)
|
||||
{ return a.getHash() == b.getHash(); }
|
||||
#endif
|
||||
|
||||
const U64 SEC_TO_USEC = 1000000;
|
||||
|
||||
@@ -114,19 +102,14 @@ BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const std::string& mesg
|
||||
std::ostringstream full_mesg;
|
||||
full_mesg << to << mesg;
|
||||
|
||||
// Create an entry for this message.
|
||||
size_t hash = llhash(full_mesg.str().c_str());
|
||||
// Create an entry for this message.o.o
|
||||
size_t hash = boost::hash<std::string>()(full_mesg.str());
|
||||
LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime());
|
||||
|
||||
// Check if this message is already in the list.
|
||||
#if _MSC_VER >= 1500 // VC9 has a bug in search_n
|
||||
// SJB: This *should* work but has not been tested yet *TODO: Test!
|
||||
message_list_iterator_t found = std::find_if(message_list->begin(), message_list->end(),
|
||||
std::bind2nd(eq_message_throttle_entry(), entry));
|
||||
#else
|
||||
message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(),
|
||||
1, entry, eq_message_throttle_entry);
|
||||
#endif
|
||||
|
||||
if (found == message_list->end())
|
||||
{
|
||||
// This message was not found. Add it to the list.
|
||||
@@ -149,18 +132,12 @@ BOOL LLMessageThrottle::addAgentAlert(const LLUUID& agent, const LLUUID& task, c
|
||||
full_mesg << agent << task << mesg;
|
||||
|
||||
// Create an entry for this message.
|
||||
size_t hash = llhash(full_mesg.str().c_str());
|
||||
size_t hash = boost::hash<std::string>()(full_mesg.str());
|
||||
LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime());
|
||||
|
||||
// Check if this message is already in the list.
|
||||
#if _MSC_VER >= 1500 // VC9 has a bug in search_n
|
||||
// SJB: This *should* work but has not been tested yet *TODO: Test!
|
||||
message_list_iterator_t found = std::find_if(message_list->begin(), message_list->end(),
|
||||
std::bind2nd(eq_message_throttle_entry(), entry));
|
||||
#else
|
||||
message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(),
|
||||
1, entry, eq_message_throttle_entry);
|
||||
#endif
|
||||
|
||||
if (found == message_list->end())
|
||||
{
|
||||
|
||||
@@ -68,21 +68,21 @@ inline BOOL to_region_handle(const F32 x_pos, const F32 y_pos, U64 *region_handl
|
||||
U32 x_int, y_int;
|
||||
if (x_pos < 0.f)
|
||||
{
|
||||
// llwarns << "to_region_handle:Clamping negative x position " << x_pos << " to zero!" << llendl;
|
||||
// LL_WARNS() << "to_region_handle:Clamping negative x position " << x_pos << " to zero!" << LL_ENDL;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_int = (U32)llmath::llround(x_pos);
|
||||
x_int = (U32)ll_round(x_pos);
|
||||
}
|
||||
if (y_pos < 0.f)
|
||||
{
|
||||
// llwarns << "to_region_handle:Clamping negative y position " << y_pos << " to zero!" << llendl;
|
||||
// LL_WARNS() << "to_region_handle:Clamping negative y position " << y_pos << " to zero!" << LL_ENDL;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
y_int = (U32)llmath::llround(y_pos);
|
||||
y_int = (U32)ll_round(y_pos);
|
||||
}
|
||||
*region_handle = to_region_handle(x_int, y_int);
|
||||
return TRUE;
|
||||
|
||||
@@ -391,7 +391,7 @@ BOOL LLThrottleGroup::dynamicAdjust()
|
||||
}
|
||||
|
||||
mBitsSentThisPeriod[i] = 0;
|
||||
total += llmath::llround(mBitsSentHistory[i]);
|
||||
total += ll_round(mBitsSentHistory[i]);
|
||||
}
|
||||
|
||||
// Look for busy channels
|
||||
|
||||
@@ -2765,7 +2765,7 @@ void LLMessageSystem::dumpReceiveCounts()
|
||||
if (mt->mReceiveCount > 0)
|
||||
{
|
||||
LL_INFOS("Messaging") << "Num: " << std::setw(3) << mt->mReceiveCount << " Bytes: " << std::setw(6) << mt->mReceiveBytes
|
||||
<< " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << llmath::llround(100 * mt->mDecodeTimeThisFrame / mReceiveTime) << "%" << llendl;
|
||||
<< " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << ll_round(100 * mt->mDecodeTimeThisFrame / mReceiveTime) << "%" << llendl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,6 +1384,8 @@ char const* const _PREHASH_GroupAVSounds = LLMessageStringTable::getInstance()->
|
||||
char const* const _PREHASH_AppearanceData = LLMessageStringTable::getInstance()->getString("AppearanceData");
|
||||
char const* const _PREHASH_AppearanceVersion = LLMessageStringTable::getInstance()->getString("AppearanceVersion");
|
||||
char const* const _PREHASH_CofVersion = LLMessageStringTable::getInstance()->getString("CofVersion");
|
||||
char const* const _PREHASH_AppearanceHover = LLMessageStringTable::getInstance()->getString("AppearanceHover");
|
||||
char const* const _PREHASH_HoverHeight = LLMessageStringTable::getInstance()->getString("HoverHeight");
|
||||
|
||||
// <FS:CR> Aurora Sim
|
||||
char const* const _PREHASH_RegionSizeX = LLMessageStringTable::getInstance()->getString("RegionSizeX");
|
||||
|
||||
@@ -1384,6 +1384,8 @@ extern char const* const _PREHASH_GroupAVSounds;
|
||||
extern char const* const _PREHASH_AppearanceData;
|
||||
extern char const* const _PREHASH_AppearanceVersion;
|
||||
extern char const* const _PREHASH_CofVersion;
|
||||
extern char const* const _PREHASH_AppearanceHover;
|
||||
extern char const* const _PREHASH_HoverHeight;
|
||||
|
||||
// <FS:CR> Aurora Sim
|
||||
extern char const* const _PREHASH_RegionSizeX;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "net.h"
|
||||
//#include "net.h"
|
||||
|
||||
// system library includes
|
||||
#include <stdexcept>
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -370,7 +369,7 @@ BOOL send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, i
|
||||
return TRUE;
|
||||
}
|
||||
llinfos << "sendto() failed to " << u32_to_ip_string(recipient) << ":" << nPort
|
||||
<< ", Error " << last_error << llendl;
|
||||
<< ", Error " << last_error << LL_ENDL;
|
||||
}
|
||||
}
|
||||
} while ( (nRet == SOCKET_ERROR)
|
||||
@@ -414,7 +413,7 @@ S32 start_net(S32& socket_out, int& nPort)
|
||||
if (nRet < 0)
|
||||
{
|
||||
llwarns << "Failed to bind on an OS assigned port error: "
|
||||
<< nRet << llendl;
|
||||
<< nRet << LL_ENDL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -596,7 +595,7 @@ int receive_packet(int hSocket, char * receiveBuffer)
|
||||
}
|
||||
|
||||
// Uncomment for testing if/when implementing for Mac or Windows:
|
||||
// llinfos << "Received datagram to in addr " << u32_to_ip_string(get_receiving_interface_ip()) << llendl;
|
||||
// LL_INFOS() << "Received datagram to in addr " << u32_to_ip_string(get_receiving_interface_ip()) << LL_ENDL;
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
@@ -67,5 +67,8 @@ const S32 ETHERNET_MTU_BYTES = 1500;
|
||||
const S32 MTUBITS = MTUBYTES*8;
|
||||
const S32 MTUU32S = MTUBITS/32;
|
||||
|
||||
// For automatic port discovery when running multiple viewers on one host
|
||||
const U32 PORT_DISCOVERY_RANGE_MIN = 13000;
|
||||
const U32 PORT_DISCOVERY_RANGE_MAX = PORT_DISCOVERY_RANGE_MIN + 50;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -119,18 +119,18 @@ LLSD LLMaterial::asLLSD() const
|
||||
LLSD material_data;
|
||||
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID;
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llmath::llround(mNormalOffsetX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llmath::llround(mNormalOffsetY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llmath::llround(mNormalRepeatX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llmath::llround(mNormalRepeatY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llmath::llround(mNormalRotation * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = ll_round(mNormalOffsetX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = ll_round(mNormalOffsetY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = ll_round(mNormalRepeatX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = ll_round(mNormalRepeatY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = ll_round(mNormalRotation * MATERIALS_MULTIPLIER);
|
||||
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID;
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llmath::llround(mSpecularOffsetX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llmath::llround(mSpecularOffsetY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llmath::llround(mSpecularRepeatX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llmath::llround(mSpecularRepeatY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llmath::llround(mSpecularRotation * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = ll_round(mSpecularOffsetX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = ll_round(mSpecularOffsetY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = ll_round(mSpecularRepeatX * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = ll_round(mSpecularRepeatY * MATERIALS_MULTIPLIER);
|
||||
material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = ll_round(mSpecularRotation * MATERIALS_MULTIPLIER);
|
||||
|
||||
material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue();
|
||||
material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent;
|
||||
|
||||
@@ -1142,12 +1142,12 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
|
||||
const LLTextureEntry* te = getTE(face_index);
|
||||
scale_s[face_index] = (F32) te->mScaleS;
|
||||
scale_t[face_index] = (F32) te->mScaleT;
|
||||
offset_s[face_index] = (S16) llmath::llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
offset_t[face_index] = (S16) llmath::llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
image_rot[face_index] = (S16) llmath::llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
|
||||
offset_s[face_index] = (S16) ll_round((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
offset_t[face_index] = (S16) ll_round((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
image_rot[face_index] = (S16) ll_round(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
|
||||
bump[face_index] = te->getBumpShinyFullbright();
|
||||
media_flags[face_index] = te->getMediaTexGen();
|
||||
glow[face_index] = (U8) llmath::llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
|
||||
glow[face_index] = (U8) ll_round((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
|
||||
|
||||
// Directly sending material_ids is not safe!
|
||||
memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */
|
||||
@@ -1227,12 +1227,12 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
|
||||
const LLTextureEntry* te = getTE(face_index);
|
||||
scale_s[face_index] = (F32) te->mScaleS;
|
||||
scale_t[face_index] = (F32) te->mScaleT;
|
||||
offset_s[face_index] = (S16) llmath::llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
offset_t[face_index] = (S16) llmath::llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
image_rot[face_index] = (S16) llmath::llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
|
||||
offset_s[face_index] = (S16) ll_round((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
offset_t[face_index] = (S16) ll_round((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
|
||||
image_rot[face_index] = (S16) ll_round(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
|
||||
bump[face_index] = te->getBumpShinyFullbright();
|
||||
media_flags[face_index] = te->getMediaTexGen();
|
||||
glow[face_index] = (U8) llmath::llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
|
||||
glow[face_index] = (U8) ll_round((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
|
||||
|
||||
// Directly sending material_ids is not safe!
|
||||
memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */
|
||||
|
||||
@@ -58,13 +58,13 @@ bool LLVolumeMessage::packProfileParams(
|
||||
tempU8 = params->getCurveType();
|
||||
mesgsys->addU8Fast(_PREHASH_ProfileCurve, tempU8);
|
||||
|
||||
tempU16 = (U16) llmath::llround( params->getBegin() / CUT_QUANTA);
|
||||
tempU16 = (U16) ll_round( params->getBegin() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileBegin, tempU16);
|
||||
|
||||
tempU16 = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA);
|
||||
tempU16 = 50000 - (U16) ll_round(params->getEnd() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileEnd, tempU16);
|
||||
|
||||
tempU16 = (U16) llmath::llround(params->getHollow() / HOLLOW_QUANTA);
|
||||
tempU16 = (U16) ll_round(params->getHollow() / HOLLOW_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileHollow, tempU16);
|
||||
|
||||
return true;
|
||||
@@ -86,13 +86,13 @@ bool LLVolumeMessage::packProfileParams(
|
||||
tempU8 = params->getCurveType();
|
||||
dp.packU8(tempU8, "Curve");
|
||||
|
||||
tempU16 = (U16) llmath::llround( params->getBegin() / CUT_QUANTA);
|
||||
tempU16 = (U16) ll_round( params->getBegin() / CUT_QUANTA);
|
||||
dp.packU16(tempU16, "Begin");
|
||||
|
||||
tempU16 = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA);
|
||||
tempU16 = 50000 - (U16) ll_round(params->getEnd() / CUT_QUANTA);
|
||||
dp.packU16(tempU16, "End");
|
||||
|
||||
tempU16 = (U16) llmath::llround(params->getHollow() / HOLLOW_QUANTA);
|
||||
tempU16 = (U16) ll_round(params->getHollow() / HOLLOW_QUANTA);
|
||||
dp.packU16(tempU16, "Hollow");
|
||||
return true;
|
||||
}
|
||||
@@ -223,46 +223,46 @@ bool LLVolumeMessage::packPathParams(
|
||||
U8 curve = params->getCurveType();
|
||||
mesgsys->addU8Fast(_PREHASH_PathCurve, curve);
|
||||
|
||||
U16 begin = (U16) llmath::llround(params->getBegin() / CUT_QUANTA);
|
||||
U16 begin = (U16) ll_round(params->getBegin() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_PathBegin, begin);
|
||||
|
||||
U16 end = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA);
|
||||
U16 end = 50000 - (U16) ll_round(params->getEnd() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_PathEnd, end);
|
||||
|
||||
// Avoid truncation problem with direct F32->U8 cast.
|
||||
// (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50.
|
||||
|
||||
U8 pack_scale_x = 200 - (U8) llmath::llround(params->getScaleX() / SCALE_QUANTA);
|
||||
U8 pack_scale_x = 200 - (U8) ll_round(params->getScaleX() / SCALE_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathScaleX, pack_scale_x );
|
||||
|
||||
U8 pack_scale_y = 200 - (U8) llmath::llround(params->getScaleY() / SCALE_QUANTA);
|
||||
U8 pack_scale_y = 200 - (U8) ll_round(params->getScaleY() / SCALE_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathScaleY, pack_scale_y );
|
||||
|
||||
U8 pack_shear_x = (U8) llmath::llround(params->getShearX() / SHEAR_QUANTA);
|
||||
U8 pack_shear_x = (U8) ll_round(params->getShearX() / SHEAR_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathShearX, pack_shear_x );
|
||||
|
||||
U8 pack_shear_y = (U8) llmath::llround(params->getShearY() / SHEAR_QUANTA);
|
||||
U8 pack_shear_y = (U8) ll_round(params->getShearY() / SHEAR_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathShearY, pack_shear_y );
|
||||
|
||||
S8 twist = (S8) llmath::llround(params->getTwist() / SCALE_QUANTA);
|
||||
S8 twist = (S8) ll_round(params->getTwist() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTwist, twist);
|
||||
|
||||
S8 twist_begin = (S8) llmath::llround(params->getTwistBegin() / SCALE_QUANTA);
|
||||
S8 twist_begin = (S8) ll_round(params->getTwistBegin() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTwistBegin, twist_begin);
|
||||
|
||||
S8 radius_offset = (S8) llmath::llround(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
S8 radius_offset = (S8) ll_round(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathRadiusOffset, radius_offset);
|
||||
|
||||
S8 taper_x = (S8) llmath::llround(params->getTaperX() / TAPER_QUANTA);
|
||||
S8 taper_x = (S8) ll_round(params->getTaperX() / TAPER_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTaperX, taper_x);
|
||||
|
||||
S8 taper_y = (S8) llmath::llround(params->getTaperY() / TAPER_QUANTA);
|
||||
S8 taper_y = (S8) ll_round(params->getTaperY() / TAPER_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTaperY, taper_y);
|
||||
|
||||
U8 revolutions = (U8) llmath::llround( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
U8 revolutions = (U8) ll_round( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathRevolutions, revolutions);
|
||||
|
||||
S8 skew = (S8) llmath::llround(params->getSkew() / SCALE_QUANTA);
|
||||
S8 skew = (S8) ll_round(params->getSkew() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathSkew, skew);
|
||||
|
||||
return true;
|
||||
@@ -280,46 +280,46 @@ bool LLVolumeMessage::packPathParams(
|
||||
U8 curve = params->getCurveType();
|
||||
dp.packU8(curve, "Curve");
|
||||
|
||||
U16 begin = (U16) llmath::llround(params->getBegin() / CUT_QUANTA);
|
||||
U16 begin = (U16) ll_round(params->getBegin() / CUT_QUANTA);
|
||||
dp.packU16(begin, "Begin");
|
||||
|
||||
U16 end = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA);
|
||||
U16 end = 50000 - (U16) ll_round(params->getEnd() / CUT_QUANTA);
|
||||
dp.packU16(end, "End");
|
||||
|
||||
// Avoid truncation problem with direct F32->U8 cast.
|
||||
// (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50.
|
||||
|
||||
U8 pack_scale_x = 200 - (U8) llmath::llround(params->getScaleX() / SCALE_QUANTA);
|
||||
U8 pack_scale_x = 200 - (U8) ll_round(params->getScaleX() / SCALE_QUANTA);
|
||||
dp.packU8(pack_scale_x, "ScaleX");
|
||||
|
||||
U8 pack_scale_y = 200 - (U8) llmath::llround(params->getScaleY() / SCALE_QUANTA);
|
||||
U8 pack_scale_y = 200 - (U8) ll_round(params->getScaleY() / SCALE_QUANTA);
|
||||
dp.packU8(pack_scale_y, "ScaleY");
|
||||
|
||||
S8 pack_shear_x = (S8) llmath::llround(params->getShearX() / SHEAR_QUANTA);
|
||||
S8 pack_shear_x = (S8) ll_round(params->getShearX() / SHEAR_QUANTA);
|
||||
dp.packU8(*(U8 *)&pack_shear_x, "ShearX");
|
||||
|
||||
S8 pack_shear_y = (S8) llmath::llround(params->getShearY() / SHEAR_QUANTA);
|
||||
S8 pack_shear_y = (S8) ll_round(params->getShearY() / SHEAR_QUANTA);
|
||||
dp.packU8(*(U8 *)&pack_shear_y, "ShearY");
|
||||
|
||||
S8 twist = (S8) llmath::llround(params->getTwist() / SCALE_QUANTA);
|
||||
S8 twist = (S8) ll_round(params->getTwist() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&twist, "Twist");
|
||||
|
||||
S8 twist_begin = (S8) llmath::llround(params->getTwistBegin() / SCALE_QUANTA);
|
||||
S8 twist_begin = (S8) ll_round(params->getTwistBegin() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&twist_begin, "TwistBegin");
|
||||
|
||||
S8 radius_offset = (S8) llmath::llround(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
S8 radius_offset = (S8) ll_round(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&radius_offset, "RadiusOffset");
|
||||
|
||||
S8 taper_x = (S8) llmath::llround(params->getTaperX() / TAPER_QUANTA);
|
||||
S8 taper_x = (S8) ll_round(params->getTaperX() / TAPER_QUANTA);
|
||||
dp.packU8(*(U8 *)&taper_x, "TaperX");
|
||||
|
||||
S8 taper_y = (S8) llmath::llround(params->getTaperY() / TAPER_QUANTA);
|
||||
S8 taper_y = (S8) ll_round(params->getTaperY() / TAPER_QUANTA);
|
||||
dp.packU8(*(U8 *)&taper_y, "TaperY");
|
||||
|
||||
U8 revolutions = (U8) llmath::llround( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
U8 revolutions = (U8) ll_round( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
dp.packU8(*(U8 *)&revolutions, "Revolutions");
|
||||
|
||||
S8 skew = (S8) llmath::llround(params->getSkew() / SCALE_QUANTA);
|
||||
S8 skew = (S8) ll_round(params->getSkew() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&skew, "Skew");
|
||||
|
||||
return true;
|
||||
|
||||
@@ -184,8 +184,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, const F32 point_size,
|
||||
mDescender = -mFTFace->descender * pixels_per_unit;
|
||||
mLineHeight = mFTFace->height * pixels_per_unit;
|
||||
|
||||
S32 max_char_width = llmath::llround(0.5f + (x_max - x_min));
|
||||
S32 max_char_height = llmath::llround(0.5f + (y_max - y_min));
|
||||
S32 max_char_width = ll_round(0.5f + (x_max - x_min));
|
||||
S32 max_char_height = ll_round(0.5f + (y_max - y_min));
|
||||
|
||||
mFontBitmapCachep->init(components, max_char_width, max_char_height);
|
||||
|
||||
|
||||
@@ -228,10 +228,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
case LEFT:
|
||||
break;
|
||||
case RIGHT:
|
||||
cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
|
||||
cur_x -= llmin(scaled_max_pixels, ll_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
|
||||
break;
|
||||
case HCENTER:
|
||||
cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
|
||||
cur_x -= llmin(scaled_max_pixels, ll_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -240,7 +240,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
cur_render_y = cur_y;
|
||||
cur_render_x = cur_x;
|
||||
|
||||
F32 start_x = (F32)llmath::llround(cur_x);
|
||||
F32 start_x = (F32)ll_round(cur_x);
|
||||
|
||||
const LLFontBitmapCache* font_bitmap_cache = mFontFreetype->getFontBitmapCache();
|
||||
|
||||
@@ -254,12 +254,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
if (use_ellipses && halign == LEFT)
|
||||
{
|
||||
// check for too long of a string
|
||||
S32 string_width = llmath::llround(getWidthF32(wstr, begin_offset, max_chars) * sScaleX);
|
||||
S32 string_width = ll_round(getWidthF32(wstr, begin_offset, max_chars) * sScaleX);
|
||||
if (string_width > scaled_max_pixels)
|
||||
{
|
||||
// use four dots for ellipsis width to generate padding
|
||||
const LLWString dots(utf8str_to_wstring(std::string("....")));
|
||||
scaled_max_pixels = llmax(0, scaled_max_pixels - llmath::llround(getWidthF32(dots.c_str())));
|
||||
scaled_max_pixels = llmax(0, scaled_max_pixels - ll_round(getWidthF32(dots.c_str())));
|
||||
draw_ellipses = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -306,8 +306,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
gGL.getTexUnit(0)->bind(ext_image);
|
||||
|
||||
// snap origin to whole screen pixel
|
||||
const F32 ext_x = (F32)llmath::llround(cur_render_x + (EXT_X_BEARING * sScaleX));
|
||||
const F32 ext_y = (F32)llmath::llround(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight()));
|
||||
const F32 ext_x = (F32)ll_round(cur_render_x + (EXT_X_BEARING * sScaleX));
|
||||
const F32 ext_y = (F32)ll_round(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight()));
|
||||
|
||||
LLRectf uv_rect(0.f, 1.f, 1.f, 0.f);
|
||||
LLRectf screen_rect(ext_x, ext_y + ext_height, ext_x + ext_width, ext_y);
|
||||
@@ -396,10 +396,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
(fgi->mXBitmapOffset + fgi->mWidth) * inv_width,
|
||||
(fgi->mYBitmapOffset - PAD_UVY) * inv_height);
|
||||
// snap glyph origin to whole screen pixel
|
||||
LLRectf screen_rect((F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing),
|
||||
(F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing),
|
||||
(F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
|
||||
(F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
|
||||
LLRectf screen_rect((F32)ll_round(cur_render_x + (F32)fgi->mXBearing),
|
||||
(F32)ll_round(cur_render_y + (F32)fgi->mYBearing),
|
||||
(F32)ll_round(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
|
||||
(F32)ll_round(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
|
||||
|
||||
if (glyph_count >= GLYPH_BATCH_SIZE)
|
||||
{
|
||||
@@ -430,8 +430,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
// Must do this to cur_x, not just to cur_render_x, otherwise you
|
||||
// will squish sub-pixel kerned characters too close together.
|
||||
// For example, "CCCCC" looks bad.
|
||||
cur_x = (F32)llmath::llround(cur_x);
|
||||
//cur_y = (F32)llmath::llround(cur_y);
|
||||
cur_x = (F32)ll_round(cur_x);
|
||||
//cur_y = (F32)ll_round(cur_y);
|
||||
|
||||
cur_render_x = cur_x;
|
||||
cur_render_y = cur_y;
|
||||
@@ -506,7 +506,7 @@ F32 LLFontGL::getDescenderHeight() const
|
||||
|
||||
F32 LLFontGL::getLineHeight() const
|
||||
{
|
||||
return (F32)llmath::llround(mFontFreetype->getLineHeight() / sScaleY);
|
||||
return (F32)ll_round(mFontFreetype->getLineHeight() / sScaleY);
|
||||
}
|
||||
|
||||
S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
|
||||
@@ -517,7 +517,7 @@ S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, cons
|
||||
S32 LLFontGL::getWidth(const LLWString& utf32text, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
|
||||
{
|
||||
F32 width = getWidthF32(utf32text, begin_offset, max_chars, use_embedded);
|
||||
return llmath::llround(width);
|
||||
return ll_round(width);
|
||||
}
|
||||
|
||||
F32 LLFontGL::getWidthF32(const std::string& utf8text, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
|
||||
@@ -582,7 +582,7 @@ F32 LLFontGL::getWidthF32(const LLWString& utf32text, const S32 begin_offset, co
|
||||
}
|
||||
}
|
||||
// Round after kerning.
|
||||
cur_x = (F32)llmath::llround(cur_x);
|
||||
cur_x = (F32)ll_round(cur_x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ S32 LLFontGL::maxDrawableChars(const LLWString& utf32text, F32 max_pixels, S32 m
|
||||
}
|
||||
}
|
||||
// Round after kerning.
|
||||
cur_x = (F32)llmath::llround(cur_x);
|
||||
cur_x = (F32)ll_round(cur_x);
|
||||
drawn_x = cur_x;
|
||||
}
|
||||
|
||||
@@ -785,7 +785,7 @@ S32 LLFontGL::firstDrawableChar(const LLWString& utf32text, F32 max_pixels, S32
|
||||
}
|
||||
|
||||
// Round after kerning.
|
||||
total_width = (F32)llmath::llround(total_width);
|
||||
total_width = (F32)ll_round(total_width);
|
||||
}
|
||||
|
||||
if (drawable_chars == 0)
|
||||
@@ -872,7 +872,7 @@ S32 LLFontGL::charFromPixelOffset(const LLWString& utf32text, const S32 begin_of
|
||||
|
||||
|
||||
// Round after kerning.
|
||||
cur_x = (F32)llmath::llround(cur_x);
|
||||
cur_x = (F32)ll_round(cur_x);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -639,9 +639,8 @@ void LLPostProcess::drawOrthoQuad(QuadType type)
|
||||
mVBO->getTexCoord1Strider(uv2);
|
||||
|
||||
float offs[2] = {
|
||||
/*llmath::llround*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE),
|
||||
/*llmath::llround*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE)
|
||||
};
|
||||
/*ll_round*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE),
|
||||
/*ll_round*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE) };
|
||||
float scale[2] = {
|
||||
(float)mScreenWidth * mNoiseTextureScale,
|
||||
(float)mScreenHeight * mNoiseTextureScale };
|
||||
|
||||
@@ -401,8 +401,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
F32 image_width = image->getWidth(0);
|
||||
F32 image_height = image->getHeight(0);
|
||||
|
||||
S32 image_natural_width = llmath::llround(image_width * uv_width);
|
||||
S32 image_natural_height = llmath::llround(image_height * uv_height);
|
||||
S32 image_natural_width = ll_round(image_width * uv_width);
|
||||
S32 image_natural_height = ll_round(image_height * uv_height);
|
||||
|
||||
LLRectf draw_center_rect( uv_center_rect.mLeft * image_width,
|
||||
uv_center_rect.mTop * image_height,
|
||||
@@ -421,10 +421,10 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
|
||||
F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
|
||||
|
||||
draw_center_rect.mLeft = llmath::llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]);
|
||||
draw_center_rect.mTop = llmath::llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]);
|
||||
draw_center_rect.mRight = llmath::llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]);
|
||||
draw_center_rect.mBottom = llmath::llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]);
|
||||
draw_center_rect.mLeft = ll_round(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]);
|
||||
draw_center_rect.mTop = ll_round(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]);
|
||||
draw_center_rect.mRight = ll_round(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]);
|
||||
draw_center_rect.mBottom = ll_round(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]);
|
||||
}
|
||||
|
||||
LLRectf draw_outer_rect(ui_translation.mV[VX],
|
||||
@@ -664,8 +664,8 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
|
||||
ui_translation.mV[VY] += y;
|
||||
ui_translation.scaleVec(ui_scale);
|
||||
S32 index = 0;
|
||||
S32 scaled_width = llmath::llround(width * ui_scale.mV[VX]);
|
||||
S32 scaled_height = llmath::llround(height * ui_scale.mV[VY]);
|
||||
S32 scaled_width = ll_round(width * ui_scale.mV[VX]);
|
||||
S32 scaled_height = ll_round(height * ui_scale.mV[VY]);
|
||||
|
||||
uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
|
||||
pos[index].set(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f);
|
||||
@@ -1617,4 +1617,4 @@ LLPointer<LLUIImage> LLRender2D::getUIImage(const std::string& name, S32 priorit
|
||||
return sImageProvider->getUIImage(name, priority);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,13 +115,13 @@ void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4&
|
||||
S32 LLUIImage::getWidth() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llmath::llround((F32)mImage->getWidth(0) * mClipRegion.getWidth());
|
||||
return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getHeight() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llmath::llround((F32)mImage->getHeight(0) * mClipRegion.getHeight());
|
||||
return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getTextureWidth() const
|
||||
|
||||
@@ -536,8 +536,8 @@ void LLButton::getOverlayImageSize(S32& overlay_width, S32& overlay_height)
|
||||
overlay_height = mImageOverlay->getHeight();
|
||||
|
||||
F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f);
|
||||
overlay_width = llmath::llround((F32)overlay_width * scale_factor);
|
||||
overlay_height = llmath::llround((F32)overlay_height * scale_factor);
|
||||
overlay_width = ll_round((F32)overlay_width * scale_factor);
|
||||
overlay_height = ll_round((F32)overlay_height * scale_factor);
|
||||
}
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ void LLButton::draw()
|
||||
if (hasFocus())
|
||||
{
|
||||
F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
|
||||
drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llmath::llround(lerp(1.f, 3.f, lerp_amt)));
|
||||
drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, ll_round(lerp(1.f, 3.f, lerp_amt)));
|
||||
}
|
||||
|
||||
if (use_glow_effect)
|
||||
@@ -981,7 +981,7 @@ void LLButton::resize(LLUIString label)
|
||||
{
|
||||
S32 overlay_width = mImageOverlay->getWidth();
|
||||
F32 scale_factor = (getRect().getHeight() - (mImageOverlayBottomPad + mImageOverlayTopPad)) / (F32)mImageOverlay->getHeight();
|
||||
overlay_width = llmath::llround((F32)overlay_width * scale_factor);
|
||||
overlay_width = ll_round((F32)overlay_width * scale_factor);
|
||||
|
||||
switch(mImageOverlayAlignment)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect,
|
||||
// Label (add a little space to make sure text actually renders)
|
||||
const S32 FUDGE = 10;
|
||||
S32 text_width = mFont->getWidth( label ) + FUDGE;
|
||||
S32 text_height = llmath::llround(mFont->getLineHeight());
|
||||
S32 text_height = ll_round(mFont->getLineHeight());
|
||||
LLRect label_rect;
|
||||
label_rect.setOriginAndSize(
|
||||
LLCHECKBOXCTRL_HPAD + LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING,
|
||||
@@ -187,7 +187,7 @@ void LLCheckBoxCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
//stretch or shrink bounding rectangle of label when rebuilding UI at new scale
|
||||
const S32 FUDGE = 10;
|
||||
S32 text_width = mFont->getWidth( mLabel->getText() ) + FUDGE;
|
||||
S32 text_height = llmath::llround(mFont->getLineHeight());
|
||||
S32 text_height = ll_round(mFont->getLineHeight());
|
||||
LLRect label_rect;
|
||||
label_rect.setOriginAndSize(
|
||||
LLCHECKBOXCTRL_HPAD + LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING,
|
||||
|
||||
@@ -247,7 +247,7 @@ void LLDragHandleTop::reshapeTitleBox()
|
||||
S32 title_width = font->getWidth( getTitleBox()->getText() ) + TITLE_PAD;
|
||||
if (getMaxTitleWidth() > 0)
|
||||
title_width = llmin(title_width, getMaxTitleWidth());
|
||||
S32 title_height = llmath::llround(font->getLineHeight());
|
||||
S32 title_height = ll_round(font->getLineHeight());
|
||||
LLRect title_rect;
|
||||
title_rect.setLeftTopAndSize(
|
||||
LEFT_PAD,
|
||||
|
||||
@@ -1449,7 +1449,7 @@ void LLFloater::draw()
|
||||
}
|
||||
gl_drop_shadow(left, top, right, bottom,
|
||||
shadow_color,
|
||||
llmath::llround(shadow_offset));
|
||||
ll_round(shadow_offset));
|
||||
|
||||
// No transparent windows in simple UI
|
||||
if (isBackgroundOpaque())
|
||||
@@ -1614,16 +1614,16 @@ void LLFloater::updateButtons()
|
||||
btn_rect.setLeftTopAndSize(
|
||||
LLPANEL_BORDER_WIDTH,
|
||||
getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count,
|
||||
llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
ll_round((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
ll_round((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_rect.setLeftTopAndSize(
|
||||
getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count,
|
||||
getRect().getHeight() - CLOSE_BOX_FROM_TOP,
|
||||
llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
ll_round((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
ll_round((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
}
|
||||
|
||||
mButtons[i]->setRect(btn_rect);
|
||||
@@ -1650,16 +1650,16 @@ void LLFloater::buildButtons()
|
||||
btn_rect.setLeftTopAndSize(
|
||||
LLPANEL_BORDER_WIDTH,
|
||||
getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1),
|
||||
llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
ll_round(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
ll_round(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_rect.setLeftTopAndSize(
|
||||
getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1),
|
||||
getRect().getHeight() - CLOSE_BOX_FROM_TOP,
|
||||
llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
ll_round(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale),
|
||||
ll_round(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale));
|
||||
}
|
||||
|
||||
LLButton* buttonp = new LLButton(
|
||||
|
||||
@@ -173,4 +173,8 @@ void LLFlyoutButton::setToggleState(BOOL state)
|
||||
mToggleState = state;
|
||||
}
|
||||
|
||||
void LLFlyoutButton::setLabel(const std::string& label)
|
||||
{
|
||||
mActionButton->setLabel(label);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
virtual void setEnabled(BOOL enabled);
|
||||
|
||||
void setToggleState(BOOL state);
|
||||
void setLabel(const std::string& label); // Not to be confused with LLComboBox::setLabel
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory);
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
F32 getFocusTime() const { return mFocusFlashTimer.getElapsedTimeF32(); }
|
||||
F32 getFocusFlashAmt() const;
|
||||
S32 getFocusFlashWidth() const { return llmath::llround(lerp(1.f, 3.f, getFocusFlashAmt())); }
|
||||
S32 getFocusFlashWidth() const { return ll_round(lerp(1.f, 3.f, getFocusFlashAmt())); }
|
||||
LLColor4 getFocusColor() const;
|
||||
void triggerFocusFlash();
|
||||
BOOL getAppHasFocus() const { return mAppHasFocus; }
|
||||
|
||||
@@ -122,7 +122,7 @@ F32 LLLayoutPanel::getVisibleAmount() const
|
||||
|
||||
S32 LLLayoutPanel::getLayoutDim() const
|
||||
{
|
||||
return llmath::llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL)
|
||||
return ll_round((F32)((mOrientation == LLLayoutStack::HORIZONTAL)
|
||||
? getRect().getWidth()
|
||||
: getRect().getHeight()));
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void LLLayoutPanel::setTargetDim(S32 value)
|
||||
S32 LLLayoutPanel::getVisibleDim() const
|
||||
{
|
||||
F32 min_dim = getRelevantMinDim();
|
||||
return llmath::llround(mVisibleAmt
|
||||
return ll_round(mVisibleAmt
|
||||
* (min_dim
|
||||
+ (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt))));
|
||||
}
|
||||
@@ -157,7 +157,7 @@ S32 LLLayoutPanel::getVisibleDim() const
|
||||
void LLLayoutPanel::setOrientation( LLLayoutStack::ELayoutOrientation orientation )
|
||||
{
|
||||
mOrientation = orientation;
|
||||
S32 layout_dim = llmath::llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL)
|
||||
S32 layout_dim = ll_round((F32)((mOrientation == LLLayoutStack::HORIZONTAL)
|
||||
? getRect().getWidth()
|
||||
: getRect().getHeight()));
|
||||
|
||||
@@ -374,14 +374,14 @@ void LLLayoutStack::updateLayout()
|
||||
{
|
||||
panelp->mTargetDim = panelp->getRelevantMinDim();
|
||||
}
|
||||
space_to_distribute -= panelp->getVisibleDim() + llmath::llround((F32)mPanelSpacing * panelp->getVisibleAmount());
|
||||
space_to_distribute -= panelp->getVisibleDim() + ll_round((F32)mPanelSpacing * panelp->getVisibleAmount());
|
||||
total_visible_fraction += panelp->mFractionalSize * panelp->getAutoResizeFactor();
|
||||
}
|
||||
|
||||
llassert(total_visible_fraction < 1.05f);
|
||||
|
||||
// don't need spacing after last panel
|
||||
space_to_distribute += panelp ? llmath::llround((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0;
|
||||
space_to_distribute += panelp ? ll_round((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0;
|
||||
|
||||
S32 remaining_space = space_to_distribute;
|
||||
F32 fraction_distributed = 0.f;
|
||||
@@ -392,7 +392,7 @@ void LLLayoutStack::updateLayout()
|
||||
if (panelp->mAutoResize)
|
||||
{
|
||||
F32 fraction_to_distribute = (panelp->mFractionalSize * panelp->getAutoResizeFactor()) / (total_visible_fraction);
|
||||
S32 delta = llmath::llround((F32)space_to_distribute * fraction_to_distribute);
|
||||
S32 delta = ll_round((F32)space_to_distribute * fraction_to_distribute);
|
||||
fraction_distributed += fraction_to_distribute;
|
||||
panelp->mTargetDim += delta;
|
||||
remaining_space -= delta;
|
||||
@@ -425,17 +425,17 @@ void LLLayoutStack::updateLayout()
|
||||
LLRect panel_rect;
|
||||
if (mOrientation == HORIZONTAL)
|
||||
{
|
||||
panel_rect.setLeftTopAndSize(llmath::llround(cur_pos),
|
||||
panel_rect.setLeftTopAndSize(ll_round(cur_pos),
|
||||
getRect().getHeight(),
|
||||
llmath::llround(panel_dim),
|
||||
ll_round(panel_dim),
|
||||
getRect().getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
panel_rect.setLeftTopAndSize(0,
|
||||
llmath::llround(cur_pos),
|
||||
ll_round(cur_pos),
|
||||
getRect().getWidth(),
|
||||
llmath::llround(panel_dim));
|
||||
ll_round(panel_dim));
|
||||
}
|
||||
panelp->setIgnoreReshape(true);
|
||||
panelp->setShape(panel_rect);
|
||||
@@ -447,14 +447,14 @@ void LLLayoutStack::updateLayout()
|
||||
if (mOrientation == HORIZONTAL)
|
||||
{
|
||||
resize_bar_rect.mLeft = panel_rect.mRight - mResizeBarOverlap;
|
||||
resize_bar_rect.mRight = panel_rect.mRight + (S32)(llmath::llround(panel_spacing)) + mResizeBarOverlap;
|
||||
resize_bar_rect.mRight = panel_rect.mRight + (S32)(ll_round(panel_spacing)) + mResizeBarOverlap;
|
||||
|
||||
cur_pos += panel_visible_dim + panel_spacing;
|
||||
}
|
||||
else //VERTICAL
|
||||
{
|
||||
resize_bar_rect.mTop = panel_rect.mBottom + mResizeBarOverlap;
|
||||
resize_bar_rect.mBottom = panel_rect.mBottom - (S32)(llmath::llround(panel_spacing)) - mResizeBarOverlap;
|
||||
resize_bar_rect.mBottom = panel_rect.mBottom - (S32)(ll_round(panel_spacing)) - mResizeBarOverlap;
|
||||
|
||||
cur_pos -= panel_visible_dim + panel_spacing;
|
||||
}
|
||||
@@ -1035,4 +1035,4 @@ LLView* LLLayoutPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactor
|
||||
panelp->setOrigin(0, 0);
|
||||
|
||||
return panelp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ std::vector<S32> LLLineEditor::getMisspelledWordsPositions()
|
||||
{
|
||||
//misspelled word here, and you have just right clicked on it!
|
||||
//get the center of this word..
|
||||
//S32 center = llmath::llround( (wordEnd-wordStart)/2 ) + wordStart;
|
||||
//S32 center = ll_round( (wordEnd-wordStart)/2 ) + wordStart;
|
||||
//turn this cursor position into a pixel pos
|
||||
//center = findPixelNearestPos(center-getCursor());
|
||||
|
||||
@@ -770,7 +770,7 @@ BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
|
||||
// Scroll if mouse cursor outside of bounds
|
||||
if (mScrollTimer.hasExpired())
|
||||
{
|
||||
S32 increment = llmath::llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME);
|
||||
S32 increment = ll_round(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME);
|
||||
mScrollTimer.reset(AUTO_SCROLL_TIME);
|
||||
if( (x < mMinHPixels) && (mScrollHPos > 0 ) )
|
||||
{
|
||||
@@ -1930,7 +1930,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
select_left - mScrollHPos,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
}
|
||||
|
||||
@@ -1939,8 +1939,8 @@ void LLLineEditor::draw()
|
||||
LLColor4 color(1.f - bg_color.mV[0], 1.f - bg_color.mV[1], 1.f - bg_color.mV[2], alpha );
|
||||
// selected middle
|
||||
S32 width = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos + rendered_text, select_right - mScrollHPos - rendered_text);
|
||||
width = llmin(width, mMaxHPixels - llmath::llround(rendered_pixels_right));
|
||||
gl_rect_2d(llmath::llround(rendered_pixels_right), cursor_top, llmath::llround(rendered_pixels_right)+width, cursor_bottom, color);
|
||||
width = llmin(width, mMaxHPixels - ll_round(rendered_pixels_right));
|
||||
gl_rect_2d(ll_round(rendered_pixels_right), cursor_top, ll_round(rendered_pixels_right)+width, cursor_bottom, color);
|
||||
|
||||
LLColor4 tmp_color( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha );
|
||||
rendered_text += mGLFont->render(
|
||||
@@ -1951,7 +1951,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
select_right - mScrollHPos - rendered_text,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
}
|
||||
|
||||
@@ -1966,7 +1966,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
}
|
||||
}
|
||||
@@ -1980,7 +1980,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
}
|
||||
#if 0 // for when we're ready for image art.
|
||||
@@ -2048,7 +2048,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right, FALSE);
|
||||
}
|
||||
|
||||
@@ -2073,7 +2073,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llmath::llround(rendered_pixels_right),
|
||||
mMaxHPixels - ll_round(rendered_pixels_right),
|
||||
&rendered_pixels_right, FALSE);
|
||||
}
|
||||
// Draw children (border)
|
||||
@@ -3022,7 +3022,7 @@ void LLLineEditor::markAsPreedit(S32 position, S32 length)
|
||||
|
||||
S32 LLLineEditor::getPreeditFontSize() const
|
||||
{
|
||||
return llmath::llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
return ll_round(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
void LLLineEditor::setReplaceNewlinesWithSpaces(BOOL replace)
|
||||
|
||||
@@ -342,7 +342,7 @@ void LLMenuItemGL::setJumpKey(KEY key)
|
||||
// virtual
|
||||
U32 LLMenuItemGL::getNominalHeight( void ) const
|
||||
{
|
||||
return llmath::llround(mFont->getLineHeight()) + MENU_ITEM_PADDING;
|
||||
return ll_round(mFont->getLineHeight()) + MENU_ITEM_PADDING;
|
||||
}
|
||||
|
||||
//virtual
|
||||
@@ -1828,7 +1828,7 @@ void LLMenuItemBranchDownGL::draw( void )
|
||||
if (offset != std::string::npos)
|
||||
{
|
||||
const LLWString& utf32text = mLabel.getWString();
|
||||
S32 x_offset = llmath::llround((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(utf32text, 0, S32_MAX) / 2.f);
|
||||
S32 x_offset = ll_round((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(utf32text, 0, S32_MAX) / 2.f);
|
||||
S32 x_begin = x_offset + getFont()->getWidth(utf32text, 0, offset);
|
||||
S32 x_end = x_offset + getFont()->getWidth(utf32text, 0, offset + 1);
|
||||
gl_line_2d(x_begin, LABEL_BOTTOM_PAD_PIXELS, x_end, LABEL_BOTTOM_PAD_PIXELS);
|
||||
@@ -2662,7 +2662,7 @@ void LLMenuGL::arrange( void )
|
||||
|
||||
// *FIX: create the item first and then ask for its dimensions?
|
||||
S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::getFontSansSerif()->getWidth( std::string("More") ); // *TODO: Translate
|
||||
S32 spillover_item_height = llmath::llround(LLFontGL::getFontSansSerif()->getLineHeight()) + MENU_ITEM_PADDING;
|
||||
S32 spillover_item_height = ll_round(LLFontGL::getFontSansSerif()->getLineHeight()) + MENU_ITEM_PADDING;
|
||||
|
||||
// Scrolling support
|
||||
item_list_t::iterator first_visible_item_iter;
|
||||
@@ -3590,8 +3590,8 @@ BOOL LLMenuGL::handleHover( S32 x, S32 y, MASK mask )
|
||||
LLVector2 mouse_avg_dir((F32)mMouseVelX, (F32)mMouseVelY);
|
||||
mouse_avg_dir.normVec();
|
||||
F32 interp = 0.5f * (llclamp(mouse_dir * mouse_avg_dir, 0.f, 1.f));
|
||||
mMouseVelX = llmath::llround(lerp((F32)mouse_delta_x, (F32)mMouseVelX, interp));
|
||||
mMouseVelY = llmath::llround(lerp((F32)mouse_delta_y, (F32)mMouseVelY, interp));
|
||||
mMouseVelX = ll_round(lerp((F32)mouse_delta_x, (F32)mMouseVelX, interp));
|
||||
mMouseVelY = ll_round(lerp((F32)mouse_delta_y, (F32)mMouseVelY, interp));
|
||||
mLastMouseX = x;
|
||||
mLastMouseY = y;
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ void LLModalDialog::draw()
|
||||
void LLModalDialog::centerOnScreen()
|
||||
{
|
||||
LLVector2 window_size = LLUI::getWindowSize();
|
||||
centerWithin(LLRect(0, 0, llmath::llround(window_size.mV[VX]), llmath::llround(window_size.mV[VY])));
|
||||
centerWithin(LLRect(0, 0, ll_round(window_size.mV[VX]), ll_round(window_size.mV[VY])));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ void LLProgressBar::draw()
|
||||
bar_bg_imagep->draw(getLocalRect(), background_color % alpha);
|
||||
|
||||
LLRect progress_rect = getLocalRect();
|
||||
progress_rect.mRight = llmath::llround(getRect().getWidth() * (mPercentDone / 100.f));
|
||||
progress_rect.mRight = ll_round(getRect().getWidth() * (mPercentDone / 100.f));
|
||||
bar_fg_imagep->draw(progress_rect, LLColor4::white % alpha);
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ bool LLScrollContainer::autoScroll(S32 x, S32 y)
|
||||
// clip rect against root view
|
||||
inner_rect_local.intersectWith(screen_local_extents);
|
||||
|
||||
S32 auto_scroll_speed = llmath::llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32());
|
||||
S32 auto_scroll_speed = ll_round(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32());
|
||||
// autoscroll region should take up no more than one third of visible scroller area
|
||||
S32 auto_scroll_region_width = llmin(inner_rect_local.getWidth() / 3, 10);
|
||||
S32 auto_scroll_region_height = llmin(inner_rect_local.getHeight() / 3, 10);
|
||||
|
||||
@@ -254,7 +254,7 @@ BOOL LLScrollListText::getVisible() const
|
||||
//virtual
|
||||
S32 LLScrollListText::getHeight() const
|
||||
{
|
||||
return llmath::llround(mFont->getLineHeight());
|
||||
return ll_round(mFont->getLineHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
|
||||
break;
|
||||
}
|
||||
LLRect highlight_rect(left - 2,
|
||||
llmath::llround(mFont->getLineHeight()) + 1,
|
||||
ll_round(mFont->getLineHeight()) + 1,
|
||||
left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
|
||||
1);
|
||||
mRoundedRectImage->draw(highlight_rect, highlight_color);
|
||||
|
||||
@@ -602,7 +602,7 @@ bool LLScrollListCtrl::updateColumnWidths()
|
||||
S32 new_width = column->getWidth();
|
||||
if (column->mRelWidth >= 0)
|
||||
{
|
||||
new_width = (S32)llmath::llround(column->mRelWidth*mItemListRect.getWidth());
|
||||
new_width = (S32)ll_round(column->mRelWidth*mItemListRect.getWidth());
|
||||
}
|
||||
else if (column->mDynamicWidth)
|
||||
{
|
||||
@@ -2604,9 +2604,11 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
|
||||
|
||||
LLSD columns;
|
||||
S32 index = 0;
|
||||
const std::string nodename(std::string(node->getName()->mString) + '.');
|
||||
const std::string kidcolumn(nodename + "columns");
|
||||
for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
|
||||
{
|
||||
if (child->hasName("column"))
|
||||
if (child->hasName("column") || child->hasName(kidcolumn))
|
||||
{
|
||||
std::string labelname("");
|
||||
if (child->getAttributeString("label", labelname))
|
||||
@@ -2666,9 +2668,11 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
|
||||
scroll_list->sortByColumnIndex(sort_column, sort_ascending);
|
||||
}
|
||||
|
||||
const std::string kidrow(nodename + "row");
|
||||
const std::string kidrows(nodename + "rows");
|
||||
for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
|
||||
{
|
||||
if (child->hasName("row") || child->hasName("rows"))
|
||||
if (child->hasName("row") || child->hasName(kidrow) || child->hasName("rows") || child->hasName(kidrows))
|
||||
{
|
||||
LLUUID id;
|
||||
LLSD row;
|
||||
@@ -2829,7 +2833,7 @@ void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params
|
||||
}
|
||||
if (new_column->mRelWidth >= 0)
|
||||
{
|
||||
new_column->setWidth((S32)llmath::llround(new_column->mRelWidth*mItemListRect.getWidth()));
|
||||
new_column->setWidth((S32)ll_round(new_column->mRelWidth*mItemListRect.getWidth()));
|
||||
}
|
||||
else if(new_column->mDynamicWidth)
|
||||
{
|
||||
|
||||
@@ -324,6 +324,23 @@ public:
|
||||
BOOL hasSortOrder() const;
|
||||
void clearSortOrder();
|
||||
|
||||
template<typename T> S32 selectMultiple(const std::vector<T>& vec)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (item_list::iterator iter = mItemList.begin(); iter != mItemList.end(); ++iter)
|
||||
{
|
||||
LLScrollListItem* item = *iter;
|
||||
for (typename std::vector<T>::const_iterator titr = vec.begin(); titr != vec.end(); ++titr)
|
||||
if (item->getEnabled() && static_cast<T>(item->getValue()) == (*titr))
|
||||
{
|
||||
selectItem(item, false);
|
||||
++count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mCommitOnSelectionChange) commitIfChanged();
|
||||
return count;
|
||||
}
|
||||
S32 selectMultiple( uuid_vec_t ids );
|
||||
// conceptually const, but mutates mItemList
|
||||
void updateSort() const;
|
||||
|
||||
@@ -75,7 +75,8 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
|
||||
mEditor( NULL ),
|
||||
mTextBox( NULL ),
|
||||
mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
|
||||
mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) )
|
||||
mTextDisabledColor(LLUI::sColorsGroup->getColor("LabelDisabledColor")),
|
||||
mEditorCommitSignal(NULL)
|
||||
{
|
||||
S32 top = getRect().getHeight();
|
||||
S32 bottom = 0;
|
||||
@@ -141,6 +142,11 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
|
||||
updateText();
|
||||
}
|
||||
|
||||
LLSliderCtrl::~LLSliderCtrl()
|
||||
{
|
||||
delete mEditorCommitSignal;
|
||||
}
|
||||
|
||||
void LLSliderCtrl::setValue(F32 v, BOOL from_event)
|
||||
{
|
||||
mSlider->setValue( v, from_event );
|
||||
@@ -238,6 +244,8 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata )
|
||||
if( success )
|
||||
{
|
||||
self->onCommit();
|
||||
if (self->mEditorCommitSignal)
|
||||
(*(self->mEditorCommitSignal))(self, self->getValueF32());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -350,6 +358,12 @@ boost::signals2::connection LLSliderCtrl::setSliderMouseUpCallback( const commit
|
||||
return mSlider->setMouseUpCallback( cb );
|
||||
}
|
||||
|
||||
boost::signals2::connection LLSliderCtrl::setSliderEditorCommitCallback(const commit_signal_t::slot_type& cb)
|
||||
{
|
||||
if (!mEditorCommitSignal) mEditorCommitSignal = new commit_signal_t();
|
||||
return mEditorCommitSignal->connect(cb);
|
||||
}
|
||||
|
||||
void LLSliderCtrl::onTabInto()
|
||||
{
|
||||
if( mEditor )
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
const std::string& control_which = LLStringUtil::null );
|
||||
|
||||
virtual ~LLSliderCtrl() {} // Children all cleaned up by default view destructor.
|
||||
virtual ~LLSliderCtrl();
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
|
||||
boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
|
||||
boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
|
||||
boost::signals2::connection setSliderEditorCommitCallback(const commit_signal_t::slot_type& cb);
|
||||
|
||||
virtual void onTabInto();
|
||||
|
||||
@@ -137,6 +138,8 @@ private:
|
||||
|
||||
LLColor4 mTextEnabledColor;
|
||||
LLColor4 mTextDisabledColor;
|
||||
|
||||
commit_signal_t* mEditorCommitSignal;
|
||||
};
|
||||
|
||||
#endif // LL_LLSLIDERCTRL_H
|
||||
|
||||
@@ -147,7 +147,7 @@ F32 clamp_precision(F32 value, S32 decimal_precision)
|
||||
for (S32 i = 0; i < decimal_precision; i++)
|
||||
clamped_value *= 10.0;
|
||||
|
||||
clamped_value = llmath::llround((F32)clamped_value);
|
||||
clamped_value = ll_round((F32)clamped_value);
|
||||
|
||||
for (S32 i = 0; i < decimal_precision; i++)
|
||||
clamped_value /= 10.0;
|
||||
@@ -161,13 +161,13 @@ F32 get_increment(F32 inc, S32 decimal_precision) //CF: finetune increments
|
||||
if(gKeyboard->getKeyDown(KEY_ALT))
|
||||
inc = inc * 10.f;
|
||||
else if(gKeyboard->getKeyDown(KEY_CONTROL)) {
|
||||
if (llmath::llround(inc * 1000.f) == 25) // 0.025 gets 0.05 here
|
||||
if (ll_round(inc * 1000.f) == 25) // 0.025 gets 0.05 here
|
||||
inc = inc * 0.2f;
|
||||
else
|
||||
inc = inc * 0.1f;
|
||||
}
|
||||
else if(gKeyboard->getKeyDown(KEY_SHIFT)) {
|
||||
if (decimal_precision == 2 && llmath::llround(inc) == 1) // for rotations, finest step is 0.05
|
||||
if (decimal_precision == 2 && ll_round(inc) == 1) // for rotations, finest step is 0.05
|
||||
inc = inc * 0.05f;
|
||||
else
|
||||
inc = inc * 0.01f;
|
||||
|
||||
@@ -120,7 +120,7 @@ void LLStatGraph::draw()
|
||||
|
||||
color = mThresholdColors[i];
|
||||
gGL.color4fv(color.mV);
|
||||
gl_rect_2d(1, llmath::llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE);
|
||||
gl_rect_2d(1, ll_round(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE);
|
||||
}
|
||||
|
||||
void LLStatGraph::setValue(const LLSD& value)
|
||||
|
||||
@@ -312,7 +312,7 @@ LLTextEditor::LLTextEditor(
|
||||
|
||||
updateTextRect();
|
||||
|
||||
S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
S32 page_size = mTextRect.getHeight() / line_height;
|
||||
|
||||
// Init the scrollbar
|
||||
@@ -970,7 +970,7 @@ S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL rou
|
||||
|
||||
// Figure out which line we're nearest to.
|
||||
S32 total_lines = getLineCount();
|
||||
S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
S32 max_visible_lines = mTextRect.getHeight() / line_height;
|
||||
S32 scroll_lines = mScrollbar->getDocPos();
|
||||
S32 visible_lines = llmin( total_lines - scroll_lines, max_visible_lines ); // Lines currently visible
|
||||
@@ -2927,7 +2927,7 @@ void LLTextEditor::drawSelectionBackground()
|
||||
const S32 text_len = getLength();
|
||||
std::queue<S32> line_endings;
|
||||
|
||||
S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
|
||||
S32 selection_left = llmin( mSelectionStart, mSelectionEnd );
|
||||
S32 selection_right = llmax( mSelectionStart, mSelectionEnd );
|
||||
@@ -3122,7 +3122,7 @@ void LLTextEditor::drawMisspelled()
|
||||
|
||||
S32 line_end = 0;
|
||||
// Determine if the cursor is visible and if so what its coordinates are.
|
||||
while( (mTextRect.mBottom <= llmath::llround(text_y)) && (search_pos < num_lines))
|
||||
while( (mTextRect.mBottom <= ll_round(text_y)) && (search_pos < num_lines))
|
||||
{
|
||||
line_end = text_len + 1;
|
||||
S32 next_line = -1;
|
||||
@@ -3197,7 +3197,7 @@ void LLTextEditor::drawCursor()
|
||||
|
||||
S32 line_end = 0;
|
||||
// Determine if the cursor is visible and if so what its coordinates are.
|
||||
while( (mTextRect.mBottom <= llmath::llround(text_y)) && (cur_pos < num_lines))
|
||||
while( (mTextRect.mBottom <= ll_round(text_y)) && (cur_pos < num_lines))
|
||||
{
|
||||
line_end = text_len + 1;
|
||||
S32 next_line = -1;
|
||||
@@ -3316,7 +3316,7 @@ void LLTextEditor::drawPreeditMarker()
|
||||
return;
|
||||
}
|
||||
|
||||
const S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
const S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
|
||||
S32 line_start = getLineStart(cur_line);
|
||||
S32 line_y = mTextRect.mTop - line_height;
|
||||
@@ -3436,7 +3436,7 @@ void LLTextEditor::drawText()
|
||||
if (seg_iter == mSegments.end() || (*seg_iter)->getStart() > line_start) --seg_iter;
|
||||
LLTextSegment* cur_segment = *seg_iter;
|
||||
|
||||
S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
F32 text_y = (F32)(mTextRect.mTop - line_height);
|
||||
while((mTextRect.mBottom <= text_y) && (cur_line < num_lines))
|
||||
{
|
||||
@@ -3461,7 +3461,7 @@ void LLTextEditor::drawText()
|
||||
if( mShowLineNumbers && !cur_line_is_continuation)
|
||||
{
|
||||
const LLFontGL *num_font = LLFontGL::getFontMonospace();
|
||||
F32 y_top = text_y + ((F32)llmath::llround(num_font->getLineHeight()) / 2);
|
||||
F32 y_top = text_y + ((F32)ll_round(num_font->getLineHeight()) / 2);
|
||||
BOOL is_cur_line = getCurrentLine() == cur_line_num;
|
||||
const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL;
|
||||
const LLColor4 fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor;
|
||||
@@ -3506,7 +3506,7 @@ void LLTextEditor::drawText()
|
||||
S32 style_image_height = style->mImageHeight;
|
||||
S32 style_image_width = style->mImageWidth;
|
||||
LLUIImagePtr image = style->getImage();
|
||||
image->draw(llmath::llround(text_x), llmath::llround(text_y)+line_height-style_image_height,
|
||||
image->draw(ll_round(text_x), ll_round(text_y)+line_height-style_image_height,
|
||||
style_image_width, style_image_height);
|
||||
}
|
||||
|
||||
@@ -3593,7 +3593,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
|
||||
}
|
||||
}
|
||||
|
||||
F32 y_top = y + (F32)llmath::llround(font->getLineHeight());
|
||||
F32 y_top = y + (F32)ll_round(font->getLineHeight());
|
||||
|
||||
if( selection_left > seg_start )
|
||||
{
|
||||
@@ -3996,7 +3996,7 @@ void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
// propagate shape information to scrollbar
|
||||
mScrollbar->setDocSize( getLineCount() );
|
||||
|
||||
S32 line_height = llmath::llround( mGLFont->getLineHeight() );
|
||||
S32 line_height = ll_round( mGLFont->getLineHeight() );
|
||||
S32 page_lines = mTextRect.getHeight() / line_height;
|
||||
mScrollbar->setPageSize( page_lines );
|
||||
}
|
||||
@@ -5163,7 +5163,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
|
||||
}
|
||||
|
||||
const llwchar * const text = mWText.c_str();
|
||||
const S32 line_height = llmath::llround(mGLFont->getLineHeight());
|
||||
const S32 line_height = ll_round(mGLFont->getLineHeight());
|
||||
|
||||
if (coord)
|
||||
{
|
||||
@@ -5266,7 +5266,7 @@ void LLTextEditor::markAsPreedit(S32 position, S32 length)
|
||||
|
||||
S32 LLTextEditor::getPreeditFontSize() const
|
||||
{
|
||||
return llmath::llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
return ll_round(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
void LLTextEditor::setKeystrokeCallback(const keystroke_signal_t::slot_type& callback)
|
||||
|
||||
@@ -158,8 +158,8 @@ void LLUI::cleanupClass()
|
||||
void LLUI::setMousePositionScreen(S32 x, S32 y)
|
||||
{
|
||||
S32 screen_x, screen_y;
|
||||
screen_x = llmath::llround((F32)x * getScaleFactor().mV[VX]);
|
||||
screen_y = llmath::llround((F32)y * getScaleFactor().mV[VY]);
|
||||
screen_x = ll_round((F32)x * getScaleFactor().mV[VX]);
|
||||
screen_y = ll_round((F32)y * getScaleFactor().mV[VY]);
|
||||
|
||||
LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert());
|
||||
}
|
||||
@@ -170,8 +170,8 @@ void LLUI::getMousePositionScreen(S32 *x, S32 *y)
|
||||
LLCoordWindow cursor_pos_window;
|
||||
getWindow()->getCursorPosition(&cursor_pos_window);
|
||||
LLCoordGL cursor_pos_gl(cursor_pos_window.convert());
|
||||
*x = llmath::llround((F32)cursor_pos_gl.mX / getScaleFactor().mV[VX]);
|
||||
*y = llmath::llround((F32)cursor_pos_gl.mY / getScaleFactor().mV[VX]);
|
||||
*x = ll_round((F32)cursor_pos_gl.mX / getScaleFactor().mV[VX]);
|
||||
*y = ll_round((F32)cursor_pos_gl.mY / getScaleFactor().mV[VX]);
|
||||
}
|
||||
|
||||
//static
|
||||
@@ -262,15 +262,15 @@ LLVector2 LLUI::getWindowSize()
|
||||
//static
|
||||
void LLUI::screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y)
|
||||
{
|
||||
*gl_x = llmath::llround((F32)screen_x * getScaleFactor().mV[VX]);
|
||||
*gl_y = llmath::llround((F32)screen_y * getScaleFactor().mV[VY]);
|
||||
*gl_x = ll_round((F32)screen_x * getScaleFactor().mV[VX]);
|
||||
*gl_y = ll_round((F32)screen_y * getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y)
|
||||
{
|
||||
*screen_x = llmath::llround((F32)gl_x / getScaleFactor().mV[VX]);
|
||||
*screen_y = llmath::llround((F32)gl_y / getScaleFactor().mV[VY]);
|
||||
*screen_x = ll_round((F32)gl_x / getScaleFactor().mV[VX]);
|
||||
*screen_y = ll_round((F32)gl_y / getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
//static
|
||||
|
||||
@@ -835,9 +835,9 @@ void LLUrlEntryParcel::processParcelInfo(const LLParcelData& parcel_data)
|
||||
// If parcel name is empty use Sim_name (x, y, z) for parcel label.
|
||||
else if (!parcel_data.sim_name.empty())
|
||||
{
|
||||
S32 region_x = llmath::llround(parcel_data.global_x) % REGION_WIDTH_UNITS;
|
||||
S32 region_y = llmath::llround(parcel_data.global_y) % REGION_WIDTH_UNITS;
|
||||
S32 region_z = llmath::llround(parcel_data.global_z);
|
||||
S32 region_x = ll_round(parcel_data.global_x) % REGION_WIDTH_UNITS;
|
||||
S32 region_y = ll_round(parcel_data.global_y) % REGION_WIDTH_UNITS;
|
||||
S32 region_z = ll_round(parcel_data.global_z);
|
||||
|
||||
label = llformat("%s (%d, %d, %d)",
|
||||
parcel_data.sim_name.c_str(), region_x, region_y, region_z);
|
||||
|
||||
@@ -2416,7 +2416,9 @@ LLControlVariable *LLView::findControl(const std::string& name)
|
||||
{
|
||||
return mParentView->findControl(name);
|
||||
}
|
||||
return LLUI::sConfigGroup->getControl(name);
|
||||
if (LLControlVariable* control = LLUI::sConfigGroup->getControl(name))
|
||||
return control;
|
||||
return LLUI::sAccountGroup->getControl(name);
|
||||
}
|
||||
|
||||
const S32 FLOATER_H_MARGIN = 15;
|
||||
@@ -2916,7 +2918,7 @@ bool LLView::setControlValue(const LLSD& value)
|
||||
std::string ctrlname = getControlName();
|
||||
if (!ctrlname.empty())
|
||||
{
|
||||
LLUI::sConfigGroup->setUntypedValue(ctrlname, value);
|
||||
LLUI::getControlControlGroup(ctrlname).setUntypedValue(ctrlname, value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -269,7 +269,7 @@ void LLKeyboardWin32::scanKeyboard()
|
||||
// keydown in highest bit
|
||||
if (!mControllerKeys[key] && !pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000))
|
||||
{
|
||||
//llinfos << "Key up event missed, resetting" << llendl;
|
||||
//LL_INFOS() << "Key up event missed, resetting" << LL_ENDL;
|
||||
mKeyLevel[key] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llkeyboardwin32.h
|
||||
* @brief Handler for assignable key bindings
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -2561,8 +2561,8 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
|
||||
std::string cmd, arg;
|
||||
cmd = gDirUtilp->getAppRODataDir();
|
||||
cmd += gDirUtilp->getDirDelimiter();
|
||||
//cmd += "etc";
|
||||
//cmd += gDirUtilp->getDirDelimiter();
|
||||
cmd += "etc";
|
||||
cmd += gDirUtilp->getDirDelimiter();
|
||||
cmd += "launch_url.sh";
|
||||
arg = escaped_url;
|
||||
exec_cmd(cmd, arg);
|
||||
|
||||
@@ -3820,11 +3820,11 @@ LLWindowCallbacks::DragNDropResult LLWindowWin32::completeDragNDropRequest( cons
|
||||
// When it handled the message, the value to be returned from
|
||||
// the Window Procedure is set to *result.
|
||||
|
||||
BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
BOOL LLWindowWin32::handleImeRequests(WPARAM w_param, LPARAM l_param, LRESULT *result)
|
||||
{
|
||||
if ( mPreeditor )
|
||||
{
|
||||
switch (request)
|
||||
switch (w_param)
|
||||
{
|
||||
case IMR_CANDIDATEWINDOW: // http://msdn2.microsoft.com/en-us/library/ms776080.aspx
|
||||
{
|
||||
@@ -3832,7 +3832,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
LLRect preedit_bounds;
|
||||
mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL);
|
||||
|
||||
CANDIDATEFORM *const form = (CANDIDATEFORM *)param;
|
||||
CANDIDATEFORM *const form = (CANDIDATEFORM *)l_param;
|
||||
DWORD const dwIndex = form->dwIndex;
|
||||
fillCandidateForm(caret_coord, preedit_bounds, form);
|
||||
form->dwIndex = dwIndex;
|
||||
@@ -3842,7 +3842,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
}
|
||||
case IMR_QUERYCHARPOSITION:
|
||||
{
|
||||
IMECHARPOSITION *const char_position = (IMECHARPOSITION *)param;
|
||||
IMECHARPOSITION *const char_position = (IMECHARPOSITION *)l_param;
|
||||
|
||||
// char_position->dwCharPos counts in number of
|
||||
// WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the
|
||||
@@ -3867,7 +3867,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
}
|
||||
case IMR_COMPOSITIONFONT:
|
||||
{
|
||||
fillCompositionLogfont((LOGFONT *)param);
|
||||
fillCompositionLogfont((LOGFONT *)l_param);
|
||||
|
||||
*result = 1;
|
||||
return TRUE;
|
||||
@@ -3882,7 +3882,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
S32 context_offset;
|
||||
const LLWString context = find_context(wtext, select, select_length, &context_offset);
|
||||
|
||||
RECONVERTSTRING * const reconvert_string = (RECONVERTSTRING *)param;
|
||||
RECONVERTSTRING * const reconvert_string = (RECONVERTSTRING *)l_param;
|
||||
const U32 size = fillReconvertString(context, select - context_offset, select_length, reconvert_string);
|
||||
if (reconvert_string)
|
||||
{
|
||||
@@ -3932,7 +3932,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
|
||||
context.erase(preedit, preedit_length);
|
||||
}
|
||||
|
||||
RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)param;
|
||||
RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)l_param;
|
||||
*result = fillReconvertString(context, preedit, 0, reconvert_string);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ protected:
|
||||
U32 fillReconvertString(const LLWString &text, S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string);
|
||||
void handleStartCompositionMessage();
|
||||
void handleCompositionMessage(U32 indexes);
|
||||
BOOL handleImeRequests(U32 request, U32 param, LRESULT *result);
|
||||
BOOL handleImeRequests(WPARAM request, LPARAM param, LRESULT *result);
|
||||
|
||||
protected:
|
||||
//
|
||||
|
||||
@@ -82,6 +82,7 @@ set(viewer_SOURCE_FILES
|
||||
NACLantispam.cpp
|
||||
aihttpview.cpp
|
||||
aixmllindengenepool.cpp
|
||||
alfloaterregiontracker.cpp
|
||||
aoremotectrl.cpp
|
||||
ascentfloatercontactgroups.cpp
|
||||
ascentkeyword.cpp
|
||||
@@ -610,6 +611,7 @@ set(viewer_HEADER_FILES
|
||||
NACLantispam.h
|
||||
aihttpview.h
|
||||
aixmllindengenepool.h
|
||||
alfloaterregiontracker.h
|
||||
aoremotectrl.h
|
||||
ascentfloatercontactgroups.h
|
||||
ascentkeyword.h
|
||||
|
||||
@@ -190,7 +190,7 @@ class AIGLHTTPHeaderBar : public LLView
|
||||
AIGLHTTPHeaderBar(std::string const& name, AIHTTPView* httpview) :
|
||||
LLView(name, FALSE), mHTTPView(httpview)
|
||||
{
|
||||
sLineHeight = llmath::llround(LLFontGL::getFontMonospace()->getLineHeight());
|
||||
sLineHeight = ll_round(LLFontGL::getFontMonospace()->getLineHeight());
|
||||
setRect(LLRect(0, 0, 200, sLineHeight * number_of_header_lines));
|
||||
}
|
||||
|
||||
|
||||
298
indra/newview/alfloaterregiontracker.cpp
Normal file
298
indra/newview/alfloaterregiontracker.cpp
Normal file
@@ -0,0 +1,298 @@
|
||||
/**
|
||||
* @file alfloaterregiontracker.cpp
|
||||
* @brief Region tracking floater
|
||||
*
|
||||
* $LicenseInfo:firstyear=2013&license=viewerlgpl$
|
||||
* Alchemy Viewer Source Code
|
||||
* Copyright (C) 2014, Alchemy Viewer Project.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "alfloaterregiontracker.h"
|
||||
|
||||
// library
|
||||
#include "llbutton.h"
|
||||
#include "lldir.h"
|
||||
#include "llfile.h"
|
||||
#include "llscrolllistctrl.h"
|
||||
#include "llsd.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llsdserialize_xml.h"
|
||||
#include "lltextbox.h"
|
||||
#include "lluictrlfactory.h"
|
||||
|
||||
// newview
|
||||
#include "hippogridmanager.h"
|
||||
#include "llagent.h"
|
||||
#include "llfloaterworldmap.h"
|
||||
//#include "llfloaterreg.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llviewermessage.h"
|
||||
#include "llworldmap.h"
|
||||
#include "llworldmapmessage.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
const std::string TRACKER_FILE = "tracked_regions.json";
|
||||
|
||||
ALFloaterRegionTracker::ALFloaterRegionTracker(const LLSD&)
|
||||
: LLFloater(),
|
||||
LLEventTimer(5.f),
|
||||
mRefreshRegionListBtn(NULL),
|
||||
mRemoveRegionBtn(NULL),
|
||||
mOpenMapBtn(NULL),
|
||||
mRegionScrollList(NULL)
|
||||
{
|
||||
LLUICtrlFactory::instance().buildFloater(this, "floater_region_tracker.xml");
|
||||
loadFromJSON();
|
||||
}
|
||||
|
||||
ALFloaterRegionTracker::~ALFloaterRegionTracker()
|
||||
{
|
||||
saveToJSON();
|
||||
}
|
||||
|
||||
BOOL ALFloaterRegionTracker::postBuild()
|
||||
{
|
||||
mRefreshRegionListBtn = getChild<LLButton>("refresh");
|
||||
mRefreshRegionListBtn->setClickedCallback(boost::bind(&ALFloaterRegionTracker::refresh, this));
|
||||
|
||||
mRemoveRegionBtn = getChild<LLButton>("remove");
|
||||
mRemoveRegionBtn->setClickedCallback(boost::bind(&ALFloaterRegionTracker::removeRegions, this));
|
||||
|
||||
mOpenMapBtn = getChild<LLButton>("open_map");
|
||||
mOpenMapBtn->setClickedCallback(boost::bind(&ALFloaterRegionTracker::openMap, this));
|
||||
|
||||
mRegionScrollList = getChild<LLScrollListCtrl>("region_list");
|
||||
mRegionScrollList->setCommitOnSelectionChange(TRUE);
|
||||
mRegionScrollList->setCommitCallback(boost::bind(&ALFloaterRegionTracker::updateHeader, this));
|
||||
mRegionScrollList->setDoubleClickCallback(boost::bind(&ALFloaterRegionTracker::openMap, this));
|
||||
|
||||
updateHeader();
|
||||
|
||||
return LLFloater::postBuild();
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::onOpen(/*const LLSD& key*/)
|
||||
{
|
||||
requestRegionData();
|
||||
mEventTimer.start();
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::onClose(bool app_quitting)
|
||||
{
|
||||
mEventTimer.stop();
|
||||
app_quitting ? destroy() : setVisible(false);
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::updateHeader()
|
||||
{
|
||||
S32 num_selected(mRegionScrollList->getNumSelected());
|
||||
mRefreshRegionListBtn->setEnabled(mRegionMap.size() != 0);
|
||||
mRemoveRegionBtn->setEnabled(!!num_selected);
|
||||
mOpenMapBtn->setEnabled(num_selected == 1);
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::refresh()
|
||||
{
|
||||
if (!mRegionMap.size())
|
||||
{
|
||||
updateHeader();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> saved_selected_values;
|
||||
BOOST_FOREACH(const LLScrollListItem* item, mRegionScrollList->getAllSelected())
|
||||
{
|
||||
saved_selected_values.push_back(item->getValue().asString());
|
||||
}
|
||||
mRegionScrollList->deleteAllItems();
|
||||
|
||||
const std::string& cur_region_name = gAgent.getRegion()->getName();
|
||||
|
||||
for (LLSD::map_const_iterator it = mRegionMap.beginMap(); it != mRegionMap.endMap(); it++)
|
||||
{
|
||||
const std::string& sim_name = it->first;
|
||||
const LLSD& data = it->second;
|
||||
if (data.isMap()) // Assume the rest is correct.
|
||||
{
|
||||
LLScrollListCell::Params label;
|
||||
LLScrollListCell::Params maturity;
|
||||
LLScrollListCell::Params region;
|
||||
LLScrollListCell::Params count;
|
||||
label.column("region_label").type("text").value(data["label"].asString());
|
||||
maturity.column("region_maturity_icon").type("icon").font_halign(LLFontGL::HCENTER);
|
||||
region.column("region_name").type("text").value(sim_name);
|
||||
count.column("region_agent_count").type("text").value("...");
|
||||
if (LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromName(sim_name))
|
||||
{
|
||||
maturity.value(info->getAccessIcon());
|
||||
maturity.tool_tip(info->getShortAccessString());
|
||||
|
||||
info->updateAgentCount(LLTimer::getElapsedSeconds());
|
||||
S32 agent_count = info->getAgentCount();
|
||||
if (info->isDown())
|
||||
{
|
||||
label.color(LLColor4::red);
|
||||
maturity.color(LLColor4::red);
|
||||
region.color(LLColor4::red);
|
||||
count.color(LLColor4::red);
|
||||
count.value(0);
|
||||
}
|
||||
else
|
||||
count.value((sim_name == cur_region_name) ? agent_count + 1 : agent_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
label.color(LLColor4::grey);
|
||||
maturity.color(LLColor4::grey);
|
||||
region.color(LLColor4::grey);
|
||||
count.color(LLColor4::grey);
|
||||
|
||||
LLWorldMapMessage::getInstance()->sendNamedRegionRequest(sim_name);
|
||||
if (!mEventTimer.getStarted()) mEventTimer.start();
|
||||
}
|
||||
LLScrollListItem::Params row;
|
||||
row.value = sim_name;
|
||||
row.columns.add(label);
|
||||
row.columns.add(maturity);
|
||||
row.columns.add(region);
|
||||
row.columns.add(count);
|
||||
mRegionScrollList->addRow(row);
|
||||
}
|
||||
}
|
||||
if (!saved_selected_values.empty())
|
||||
mRegionScrollList->selectMultiple(saved_selected_values);
|
||||
}
|
||||
|
||||
BOOL ALFloaterRegionTracker::tick()
|
||||
{
|
||||
refresh();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::requestRegionData()
|
||||
{
|
||||
if (!mRegionMap.size())
|
||||
return;
|
||||
|
||||
for (LLSD::map_const_iterator it = mRegionMap.beginMap(); it != mRegionMap.endMap(); it++)
|
||||
{
|
||||
const std::string& name = it->first;
|
||||
if (LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromName(name))
|
||||
{
|
||||
info->updateAgentCount(LLTimer::getElapsedSeconds());
|
||||
}
|
||||
else
|
||||
{
|
||||
LLWorldMapMessage::getInstance()->sendNamedRegionRequest(name);
|
||||
}
|
||||
}
|
||||
mEventTimer.start();
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::removeRegions()
|
||||
{
|
||||
BOOST_FOREACH(const LLScrollListItem* item, mRegionScrollList->getAllSelected())
|
||||
{
|
||||
mRegionMap.erase(item->getValue().asString());
|
||||
}
|
||||
mRegionScrollList->deleteSelectedItems();
|
||||
saveToJSON();
|
||||
updateHeader();
|
||||
}
|
||||
|
||||
std::string getGridSpecificFile(const std::string& file, const char& sep = '_')
|
||||
{
|
||||
const HippoGridInfo& grid(*gHippoGridManager->getConnectedGrid());
|
||||
if (grid.isSecondLife()) return file;
|
||||
return file + sep + grid.getGridNick();
|
||||
}
|
||||
|
||||
bool ALFloaterRegionTracker::saveToJSON()
|
||||
{
|
||||
const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, TRACKER_FILE);
|
||||
llofstream out_file;
|
||||
out_file.open(getGridSpecificFile(filename));
|
||||
if (out_file.is_open())
|
||||
{
|
||||
LLSDSerialize::toPrettyNotation(mRegionMap, out_file);
|
||||
out_file.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ALFloaterRegionTracker::loadFromJSON()
|
||||
{
|
||||
const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, TRACKER_FILE);
|
||||
llifstream in_file;
|
||||
in_file.open(getGridSpecificFile(filename));
|
||||
if (in_file.is_open())
|
||||
{
|
||||
LLSDSerialize::fromNotation(mRegionMap, in_file, LLSDSerialize::SIZE_UNLIMITED);
|
||||
in_file.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ALFloaterRegionTracker::getRegionLabelIfExists(const std::string& name)
|
||||
{
|
||||
return mRegionMap.get(name)["label"].asString();
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::onRegionAddedCallback(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
const S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
|
||||
if (option == 0)
|
||||
{
|
||||
const std::string& name = notification["payload"]["name"].asString();
|
||||
std::string label = response["label"].asString();
|
||||
LLStringUtil::trim(label);
|
||||
if (!name.empty() && !label.empty())
|
||||
{
|
||||
if (mRegionMap.has(name))
|
||||
{
|
||||
for (LLSD::map_iterator it = mRegionMap.beginMap(); it != mRegionMap.endMap(); it++)
|
||||
if (it->first == name) it->second["label"] = label;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLSD region;
|
||||
region["label"] = label;
|
||||
mRegionMap.insert(name, region);
|
||||
}
|
||||
saveToJSON();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ALFloaterRegionTracker::openMap()
|
||||
{
|
||||
const std::string& region = mRegionScrollList->getFirstSelected()->getValue().asString();
|
||||
LLFloaterWorldMap* worldmap_floaterp = gFloaterWorldMap;
|
||||
if (!region.empty() && worldmap_floaterp)
|
||||
{
|
||||
worldmap_floaterp->trackURL(region, 128, 128, 0);
|
||||
worldmap_floaterp->show(true);
|
||||
}
|
||||
}
|
||||
69
indra/newview/alfloaterregiontracker.h
Normal file
69
indra/newview/alfloaterregiontracker.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file alfloaterregiontracker.h
|
||||
* @brief Region tracking floater
|
||||
*
|
||||
* $LicenseInfo:firstyear=2013&license=viewerlgpl$
|
||||
* Alchemy Viewer Source Code
|
||||
* Copyright (C) 2014, Alchemy Viewer Project.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lleventtimer.h"
|
||||
#include "llfloater.h"
|
||||
|
||||
class LLButton;
|
||||
class LLSD;
|
||||
class LLScrollListCtrl;
|
||||
|
||||
class ALFloaterRegionTracker : public LLFloater, public LLEventTimer
|
||||
, public LLFloaterSingleton<ALFloaterRegionTracker>
|
||||
{
|
||||
//friend class LLFloaterReg;
|
||||
friend class LLUISingleton<ALFloaterRegionTracker, VisibilityPolicy<LLFloater> >;
|
||||
private:
|
||||
ALFloaterRegionTracker(const LLSD& key);
|
||||
virtual ~ALFloaterRegionTracker();
|
||||
public:
|
||||
/*virtual*/ BOOL postBuild();
|
||||
/*virtual*/ void onOpen(/*const LLSD& key*/);
|
||||
/*virtual*/ void onClose(bool app_quitting);
|
||||
/*virtual*/ void refresh();
|
||||
/*virtual*/ BOOL tick();
|
||||
using LLFloaterSingleton<ALFloaterRegionTracker>::getInstance;
|
||||
|
||||
private:
|
||||
void updateHeader();
|
||||
void requestRegionData();
|
||||
void removeRegions();
|
||||
bool saveToJSON();
|
||||
bool loadFromJSON();
|
||||
void openMap();
|
||||
|
||||
public:
|
||||
std::string getRegionLabelIfExists(const std::string& name);
|
||||
void onRegionAddedCallback(const LLSD& notification, const LLSD& response);
|
||||
|
||||
private:
|
||||
LLSD mRegionMap;
|
||||
LLButton* mRefreshRegionListBtn;
|
||||
LLButton* mRemoveRegionBtn;
|
||||
LLButton* mOpenMapBtn;
|
||||
LLScrollListCtrl* mRegionScrollList;
|
||||
};
|
||||
@@ -312,11 +312,24 @@ SITTING PAD_DIVIDE NONE start_gesture
|
||||
# these are for passing controls when sitting on vehicles
|
||||
SITTING A SHIFT slide_left
|
||||
SITTING D SHIFT slide_right
|
||||
SITTING W SHIFT move_forward_sitting
|
||||
SITTING S SHIFT move_backward_sitting
|
||||
SITTING E SHIFT spin_over_sitting
|
||||
SITTING C SHIFT spin_under_sitting
|
||||
|
||||
SITTING LEFT SHIFT slide_left
|
||||
SITTING RIGHT SHIFT slide_right
|
||||
SITTING UP SHIFT move_forward_sitting
|
||||
SITTING DOWN SHIFT move_backward_sitting
|
||||
SITTING PGUP SHIFT spin_over_sitting
|
||||
SITTING PGDN SHIFT spin_under_sitting
|
||||
|
||||
SITTING PAD_LEFT SHIFT slide_left
|
||||
SITTING PAD_RIGHT SHIFT slide_right
|
||||
SITTING PAD_UP SHIFT move_forward_sitting
|
||||
SITTING PAD_DOWN SHIFT move_backward_sitting
|
||||
SITTING PAD_PGUP SHIFT spin_over_sitting
|
||||
SITTING PAD_PGDN SHIFT spin_under_sitting
|
||||
SITTING PAD_ENTER SHIFT start_chat
|
||||
SITTING PAD_DIVIDE SHIFT start_gesture
|
||||
|
||||
|
||||
@@ -312,11 +312,24 @@ SITTING PAD_DIVIDE NONE start_gesture
|
||||
# these are for passing controls when sitting on vehicles
|
||||
SITTING Q SHIFT slide_left
|
||||
SITTING D SHIFT slide_right
|
||||
SITTING Z SHIFT move_forward_sitting
|
||||
SITTING S SHIFT move_backward_sitting
|
||||
SITTING E SHIFT spin_over_sitting
|
||||
SITTING C SHIFT spin_under_sitting
|
||||
|
||||
SITTING LEFT SHIFT slide_left
|
||||
SITTING RIGHT SHIFT slide_right
|
||||
SITTING UP SHIFT move_forward_sitting
|
||||
SITTING DOWN SHIFT move_backward_sitting
|
||||
SITTING PGUP SHIFT spin_over_sitting
|
||||
SITTING PGDN SHIFT spin_under_sitting
|
||||
|
||||
SITTING PAD_LEFT SHIFT slide_left
|
||||
SITTING PAD_RIGHT SHIFT slide_right
|
||||
SITTING PAD_UP SHIFT move_forward_sitting
|
||||
SITTING PAD_DOWN SHIFT move_backward_sitting
|
||||
SITTING PAD_PGUP SHIFT spin_over_sitting
|
||||
SITTING PAD_PGDN SHIFT spin_under_sitting
|
||||
SITTING PAD_ENTER SHIFT start_chat
|
||||
SITTING PAD_DIVIDE SHIFT start_gesture
|
||||
|
||||
|
||||
@@ -648,11 +648,11 @@
|
||||
<key>LiruBlockConferences</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>When true, new incoming conference chats will not be opened.</string>
|
||||
<string>When not zero, new incoming conference chats will not be opened, if 2 only those from nonfriends will be blocked.</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<string>U32</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
@@ -4219,6 +4219,17 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>LetterKeysFocusChatBar</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>When printable characters keys (possibly with Shift held) are pressed, the chatbar takes focus</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<boolean>0</boolean>
|
||||
</map>
|
||||
<key>ChatBubbleOpacity</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
@@ -18029,6 +18040,17 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
|
||||
<key>LogInventoryDecline</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Log in system chat whenever an inventory offer is declined</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>UseHTTPInventory</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
@@ -18521,6 +18543,22 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</map>
|
||||
<key>FloaterRegionTrackerRect</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Rectangle for Region Tracker Floater</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Rect</string>
|
||||
<key>Value</key>
|
||||
<array>
|
||||
<integer>500</integer>
|
||||
<integer>450</integer>
|
||||
<integer>850</integer>
|
||||
<integer>400</integer>
|
||||
</array>
|
||||
</map>
|
||||
<key>WindEnabled</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
@@ -18745,7 +18783,7 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<key>Type</key>
|
||||
<string>U32</string>
|
||||
<key>Value</key>
|
||||
<integer>2</integer>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
</map>
|
||||
</llsd>
|
||||
|
||||
@@ -113,6 +113,28 @@
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>AlchemyChatCommandHoverHeight</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Command to hover your height or something</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string>/hover</string>
|
||||
</map>
|
||||
<key>AlchemyChatCommandResyncAnim</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Command to stop/start in order to resync animations</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string>/resync</string>
|
||||
</map>
|
||||
<key>AlchemyConnectToNeighbors</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
@@ -135,6 +157,39 @@
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>AlchemyMouselookIFF</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Display user that is currently focused upon by crosshair in mouselook</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>AlchemyMouselookIFFRange</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Range of IFF display</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>F32</string>
|
||||
<key>Value</key>
|
||||
<real>380.0</real>
|
||||
</map>
|
||||
<key>AlchemyMouselookInstructions</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Draw Mouselook Instructions</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>AlchemyRainbowEffects</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
@@ -156,6 +211,17 @@
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>AlchemySitOnAway</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Agent groundsits in away mode</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>AscentPowerfulWizard</key>
|
||||
<map>
|
||||
@@ -1714,6 +1780,17 @@
|
||||
<key>Value</key>
|
||||
<boolean>0</boolean>
|
||||
</map>
|
||||
<key>ToolbarVisibleRegionTracker</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Whether or not the button for the region tracker is on the toolbar</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<boolean>0</boolean>
|
||||
</map>
|
||||
<key>ToolbarVisibleScriptErrors</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
||||
@@ -8,6 +8,17 @@
|
||||
</array-->
|
||||
|
||||
|
||||
<key>AvatarHoverOffsetZ</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>After-everything-else fixup for avatar Z position.</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>F32</string>
|
||||
<key>Value</key>
|
||||
<real>0.0</real>
|
||||
</map>
|
||||
<!-- Begin AO -->
|
||||
|
||||
<key>AOConfigNotecardID</key>
|
||||
@@ -393,6 +404,17 @@
|
||||
<key>Value</key>
|
||||
<string>This is an autoresponse!</string>
|
||||
</map>
|
||||
<key>AutoresponseMutedShow</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Whether to show that AutoresponseMuted's were sent</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>AutoresponseOnlyIfAway</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user