Merge branch 'master' of https://github.com/Lirusaito/SingularityViewer
This commit is contained in:
@@ -127,7 +127,7 @@ if (LINUX)
|
|||||||
-pthread
|
-pthread
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_FORTIFY_SOURCE=2 ")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ")
|
||||||
|
|
||||||
# Don't catch SIGCHLD in our base application class for the viewer
|
# Don't catch SIGCHLD in our base application class for the viewer
|
||||||
# some of our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh!
|
# some of our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh!
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ namespace LLInitParam
|
|||||||
{
|
{
|
||||||
const U8* my_addr = reinterpret_cast<const U8*>(this);
|
const U8* my_addr = reinterpret_cast<const U8*>(this);
|
||||||
const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
|
const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
|
||||||
mEnclosingBlockOffset = 0x7FFFffff & (U32)(my_addr - block_addr);
|
U32 enclosing_block_offset = 0x7FFFffff & (U32)(my_addr - block_addr);
|
||||||
|
mEnclosingBlockOffsetLow = enclosing_block_offset & 0x0000ffff;
|
||||||
|
mEnclosingBlockOffsetHigh = (enclosing_block_offset & 0x007f0000) >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -112,6 +114,35 @@ namespace LLInitParam
|
|||||||
std::copy(src_block_data.mAllParams.begin(), src_block_data.mAllParams.end(), std::back_inserter(mAllParams));
|
std::copy(src_block_data.mAllParams.begin(), src_block_data.mAllParams.end(), std::back_inserter(mAllParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlockDescriptor::addParam(const ParamDescriptorPtr in_param, const char* char_name)
|
||||||
|
{
|
||||||
|
// create a copy of the param descriptor in mAllParams
|
||||||
|
// so other data structures can store a pointer to it
|
||||||
|
mAllParams.push_back(in_param);
|
||||||
|
ParamDescriptorPtr param(mAllParams.back());
|
||||||
|
|
||||||
|
std::string name(char_name);
|
||||||
|
if ((size_t)param->mParamHandle > mMaxParamOffset)
|
||||||
|
{
|
||||||
|
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.empty())
|
||||||
|
{
|
||||||
|
mUnnamedParams.push_back(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// don't use insert, since we want to overwrite existing entries
|
||||||
|
mNamedParams[name] = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->mValidationFunc)
|
||||||
|
{
|
||||||
|
mValidationList.push_back(std::make_pair(param->mParamHandle, param->mValidationFunc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BlockDescriptor::BlockDescriptor()
|
BlockDescriptor::BlockDescriptor()
|
||||||
: mMaxParamOffset(0),
|
: mMaxParamOffset(0),
|
||||||
mInitializationState(UNINITIALIZED),
|
mInitializationState(UNINITIALIZED),
|
||||||
@@ -150,7 +181,8 @@ namespace LLInitParam
|
|||||||
|
|
||||||
bool BaseBlock::submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent)
|
bool BaseBlock::submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent)
|
||||||
{
|
{
|
||||||
if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end()), true))
|
Parser::name_stack_range_t range = std::make_pair(name_stack.begin(), name_stack.end());
|
||||||
|
if (!deserializeBlock(p, range, true))
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
@@ -196,12 +228,7 @@ namespace LLInitParam
|
|||||||
if (serialize_func)
|
if (serialize_func)
|
||||||
{
|
{
|
||||||
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
|
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
|
||||||
// each param descriptor remembers its serial number
|
|
||||||
// so we can inspect the same param under different names
|
|
||||||
// and see that it has the same number
|
|
||||||
name_stack.push_back(std::make_pair("", true));
|
|
||||||
serialize_func(*param, parser, name_stack, diff_param);
|
serialize_func(*param, parser, name_stack, diff_param);
|
||||||
name_stack.pop_back();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +322,7 @@ namespace LLInitParam
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool ignored)
|
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t& name_stack_range, bool ignored)
|
||||||
{
|
{
|
||||||
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
||||||
bool names_left = name_stack_range.first != name_stack_range.second;
|
bool names_left = name_stack_range.first != name_stack_range.second;
|
||||||
@@ -308,15 +335,12 @@ namespace LLInitParam
|
|||||||
{
|
{
|
||||||
const std::string& top_name = name_stack_range.first->first;
|
const std::string& top_name = name_stack_range.first->first;
|
||||||
|
|
||||||
ParamDescriptor::deserialize_func_t deserialize_func = NULL;
|
|
||||||
Param* paramp = NULL;
|
|
||||||
|
|
||||||
BlockDescriptor::param_map_t::iterator found_it = block_data.mNamedParams.find(top_name);
|
BlockDescriptor::param_map_t::iterator found_it = block_data.mNamedParams.find(top_name);
|
||||||
if (found_it != block_data.mNamedParams.end())
|
if (found_it != block_data.mNamedParams.end())
|
||||||
{
|
{
|
||||||
// find pointer to member parameter from offset table
|
// find pointer to member parameter from offset table
|
||||||
paramp = getParamFromHandle(found_it->second->mParamHandle);
|
Param* paramp = getParamFromHandle(found_it->second->mParamHandle);
|
||||||
deserialize_func = found_it->second->mDeserializeFunc;
|
ParamDescriptor::deserialize_func_t deserialize_func = found_it->second->mDeserializeFunc;
|
||||||
|
|
||||||
Parser::name_stack_range_t new_name_stack(name_stack_range.first, name_stack_range.second);
|
Parser::name_stack_range_t new_name_stack(name_stack_range.first, name_stack_range.second);
|
||||||
++new_name_stack.first;
|
++new_name_stack.first;
|
||||||
@@ -358,36 +382,6 @@ namespace LLInitParam
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
|
||||||
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name)
|
|
||||||
{
|
|
||||||
// create a copy of the param descriptor in mAllParams
|
|
||||||
// so other data structures can store a pointer to it
|
|
||||||
block_data.mAllParams.push_back(in_param);
|
|
||||||
ParamDescriptorPtr param(block_data.mAllParams.back());
|
|
||||||
|
|
||||||
std::string name(char_name);
|
|
||||||
if ((size_t)param->mParamHandle > block_data.mMaxParamOffset)
|
|
||||||
{
|
|
||||||
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name.empty())
|
|
||||||
{
|
|
||||||
block_data.mUnnamedParams.push_back(param);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// don't use insert, since we want to overwrite existing entries
|
|
||||||
block_data.mNamedParams[name] = param;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (param->mValidationFunc)
|
|
||||||
{
|
|
||||||
block_data.mValidationList.push_back(std::make_pair(param->mParamHandle, param->mValidationFunc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseBlock::addSynonym(Param& param, const std::string& synonym)
|
void BaseBlock::addSynonym(Param& param, const std::string& synonym)
|
||||||
{
|
{
|
||||||
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
|
||||||
@@ -460,7 +454,7 @@ namespace LLInitParam
|
|||||||
if (merge_func)
|
if (merge_func)
|
||||||
{
|
{
|
||||||
Param* paramp = getParamFromHandle((*it)->mParamHandle);
|
Param* paramp = getParamFromHandle((*it)->mParamHandle);
|
||||||
llassert(paramp->mEnclosingBlockOffset == (*it)->mParamHandle);
|
llassert(paramp->getEnclosingBlockOffset() == (*it)->mParamHandle);
|
||||||
some_param_changed |= merge_func(*paramp, *other_paramp, overwrite);
|
some_param_changed |= merge_func(*paramp, *other_paramp, overwrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -223,10 +223,14 @@ LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser:
|
|||||||
{
|
{
|
||||||
bool new_traversal = it->second;
|
bool new_traversal = it->second;
|
||||||
|
|
||||||
LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first];
|
LLSD* child_sd;
|
||||||
|
if (it->first.empty())
|
||||||
if (child_sd->isArray())
|
|
||||||
{
|
{
|
||||||
|
child_sd = sd_to_write;
|
||||||
|
if (child_sd->isUndefined())
|
||||||
|
{
|
||||||
|
*child_sd = LLSD::emptyArray();
|
||||||
|
}
|
||||||
if (new_traversal)
|
if (new_traversal)
|
||||||
{
|
{
|
||||||
// write to new element at end
|
// write to new element at end
|
||||||
@@ -240,22 +244,7 @@ LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (new_traversal
|
sd_to_write = &(*sd_to_write)[it->first];
|
||||||
&& child_sd->isDefined()
|
|
||||||
&& !child_sd->isArray())
|
|
||||||
{
|
|
||||||
// copy child contents into first element of an array
|
|
||||||
LLSD new_array = LLSD::emptyArray();
|
|
||||||
new_array.append(*child_sd);
|
|
||||||
// assign array to slot that previously held the single value
|
|
||||||
*child_sd = new_array;
|
|
||||||
// return next element in that array
|
|
||||||
sd_to_write = &((*child_sd)[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sd_to_write = child_sd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
it->second = false;
|
it->second = false;
|
||||||
}
|
}
|
||||||
@@ -283,8 +272,9 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI
|
|||||||
it != sd.endArray();
|
it != sd.endArray();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
stack.back().second = true;
|
stack.push_back(make_pair(std::string(), true));
|
||||||
readSDValues(cb, *it, stack);
|
readSDValues(cb, *it, stack);
|
||||||
|
stack.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sd.isUndefined())
|
else if (sd.isUndefined())
|
||||||
@@ -313,8 +303,14 @@ namespace LLInitParam
|
|||||||
{
|
{
|
||||||
// LLSD specialization
|
// LLSD specialization
|
||||||
// block param interface
|
// block param interface
|
||||||
bool ParamValue<LLSD, TypeValues<LLSD>, false>::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name)
|
bool ParamValue<LLSD, NOT_BLOCK>::deserializeBlock(Parser& p, Parser::name_stack_range_t& name_stack, bool new_name)
|
||||||
{
|
{
|
||||||
|
if (name_stack.first == name_stack.second
|
||||||
|
&& p.readValue<LLSD>(mValue))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack);
|
LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack);
|
||||||
|
|
||||||
LLSD::String string;
|
LLSD::String string;
|
||||||
@@ -328,15 +324,18 @@ namespace LLInitParam
|
|||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack)
|
void ParamValue<LLSD, NOT_BLOCK>::serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack)
|
||||||
{
|
{
|
||||||
p.writeValue<LLSD::String>(sd.asString(), name_stack);
|
p.writeValue<LLSD::String>(sd.asString(), name_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const
|
void ParamValue<LLSD, NOT_BLOCK>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const
|
||||||
{
|
{
|
||||||
// read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc)
|
// attempt to write LLSD out directly
|
||||||
Parser::name_stack_t stack;
|
if (!p.writeValue<LLSD>(mValue, name_stack))
|
||||||
LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, stack);
|
{
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1112,6 +1112,13 @@ std::string LLFontGL::nameFromFont(const LLFontGL* fontp)
|
|||||||
return fontp->mFontDescriptor.getName();
|
return fontp->mFontDescriptor.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// static
|
||||||
|
std::string LLFontGL::sizeFromFont(const LLFontGL* fontp)
|
||||||
|
{
|
||||||
|
return fontp->getFontDesc().getSize();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::string LLFontGL::nameFromHAlign(LLFontGL::HAlign align)
|
std::string LLFontGL::nameFromHAlign(LLFontGL::HAlign align)
|
||||||
{
|
{
|
||||||
@@ -1228,6 +1235,41 @@ LLFontGL* LLFontGL::getFont(const LLFontDescriptor& desc)
|
|||||||
return sFontRegistry->getFont(desc);
|
return sFontRegistry->getFont(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
LLFontGL* LLFontGL::getFontByName(const std::string& name)
|
||||||
|
{
|
||||||
|
// check for most common fonts first
|
||||||
|
if (name == "SANSSERIF")
|
||||||
|
{
|
||||||
|
return getFontSansSerif();
|
||||||
|
}
|
||||||
|
else if (name == "SANSSERIF_SMALL")
|
||||||
|
{
|
||||||
|
return getFontSansSerifSmall();
|
||||||
|
}
|
||||||
|
else if (name == "SANSSERIF_BIG")
|
||||||
|
{
|
||||||
|
return getFontSansSerifBig();
|
||||||
|
}
|
||||||
|
else if (name == "SMALL" || name == "OCRA")
|
||||||
|
{
|
||||||
|
// *BUG: Should this be "MONOSPACE"? Do we use "OCRA" anymore?
|
||||||
|
// Does "SMALL" mean "SERIF"?
|
||||||
|
return getFontMonospace();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//static
|
||||||
|
LLFontGL* LLFontGL::getFontDefault()
|
||||||
|
{
|
||||||
|
return getFontSansSerif(); // Fallback to sans serif as default font
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::string LLFontGL::getFontPathSystem()
|
std::string LLFontGL::getFontPathSystem()
|
||||||
{
|
{
|
||||||
|
|||||||