This commit is contained in:
Lirusaito
2016-01-18 01:18:11 -05:00
32 changed files with 1176 additions and 1682 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -49,7 +49,7 @@ if (WINDOWS)
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP"
CACHE STRING "C++ compiler release-with-debug options" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP /fp:fast -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
"${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /Zo /MD /MP /Ob2 /Zc:inline /fp:fast -D_ITERATOR_DEBUG_LEVEL=0"
CACHE STRING "C++ compiler release options" FORCE)
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} ${LL_C_FLAGS} /O2 /Zi /MD /MP /fp:fast"
@@ -59,6 +59,27 @@ if (WINDOWS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif (WORD_SIZE EQUAL 32)
if (USE_LTO)
if(INCREMENTAL_LINK)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG:INCREMENTAL")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG:INCREMENTAL")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG:INCREMENTAL")
else(INCREMENTAL_LINK)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG")
endif(INCREMENTAL_LINK)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /OPT:ICF /LTCG")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG")
elseif (INCREMENTAL_LINK)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL /VERBOSE:INCR")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL /VERBOSE:INCR")
else ()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /INCREMENTAL:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /INCREMENTAL:NO")
endif ()
set(CMAKE_CXX_STANDARD_LIBRARIES "")
set(CMAKE_C_STANDARD_LIBRARIES "")
@@ -78,9 +99,17 @@ if (WINDOWS)
/Oy-
/Zm140
/wd4267
/wd4244
/wd4244
)
if (USE_LTO)
add_compile_options(
/GL
/Gy
/Gw
)
endif (USE_LTO)
if (WORD_SIZE EQUAL 32)
add_compile_options(/arch:SSE2)
endif (WORD_SIZE EQUAL 32)
@@ -288,7 +317,6 @@ if (STANDALONE)
add_definitions(-DLL_STANDALONE=1)
else (STANDALONE)
set(${ARCH}_linux_INCLUDES
ELFIO
atk-1.0
glib-2.0
gstreamer-0.10

View File

@@ -25,7 +25,6 @@ set(cmake_SOURCE_FILES
Cwdebug.cmake
DBusGlib.cmake
DeploySharedLibs.cmake
ELFIO.cmake
EXPAT.cmake
ExamplePlugin.cmake
FMODSTUDIO.cmake
@@ -34,7 +33,6 @@ set(cmake_SOURCE_FILES
FindBerkeleyDB.cmake
FindCARes.cmake
FindColladadom.cmake
FindELFIO.cmake
FindGLOD.cmake
FindGoogleBreakpad.cmake
FindGooglePerfTools.cmake

View File

@@ -1,22 +0,0 @@
# -*- cmake -*-
include(Prebuilt)
set(ELFIO_FIND_QUIETLY ON)
if (STANDALONE)
include(FindELFIO)
elseif (LINUX)
use_prebuilt_binary(elfio)
set(ELFIO_LIBRARIES ELFIO)
set(ELFIO_INCLUDE_DIR
${LIBS_PREBUILT_DIR}/include
${LIBS_PREBUILT_LEGACY_DIR}/include
)
set(ELFIO_FOUND "YES")
endif (STANDALONE)
if (ELFIO_FOUND)
add_definitions(-DLL_ELFBIN=1)
else (ELFIO_FOUND)
set(ELFIO_INCLUDE_DIR "")
endif (ELFIO_FOUND)

View File

@@ -1,48 +0,0 @@
# -*- cmake -*-
# - Find ELFIO
# Find the ELFIO includes and library
# This module defines
# ELFIO_INCLUDE_DIR, where to find elfio.h, etc.
# ELFIO_LIBRARIES, the libraries needed to use ELFIO.
# ELFIO_FOUND, If false, do not try to use ELFIO.
# also defined, but not for general use are
# ELFIO_LIBRARY, where to find the ELFIO library.
FIND_PATH(ELFIO_INCLUDE_DIR ELFIO/ELFIO.h
/usr/local/include
/usr/include
)
SET(ELFIO_NAMES ${ELFIO_NAMES} ELFIO)
FIND_LIBRARY(ELFIO_LIBRARY
NAMES ${ELFIO_NAMES}
PATHS /usr/lib /usr/local/lib
)
IF (ELFIO_LIBRARY AND ELFIO_INCLUDE_DIR)
SET(ELFIO_LIBRARIES ${ELFIO_LIBRARY})
SET(ELFIO_FOUND "YES")
ELSE (ELFIO_LIBRARY AND ELFIO_INCLUDE_DIR)
SET(ELFIO_FOUND "NO")
ENDIF (ELFIO_LIBRARY AND ELFIO_INCLUDE_DIR)
IF (ELFIO_FOUND)
IF (NOT ELFIO_FIND_QUIETLY)
MESSAGE(STATUS "Found ELFIO: ${ELFIO_LIBRARIES}")
ENDIF (NOT ELFIO_FIND_QUIETLY)
ELSE (ELFIO_FOUND)
IF (ELFIO_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find ELFIO library")
ENDIF (ELFIO_FIND_REQUIRED)
ENDIF (ELFIO_FOUND)
# Deprecated declarations.
SET (NATIVE_ELFIO_INCLUDE_PATH ${ELFIO_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_ELFIO_LIB_PATH ${ELFIO_LIBRARY} PATH)
MARK_AS_ADVANCED(
ELFIO_LIBRARY
ELFIO_INCLUDE_DIR
)

View File

@@ -28,7 +28,7 @@ else (LINUX)
set(LLCOMMON_LIBRARIES llcommon)
endif (LINUX)
set(LLCOMMON_LINK_SHARED ON CACHE BOOL "Build the llcommon target as a shared library.")
set(LLCOMMON_LINK_SHARED OFF CACHE BOOL "Build the llcommon target as a shared library.")
if(LLCOMMON_LINK_SHARED)
add_definitions(-DLL_COMMON_LINK_SHARED=1)
endif(LLCOMMON_LINK_SHARED)

View File

@@ -29,6 +29,8 @@ set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable f
# Compiler and toolchain options
set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)")
set(DISABLE_FATAL_WARNINGS TRUE CACHE BOOL "Set this to FALSE to enable fatal warnings.")
option(INCREMENTAL_LINK "Use incremental linking or incremental LTCG for LTO on win32 builds (enable for faster links on some machines)" OFF)
option(USE_LTO "Enable Whole Program Optimization and related folding and binary reduction routines" OFF)
if(LIBS_CLOSED_DIR)
file(TO_CMAKE_PATH "${LIBS_CLOSED_DIR}" LIBS_CLOSED_DIR)

View File

@@ -86,10 +86,10 @@ LLAssetType::EType LLWearable::getAssetType() const
return LLWearableType::getAssetType(mType);
}
BOOL LLWearable::exportFile(LLFILE* fp) const
BOOL LLWearable::exportFile(const std::string& filename) const
{
llofstream ofs(fp);
return exportStream(ofs);
llofstream ofs(filename.c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
return ofs.is_open() && exportStream(ofs);
}
// virtual
@@ -105,13 +105,13 @@ BOOL LLWearable::exportStream( std::ostream& output_stream ) const
output_stream << mDescription << "\n";
// permissions
if( !mPermissions.exportStream( output_stream ) )
if( !mPermissions.exportLegacyStream( output_stream ) )
{
return FALSE;
}
// sale info
if( !mSaleInfo.exportStream( output_stream ) )
if( !mSaleInfo.exportLegacyStream( output_stream ) )
{
return FALSE;
}
@@ -193,7 +193,7 @@ void LLWearable::createLayers(S32 te, LLAvatarAppearance *avatarp)
if (layer_set)
{
layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
}
else
{
@@ -201,10 +201,11 @@ void LLWearable::createLayers(S32 te, LLAvatarAppearance *avatarp)
}
}
LLWearable::EImportResult LLWearable::importFile(LLFILE* fp, LLAvatarAppearance* avatarp )
LLWearable::EImportResult LLWearable::importFile(const std::string& filename,
LLAvatarAppearance* avatarp )
{
llifstream ifs(fp);
return importStream(ifs, avatarp);
llifstream ifs(filename.c_str(), std::ios_base::in | std::ios_base::binary);
return (! ifs.is_open())? FAILURE : importStream(ifs, avatarp);
}
// virtual
@@ -287,7 +288,7 @@ LLWearable::EImportResult LLWearable::importStream( std::istream& input_stream,
LL_WARNS() << "Bad Wearable asset: missing valid permissions" << LL_ENDL;
return LLWearable::FAILURE;
}
if( !mPermissions.importStream( input_stream ) )
if( !mPermissions.importLegacyStream( input_stream ) )
{
return LLWearable::FAILURE;
}
@@ -312,7 +313,7 @@ LLWearable::EImportResult LLWearable::importStream( std::istream& input_stream,
// up the vast majority of the tasks.
BOOL has_perm_mask = FALSE;
U32 perm_mask = 0;
if( !mSaleInfo.importStream(input_stream, has_perm_mask, perm_mask) )
if( !mSaleInfo.importLegacyStream(input_stream, has_perm_mask, perm_mask) )
{
return LLWearable::FAILURE;
}

View File

@@ -82,8 +82,8 @@ public:
SUCCESS,
BAD_HEADER
};
BOOL exportFile(LLFILE* file) const;
EImportResult importFile(LLFILE* file, LLAvatarAppearance* avatarp );
BOOL exportFile(const std::string& filename) const;
EImportResult importFile(const std::string& filename, LLAvatarAppearance* avatarp );
virtual BOOL exportStream( std::ostream& output_stream ) const;
virtual EImportResult importStream( std::istream& input_stream, LLAvatarAppearance* avatarp );

View File

@@ -416,679 +416,76 @@ LLFILE * LLFile::_Fiopen(const std::string& filename,
#endif /* LL_WINDOWS */
/************** llstdio file buffer ********************************/
//llstdio_filebuf* llstdio_filebuf::open(const char *_Filename,
// ios_base::openmode _Mode)
//{
//#if LL_WINDOWS
// _Filet *_File;
// if (is_open() || (_File = LLFILE::_Fiopen(_Filename, _Mode)) == 0)
// return (0); // open failed
//
// _Init(_File, _Openfl);
// _Initcvt(&_USE(_Mysb::getloc(), _Cvt));
// return (this); // open succeeded
//#else
// std::filebuf* _file = std::filebuf::open(_Filename, _Mode);
// if (NULL == _file) return NULL;
// return this;
//#endif
//}
// *TODO: Seek the underlying c stream for better cross-platform compatibility?
#if !LL_WINDOWS
llstdio_filebuf::int_type llstdio_filebuf::overflow(llstdio_filebuf::int_type __c)
{
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = _M_mode & ios_base::out;
if (__testout && !_M_reading)
{
if (this->pbase() < this->pptr())
{
// If appropriate, append the overflow char.
if (!__testeof)
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
// Convert pending sequence to external representation,
// and output.
if (_convert_to_external(this->pbase(),
this->pptr() - this->pbase()))
{
_M_set_buffer(0);
__ret = traits_type::not_eof(__c);
}
}
else if (_M_buf_size > 1)
{
// Overflow in 'uncommitted' mode: set _M_writing, set
// the buffer to the initial 'write' mode, and put __c
// into the buffer.
_M_set_buffer(0);
_M_writing = true;
if (!__testeof)
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
__ret = traits_type::not_eof(__c);
}
else
{
// Unbuffered.
char_type __conv = traits_type::to_char_type(__c);
if (__testeof || _convert_to_external(&__conv, 1))
{
_M_writing = true;
__ret = traits_type::not_eof(__c);
}
}
}
return __ret;
}
bool llstdio_filebuf::_convert_to_external(char_type* __ibuf,
std::streamsize __ilen)
{
// Sizes of external and pending output.
streamsize __elen;
streamsize __plen;
if (__check_facet(_M_codecvt).always_noconv())
{
//__elen = _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
__elen = fwrite(reinterpret_cast<void*>(__ibuf), 1,
__ilen, _M_file.file());
__plen = __ilen;
}
else
{
// Worst-case number of external bytes needed.
// XXX Not done encoding() == -1.
streamsize __blen = __ilen * _M_codecvt->max_length();
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
char* __bend;
const char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen,
__iend, __buf, __buf + __blen, __bend);
if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__blen = __bend - __buf;
else if (__r == codecvt_base::noconv)
{
// Same as the always_noconv case above.
__buf = reinterpret_cast<char*>(__ibuf);
__blen = __ilen;
}
else
__throw_ios_failure(__N("llstdio_filebuf::_convert_to_external "
"conversion error"));
//__elen = _M_file.xsputn(__buf, __blen);
__elen = fwrite(__buf, 1, __blen, _M_file.file());
__plen = __blen;
// Try once more for partial conversions.
if (__r == codecvt_base::partial && __elen == __plen)
{
const char_type* __iresume = __iend;
streamsize __rlen = this->pptr() - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
if (__r != codecvt_base::error)
{
__rlen = __bend - __buf;
//__elen = _M_file.xsputn(__buf, __rlen);
__elen = fwrite(__buf, 1, __rlen, _M_file.file());
__plen = __rlen;
}
else
{
__throw_ios_failure(__N("llstdio_filebuf::_convert_to_external "
"conversion error"));
}
}
}
return __elen == __plen;
}
llstdio_filebuf::int_type llstdio_filebuf::underflow()
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
if (__testin)
{
if (_M_writing)
{
if (overflow() == traits_type::eof())
return __ret;
//_M_set_buffer(-1);
//_M_writing = false;
}
// Check for pback madness, and if so switch back to the
// normal buffers and jet outta here before expensive
// fileops happen...
_M_destroy_pback();
if (this->gptr() < this->egptr())
return traits_type::to_int_type(*this->gptr());
// Get and convert input sequence.
const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
// Will be set to true if ::fread() returns 0 indicating EOF.
bool __got_eof = false;
// Number of internal characters produced.
streamsize __ilen = 0;
codecvt_base::result __r = codecvt_base::ok;
if (__check_facet(_M_codecvt).always_noconv())
{
//__ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
// __buflen);
__ilen = fread(reinterpret_cast<void*>(this->eback()), 1,
__buflen, _M_file.file());
if (__ilen == 0)
__got_eof = true;
}
else
{
// Worst-case number of external bytes.
// XXX Not done encoding() == -1.
const int __enc = _M_codecvt->encoding();
streamsize __blen; // Minimum buffer size.
streamsize __rlen; // Number of chars to read.
if (__enc > 0)
__blen = __rlen = __buflen * __enc;
else
{
__blen = __buflen + _M_codecvt->max_length() - 1;
__rlen = __buflen;
}
const streamsize __remainder = _M_ext_end - _M_ext_next;
__rlen = __rlen > __remainder ? __rlen - __remainder : 0;
// An imbue in 'read' mode implies first converting the external
// chars already present.
if (_M_reading && this->egptr() == this->eback() && __remainder)
__rlen = 0;
// Allocate buffer if necessary and move unconverted
// bytes to front.
if (_M_ext_buf_size < __blen)
{
char* __buf = new char[__blen];
if (__remainder)
__builtin_memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf;
_M_ext_buf = __buf;
_M_ext_buf_size = __blen;
}
else if (__remainder)
__builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
_M_state_last = _M_state_cur;
do
{
if (__rlen > 0)
{
// Sanity check!
// This may fail if the return value of
// codecvt::max_length() is bogus.
if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
{
__throw_ios_failure(__N("llstdio_filebuf::underflow "
"codecvt::max_length() "
"is not valid"));
}
//streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
streamsize __elen = fread(_M_ext_end, 1,
__rlen, _M_file.file());
if (__elen == 0)
__got_eof = true;
else if (__elen == -1)
break;
//_M_ext_end += __elen;
}
char_type* __iend = this->eback();
if (_M_ext_next < _M_ext_end)
{
__r = _M_codecvt->in(_M_state_cur, _M_ext_next,
_M_ext_end, _M_ext_next,
this->eback(),
this->eback() + __buflen, __iend);
}
if (__r == codecvt_base::noconv)
{
size_t __avail = _M_ext_end - _M_ext_buf;
__ilen = std::min(__avail, __buflen);
traits_type::copy(this->eback(),
reinterpret_cast<char_type*>
(_M_ext_buf), __ilen);
_M_ext_next = _M_ext_buf + __ilen;
}
else
__ilen = __iend - this->eback();
// _M_codecvt->in may return error while __ilen > 0: this is
// ok, and actually occurs in case of mixed encodings (e.g.,
// XML files).
if (__r == codecvt_base::error)
break;
__rlen = 1;
} while (__ilen == 0 && !__got_eof);
}
if (__ilen > 0)
{
_M_set_buffer(__ilen);
_M_reading = true;
__ret = traits_type::to_int_type(*this->gptr());
}
else if (__got_eof)
{
// If the actual end of file is reached, set 'uncommitted'
// mode, thus allowing an immediate write without an
// intervening seek.
_M_set_buffer(-1);
_M_reading = false;
// However, reaching it while looping on partial means that
// the file has got an incomplete character.
if (__r == codecvt_base::partial)
__throw_ios_failure(__N("llstdio_filebuf::underflow "
"incomplete character in file"));
}
else if (__r == codecvt_base::error)
__throw_ios_failure(__N("llstdio_filebuf::underflow "
"invalid byte sequence in file"));
else
__throw_ios_failure(__N("llstdio_filebuf::underflow "
"error reading the file"));
}
return __ret;
}
std::streamsize llstdio_filebuf::xsgetn(char_type* __s, std::streamsize __n)
{
// Clear out pback buffer before going on to the real deal...
streamsize __ret = 0;
if (_M_pback_init)
{
if (__n > 0 && this->gptr() == this->eback())
{
*__s++ = *this->gptr();
this->gbump(1);
__ret = 1;
--__n;
}
_M_destroy_pback();
}
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n > __buflen we read directly instead of using the
// buffer repeatedly.
const bool __testin = _M_mode & ios_base::in;
const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
&& __testin && !_M_writing)
{
// First, copy the chars already present in the buffer.
const streamsize __avail = this->egptr() - this->gptr();
if (__avail != 0)
{
if (__avail == 1)
*__s = *this->gptr();
else
traits_type::copy(__s, this->gptr(), __avail);
__s += __avail;
this->gbump(__avail);
__ret += __avail;
__n -= __avail;
}
// Need to loop in case of short reads (relatively common
// with pipes).
streamsize __len;
for (;;)
{
//__len = _M_file.xsgetn(reinterpret_cast<char*>(__s), __n);
__len = fread(reinterpret_cast<void*>(__s), 1,
__n, _M_file.file());
if (__len == -1)
__throw_ios_failure(__N("llstdio_filebuf::xsgetn "
"error reading the file"));
if (__len == 0)
break;
__n -= __len;
__ret += __len;
if (__n == 0)
break;
__s += __len;
}
if (__n == 0)
{
_M_set_buffer(0);
_M_reading = true;
}
else if (__len == 0)
{
// If end of file is reached, set 'uncommitted'
// mode, thus allowing an immediate write without
// an intervening seek.
_M_set_buffer(-1);
_M_reading = false;
}
}
else
__ret += __streambuf_type::xsgetn(__s, __n);
return __ret;
}
std::streamsize llstdio_filebuf::xsputn(char_type const* __s, std::streamsize __n)
{
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n is sufficiently large we write directly instead of
// using the buffer.
streamsize __ret = 0;
const bool __testout = _M_mode & ios_base::out;
if (__check_facet(_M_codecvt).always_noconv()
&& __testout && !_M_reading)
{
// Measurement would reveal the best choice.
const streamsize __chunk = 1ul << 10;
streamsize __bufavail = this->epptr() - this->pptr();
// Don't mistake 'uncommitted' mode buffered with unbuffered.
if (!_M_writing && _M_buf_size > 1)
__bufavail = _M_buf_size - 1;
const streamsize __limit = std::min(__chunk, __bufavail);
if (__n >= __limit)
{
const streamsize __buffill = this->pptr() - this->pbase();
const char* __buf = reinterpret_cast<const char*>(this->pbase());
//__ret = _M_file.xsputn_2(__buf, __buffill,
// reinterpret_cast<const char*>(__s), __n);
if (__buffill)
{
__ret = fwrite(__buf, 1, __buffill, _M_file.file());
}
if (__ret == __buffill)
{
__ret += fwrite(reinterpret_cast<const char*>(__s), 1,
__n, _M_file.file());
}
if (__ret == __buffill + __n)
{
_M_set_buffer(0);
_M_writing = true;
}
if (__ret > __buffill)
__ret -= __buffill;
else
__ret = 0;
}
else
__ret = __streambuf_type::xsputn(__s, __n);
}
else
__ret = __streambuf_type::xsputn(__s, __n);
return __ret;
}
int llstdio_filebuf::sync()
{
return (_M_file.sync() == 0 ? 0 : -1);
}
#endif
#if LL_WINDOWS
/************** input file stream ********************************/
llifstream::llifstream() : _M_filebuf(),
#if LL_WINDOWS
std::istream(&_M_filebuf) {}
#else
std::istream()
llifstream::llifstream() : std::ifstream()
{
this->init(&_M_filebuf);
}
#endif
// explicit
llifstream::llifstream(const std::string& _Filename,
ios_base::openmode _Mode) : _M_filebuf(),
#if LL_WINDOWS
std::istream(&_M_filebuf)
llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode) :
std::ifstream(utf8str_to_utf16str(_Filename),
_Mode | ios_base::in)
{
if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::in) == 0)
{
_Myios::setstate(ios_base::failbit);
}
}
#else
std::istream()
{
this->init(&_M_filebuf);
this->open(_Filename.c_str(), _Mode | ios_base::in);
}
#endif
// explicit
llifstream::llifstream(const char* _Filename,
ios_base::openmode _Mode) : _M_filebuf(),
#if LL_WINDOWS
std::istream(&_M_filebuf)
{
if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0)
{
_Myios::setstate(ios_base::failbit);
}
}
#else
std::istream()
{
this->init(&_M_filebuf);
this->open(_Filename, _Mode | ios_base::in);
}
#endif
llifstream::llifstream(const char* _Filename, ios_base::openmode _Mode) :
std::ifstream(utf8str_to_utf16str(_Filename).c_str(),
_Mode | ios_base::in)
// explicit
llifstream::llifstream(_Filet *_File,
ios_base::openmode _Mode, size_t _Size) :
_M_filebuf(_File, _Mode, _Size),
#if LL_WINDOWS
std::istream(&_M_filebuf) {}
#else
std::istream()
{
this->init(&_M_filebuf);
}
#endif
#if !LL_WINDOWS
// explicit
llifstream::llifstream(int __fd,
ios_base::openmode _Mode, size_t _Size) :
_M_filebuf(__fd, _Mode, _Size),
std::istream()
void llifstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
this->init(&_M_filebuf);
}
#endif
bool llifstream::is_open() const
{ // test if C stream has been opened
return _M_filebuf.is_open();
std::ifstream::open(utf8str_to_utf16str(_Filename),
_Mode | ios_base::in);
}
void llifstream::open(const char* _Filename, ios_base::openmode _Mode)
{ // open a C stream with specified mode
if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0)
#if LL_WINDOWS
{
_Myios::setstate(ios_base::failbit);
}
else
{
_Myios::clear();
}
#else
{
this->setstate(ios_base::failbit);
}
else
{
this->clear();
}
#endif
}
void llifstream::close()
{ // close the C stream
if (_M_filebuf.close() == 0)
{
#if LL_WINDOWS
_Myios::setstate(ios_base::failbit);
#else
this->setstate(ios_base::failbit);
#endif
}
{
std::ifstream::open(utf8str_to_utf16str(_Filename).c_str(),
_Mode | ios_base::in);
}
/************** output file stream ********************************/
llofstream::llofstream() : _M_filebuf(),
#if LL_WINDOWS
std::ostream(&_M_filebuf) {}
#else
std::ostream()
llofstream::llofstream() : std::ofstream()
{
this->init(&_M_filebuf);
}
#endif
// explicit
llofstream::llofstream(const std::string& _Filename,
ios_base::openmode _Mode) : _M_filebuf(),
#if LL_WINDOWS
std::ostream(&_M_filebuf)
llofstream::llofstream(const std::string& _Filename, ios_base::openmode _Mode) :
std::ofstream(utf8str_to_utf16str(_Filename),
_Mode | ios_base::out)
{
if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::out) == 0)
{
_Myios::setstate(ios_base::failbit);
}
}
#else
std::ostream()
{
this->init(&_M_filebuf);
this->open(_Filename.c_str(), _Mode | ios_base::out);
}
#endif
// explicit
llofstream::llofstream(const char* _Filename,
ios_base::openmode _Mode) : _M_filebuf(),
#if LL_WINDOWS
std::ostream(&_M_filebuf)
llofstream::llofstream(const char* _Filename, ios_base::openmode _Mode) :
std::ofstream(utf8str_to_utf16str(_Filename).c_str(),
_Mode | ios_base::out)
{
if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0)
{
_Myios::setstate(ios_base::failbit);
}
}
#else
std::ostream()
{
this->init(&_M_filebuf);
this->open(_Filename, _Mode | ios_base::out);
}
#endif
// explicit
llofstream::llofstream(_Filet *_File,
ios_base::openmode _Mode, size_t _Size) :
_M_filebuf(_File, _Mode, _Size),
#if LL_WINDOWS
std::ostream(&_M_filebuf) {}
#else
std::ostream()
void llofstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
this->init(&_M_filebuf);
}
#endif
#if !LL_WINDOWS
// explicit
llofstream::llofstream(int __fd,
ios_base::openmode _Mode, size_t _Size) :
_M_filebuf(__fd, _Mode, _Size),
std::ostream()
{
this->init(&_M_filebuf);
}
#endif
bool llofstream::is_open() const
{ // test if C stream has been opened
return _M_filebuf.is_open();
std::ofstream::open(utf8str_to_utf16str(_Filename),
_Mode | ios_base::out);
}
void llofstream::open(const char* _Filename, ios_base::openmode _Mode)
{ // open a C stream with specified mode
if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0)
#if LL_WINDOWS
{
_Myios::setstate(ios_base::failbit);
}
else
{
_Myios::clear();
}
#else
{
this->setstate(ios_base::failbit);
}
else
{
this->clear();
}
#endif
{
std::ofstream::open(utf8str_to_utf16str(_Filename).c_str(),
_Mode | ios_base::out);
}
void llofstream::close()
{ // close the C stream
if (_M_filebuf.close() == 0)
{
#if LL_WINDOWS
_Myios::setstate(ios_base::failbit);
#else
this->setstate(ios_base::failbit);
#endif
}
}
#endif // LL_WINDOWS
/************** helper functions ********************************/

View File

@@ -38,15 +38,13 @@
* Attempts to mostly mirror the POSIX style IO functions.
*/
typedef FILE LLFILE;
typedef FILE LLFILE;
#if LL_WINDOWS
// windows version of stat function and stat data structure are called _stat
typedef struct _stat llstat;
#else
typedef struct stat llstat;
#include <ext/stdio_filebuf.h>
#include <bits/postypes.h>
#endif
#ifndef S_ISREG
@@ -93,135 +91,20 @@ public:
static std::string strerr();
};
/**
* @brief Provides a layer of compatibility for C/POSIX.
*
* This is taken from both the GNU __gnu_cxx::stdio_filebuf extension and
* VC's basic_filebuf implementation.
* This file buffer provides extensions for working with standard C FILE*'s
* and POSIX file descriptors for platforms that support this.
*/
namespace
{
#if LL_WINDOWS
//typedef std::filebuf _Myfb;
//Singu note: Wrap around std::filebuf to override the open procedure.
// The client encodes filepaths in UTF-8, however Windows uses UTF-16 encoding natively.
// Need to convert paths to UTF-16 before calling std::filebuf::open.
struct _Myfb : public std::filebuf
{
_Myfb() : std::filebuf() {}
_Myfb(_Filet* file) : std::filebuf(file) {}
_Myt *open(const char *filename, std::ios_base::openmode mode, int prot = (int)std::ios_base::_Openprot)
{
return std::filebuf::open(utf8str_to_utf16str(filename).c_str(),mode,prot);
}
};
#if !defined(LL_WINDOWS)
typedef std::ifstream llifstream;
typedef std::ofstream llofstream;
#else
typedef __gnu_cxx::stdio_filebuf< char > _Myfb;
typedef std::__c_file _Filet;
#endif /* LL_WINDOWS */
}
class LL_COMMON_API llstdio_filebuf : public _Myfb
{
public:
/**
* deferred initialization / destruction
*/
llstdio_filebuf() : _Myfb() {}
virtual ~llstdio_filebuf() {}
/**
* @param f An open @c FILE*.
* @param mode Same meaning as in a standard filebuf.
* @param size Optimal or preferred size of internal buffer, in chars.
* Defaults to system's @c BUFSIZ.
*
* This constructor associates a file stream buffer with an open
* C @c FILE*. The @c FILE* will not be automatically closed when the
* stdio_filebuf is closed/destroyed.
*/
llstdio_filebuf(_Filet* __f, std::ios_base::openmode __mode,
//size_t __size = static_cast<size_t>(BUFSIZ)) :
size_t __size = static_cast<size_t>(1)) :
#if LL_WINDOWS
_Myfb(__f) {}
#else
_Myfb(__f, __mode, __size) {}
#endif
/**
* @brief Opens an external file.
* @param s The name of the file.
* @param mode The open mode flags.
* @return @c this on success, NULL on failure
*
* If a file is already open, this function immediately fails.
* Otherwise it tries to open the file named @a s using the flags
* given in @a mode.
*/
//llstdio_filebuf* open(const char *_Filename,
// std::ios_base::openmode _Mode);
/**
* @param fd An open file descriptor.
* @param mode Same meaning as in a standard filebuf.
* @param size Optimal or preferred size of internal buffer, in chars.
*
* This constructor associates a file stream buffer with an open
* POSIX file descriptor. The file descriptor will be automatically
* closed when the stdio_filebuf is closed/destroyed.
*/
#if !LL_WINDOWS
llstdio_filebuf(int __fd, std::ios_base::openmode __mode,
//size_t __size = static_cast<size_t>(BUFSIZ)) :
size_t __size = static_cast<size_t>(1)) :
_Myfb(__fd, __mode, __size) {}
#endif
// *TODO: Seek the underlying c stream for better cross-platform compatibility?
#if !LL_WINDOWS
protected:
/** underflow() and uflow() functions are called to get the next
* character from the real input source when the buffer is empty.
* Buffered input uses underflow()
*/
/*virtual*/ int_type underflow();
/* Convert internal byte sequence to external, char-based
* sequence via codecvt.
*/
bool _convert_to_external(char_type*, std::streamsize);
/** The overflow() function is called to transfer characters to the
* real output destination when the buffer is full. A call to
* overflow(c) outputs the contents of the buffer plus the
* character c.
* Consume some sequence of the characters in the pending sequence.
*/
/*virtual*/ int_type overflow(int_type __c = traits_type::eof());
/** sync() flushes the underlying @c FILE* stream.
*/
/*virtual*/ int sync();
std::streamsize xsgetn(char_type*, std::streamsize);
std::streamsize xsputn(char_type const*, std::streamsize);
#endif
};
/**
* @brief Controlling input for files.
*
* This class supports reading from named files, using the inherited
* functions from std::basic_istream. To control the associated
* sequence, an instance of std::basic_filebuf (or a platform-specific derivative)
* which allows construction using a pre-exisintg file stream buffer.
* We refer to this std::basic_filebuf (or derivative) as @c sb.
*/
class LL_COMMON_API llifstream : public std::istream
* functions from std::ifstream. The only added value is that our constructor
* Does The Right Thing when passed a non-ASCII pathname. Sadly, that isn't
* true of Microsoft's std::ifstream.
*/
class LL_COMMON_API llifstream : public std::ifstream
{
// input stream associated with a C stream
public:
@@ -247,56 +130,6 @@ public:
explicit llifstream(const char* _Filename,
ios_base::openmode _Mode = ios_base::in);
/**
* @brief Create a stream using an open c file stream.
* @param File An open @c FILE*.
@param Mode Same meaning as in a standard filebuf.
@param Size Optimal or preferred size of internal buffer, in chars.
Defaults to system's @c BUFSIZ.
*/
explicit llifstream(_Filet *_File,
ios_base::openmode _Mode = ios_base::in,
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
/**
* @brief Create a stream using an open file descriptor.
* @param fd An open file descriptor.
@param Mode Same meaning as in a standard filebuf.
@param Size Optimal or preferred size of internal buffer, in chars.
Defaults to system's @c BUFSIZ.
*/
#if !LL_WINDOWS
explicit llifstream(int __fd,
ios_base::openmode _Mode = ios_base::in,
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
#endif
/**
* @brief The destructor does nothing.
*
* The file is closed by the filebuf object, not the formatting
* stream.
*/
virtual ~llifstream() {}
// Members:
/**
* @brief Accessing the underlying buffer.
* @return The current basic_filebuf buffer.
*
* This hides both signatures of std::basic_ios::rdbuf().
*/
llstdio_filebuf* rdbuf() const
{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
/**
* @brief Wrapper to test for an open file.
* @return @c rdbuf()->is_open()
*/
bool is_open() const;
/**
* @brief Opens an external file.
* @param Filename The name of the file.
@@ -306,34 +139,21 @@ public:
* fails, @c failbit is set in the stream's error state.
*/
void open(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::in)
{ open(_Filename.c_str(), _Mode); }
ios_base::openmode _Mode = ios_base::in);
void open(const char* _Filename,
ios_base::openmode _Mode = ios_base::in);
/**
* @brief Close the file.
*
* Calls @c llstdio_filebuf::close(). If that function
* fails, @c failbit is set in the stream's error state.
*/
void close();
private:
llstdio_filebuf _M_filebuf;
};
/**
* @brief Controlling output for files.
*
* This class supports writing to named files, using the inherited
* functions from std::basic_ostream. To control the associated
* sequence, an instance of std::basic_filebuf (or a platform-specific derivative)
* which allows construction using a pre-exisintg file stream buffer.
* We refer to this std::basic_filebuf (or derivative) as @c sb.
*/
class LL_COMMON_API llofstream : public std::ostream
* This class supports writing to named files, using the inherited functions
* from std::ofstream. The only added value is that our constructor Does The
* Right Thing when passed a non-ASCII pathname. Sadly, that isn't true of
* Microsoft's std::ofstream.
*/
class LL_COMMON_API llofstream : public std::ofstream
{
public:
// Constructors:
@@ -351,64 +171,13 @@ public:
* @param Filename String specifying the filename.
* @param Mode Open file in specified mode (see std::ios_base).
*
* @c ios_base::out|ios_base::trunc is automatically included in
* @a mode.
* @c ios_base::out is automatically included in @a mode.
*/
explicit llofstream(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
explicit llofstream(const char* _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
/**
* @brief Create a stream using an open c file stream.
* @param File An open @c FILE*.
@param Mode Same meaning as in a standard filebuf.
@param Size Optimal or preferred size of internal buffer, in chars.
Defaults to system's @c BUFSIZ.
*/
explicit llofstream(_Filet *_File,
ios_base::openmode _Mode = ios_base::out,
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
/**
* @brief Create a stream using an open file descriptor.
* @param fd An open file descriptor.
@param Mode Same meaning as in a standard filebuf.
@param Size Optimal or preferred size of internal buffer, in chars.
Defaults to system's @c BUFSIZ.
*/
#if !LL_WINDOWS
explicit llofstream(int __fd,
ios_base::openmode _Mode = ios_base::out,
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
#endif
/**
* @brief The destructor does nothing.
*
* The file is closed by the filebuf object, not the formatting
* stream.
*/
virtual ~llofstream() {}
// Members:
/**
* @brief Accessing the underlying buffer.
* @return The current basic_filebuf buffer.
*
* This hides both signatures of std::basic_ios::rdbuf().
*/
llstdio_filebuf* rdbuf() const
{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
/**
* @brief Wrapper to test for an open file.
* @return @c rdbuf()->is_open()
*/
bool is_open() const;
/**
* @brief Opens an external file.
* @param Filename The name of the file.
@@ -418,23 +187,11 @@ public:
* fails, @c failbit is set in the stream's error state.
*/
void open(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc)
{ open(_Filename.c_str(), _Mode); }
ios_base::openmode _Mode = ios_base::out | ios_base::trunc);
void open(const char* _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
/**
* @brief Close the file.
*
* Calls @c llstdio_filebuf::close(). If that function
* fails, @c failbit is set in the stream's error state.
*/
void close();
private:
llstdio_filebuf _M_filebuf;
};
#endif
/**
* @breif filesize helpers.

View File

@@ -831,7 +831,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
}
else if(0 == strcmp("permissions", keyword))
{
success = mPermissions.importStream(input_stream);
success = mPermissions.importLegacyStream(input_stream);
}
else if(0 == strcmp("sale_info", keyword))
{
@@ -841,7 +841,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
// should pick up the vast majority of the tasks.
BOOL has_perm_mask = FALSE;
U32 perm_mask = 0;
success = mSaleInfo.importStream(input_stream, has_perm_mask, perm_mask);
success = mSaleInfo.importLegacyStream(input_stream, has_perm_mask, perm_mask);
if(has_perm_mask)
{
if(perm_mask == PERM_NONE)
@@ -957,7 +957,7 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu
output_stream << "\t\titem_id\t" << uuid_str << "\n";
mParentUUID.toString(uuid_str);
output_stream << "\t\tparent_id\t" << uuid_str << "\n";
mPermissions.exportStream(output_stream);
mPermissions.exportLegacyStream(output_stream);
// Check for permissions to see the asset id, and if so write it
// out as an asset id. Otherwise, apply our cheesy encryption.
@@ -991,7 +991,7 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu
std::string buffer;
buffer = llformat( "\t\tflags\t%08x\n", mFlags);
output_stream << buffer;
mSaleInfo.exportStream(output_stream);
mSaleInfo.exportLegacyStream(output_stream);
output_stream << "\t\tname\t" << mName.c_str() << "|\n";
output_stream << "\t\tdesc\t" << mDescription.c_str() << "|\n";
output_stream << "\t\tcreation_date\t" << mCreationDate << "\n";

View File

@@ -31,7 +31,6 @@
// library includes
#include "message.h"
#include "metapropertyt.h"
#include "llsd.h"
///----------------------------------------------------------------------------
@@ -572,17 +571,143 @@ void LLPermissions::unpackMessage(LLMessageSystem* msg, const char* block, S32 b
BOOL LLPermissions::importFile(LLFILE* fp)
{
llifstream ifs(fp);
return importStream(ifs);
init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
const S32 BUFSIZE = 16384;
// *NOTE: Changing the buffer size will require changing the scanf
// calls below.
char buffer[BUFSIZE]; /* Flawfinder: ignore */
char keyword[256]; /* Flawfinder: ignore */
char valuestr[256]; /* Flawfinder: ignore */
char uuid_str[256]; /* Flawfinder: ignore */
U32 mask;
keyword[0] = '\0';
valuestr[0] = '\0';
while (!feof(fp))
{
if (fgets(buffer, BUFSIZE, fp) == NULL)
{
buffer[0] = '\0';
}
sscanf( /* Flawfinder: ignore */
buffer,
" %255s %255s",
keyword, valuestr);
if (!strcmp("{", keyword))
{
continue;
}
if (!strcmp("}",keyword))
{
break;
}
else if (!strcmp("creator_mask", keyword))
{
// legacy support for "creator" masks
sscanf(valuestr, "%x", &mask);
mMaskBase = mask;
fixFairUse();
}
else if (!strcmp("base_mask", keyword))
{
sscanf(valuestr, "%x", &mask);
mMaskBase = mask;
//fixFairUse();
}
else if (!strcmp("owner_mask", keyword))
{
sscanf(valuestr, "%x", &mask);
mMaskOwner = mask;
}
else if (!strcmp("group_mask", keyword))
{
sscanf(valuestr, "%x", &mask);
mMaskGroup = mask;
}
else if (!strcmp("everyone_mask", keyword))
{
sscanf(valuestr, "%x", &mask);
mMaskEveryone = mask;
}
else if (!strcmp("next_owner_mask", keyword))
{
sscanf(valuestr, "%x", &mask);
mMaskNextOwner = mask;
}
else if (!strcmp("creator_id", keyword))
{
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
mCreator.set(uuid_str);
}
else if (!strcmp("owner_id", keyword))
{
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
mOwner.set(uuid_str);
}
else if (!strcmp("last_owner_id", keyword))
{
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
mLastOwner.set(uuid_str);
}
else if (!strcmp("group_id", keyword))
{
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
mGroup.set(uuid_str);
}
else if (!strcmp("group_owned", keyword))
{
sscanf(valuestr, "%d", &mask);
if(mask) mIsGroupOwned = true;
else mIsGroupOwned = false;
}
else
{
LL_INFOS() << "unknown keyword " << keyword << " in permissions import" << LL_ENDL;
}
}
fix();
return TRUE;
}
BOOL LLPermissions::exportFile(LLFILE* fp) const
{
llofstream ofs(fp);
return exportStream(ofs);
std::string uuid_str;
fprintf(fp, "\tpermissions 0\n");
fprintf(fp, "\t{\n");
fprintf(fp, "\t\tbase_mask\t%08x\n", mMaskBase);
fprintf(fp, "\t\towner_mask\t%08x\n", mMaskOwner);
fprintf(fp, "\t\tgroup_mask\t%08x\n", mMaskGroup);
fprintf(fp, "\t\teveryone_mask\t%08x\n", mMaskEveryone);
fprintf(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
mCreator.toString(uuid_str);
fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str.c_str());
mOwner.toString(uuid_str);
fprintf(fp, "\t\towner_id\t%s\n", uuid_str.c_str());
mLastOwner.toString(uuid_str);
fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str.c_str());
mGroup.toString(uuid_str);
fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str.c_str());
if(mIsGroupOwned)
{
fprintf(fp, "\t\tgroup_owned\t1\n");
}
fprintf(fp,"\t}\n");
return TRUE;
}
BOOL LLPermissions::importStream(std::istream& input_stream)
BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
{
init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
const S32 BUFSIZE = 16384;
@@ -601,18 +726,6 @@ BOOL LLPermissions::importStream(std::istream& input_stream)
while (input_stream.good())
{
input_stream.getline(buffer, BUFSIZE);
if (input_stream.eof())
{
LL_WARNS() << "Bad permissions: early end of input stream"
<< LL_ENDL;
return FALSE;
}
if (input_stream.fail())
{
LL_WARNS() << "Bad permissions: failed to read from input stream"
<< LL_ENDL;
return FALSE;
}
sscanf( /* Flawfinder: ignore */
buffer,
" %255s %255s",
@@ -695,26 +808,36 @@ BOOL LLPermissions::importStream(std::istream& input_stream)
}
BOOL LLPermissions::exportStream(std::ostream& output_stream) const
BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const
{
if (!output_stream.good()) return FALSE;
std::string uuid_str;
output_stream << "\tpermissions 0\n";
output_stream << "\t{\n";
char prev_fill = output_stream.fill('0');
output_stream << std::hex;
output_stream << "\t\tbase_mask\t" << std::setw(8) << mMaskBase << "\n";
output_stream << "\t\towner_mask\t" << std::setw(8) << mMaskOwner << "\n";
output_stream << "\t\tgroup_mask\t" << std::setw(8) << mMaskGroup << "\n";
output_stream << "\t\teveryone_mask\t" << std::setw(8) << mMaskEveryone << "\n";
output_stream << "\t\tnext_owner_mask\t" << std::setw(8) << mMaskNextOwner << "\n";
output_stream << std::dec;
output_stream.fill(prev_fill);
std::string buffer;
buffer = llformat( "\t\tbase_mask\t%08x\n", mMaskBase);
output_stream << buffer;
buffer = llformat( "\t\towner_mask\t%08x\n", mMaskOwner);
output_stream << buffer;
buffer = llformat( "\t\tgroup_mask\t%08x\n", mMaskGroup);
output_stream << buffer;
buffer = llformat( "\t\teveryone_mask\t%08x\n", mMaskEveryone);
output_stream << buffer;
buffer = llformat( "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
output_stream << buffer;
output_stream << "\t\tcreator_id\t" << mCreator << "\n";
output_stream << "\t\towner_id\t" << mOwner << "\n";
output_stream << "\t\tlast_owner_id\t" << mLastOwner << "\n";
output_stream << "\t\tgroup_id\t" << mGroup << "\n";
mCreator.toString(uuid_str);
output_stream << "\t\tcreator_id\t" << uuid_str << "\n";
mOwner.toString(uuid_str);
output_stream << "\t\towner_id\t" << uuid_str << "\n";
mLastOwner.toString(uuid_str);
output_stream << "\t\tlast_owner_id\t" << uuid_str << "\n";
mGroup.toString(uuid_str);
output_stream << "\t\tgroup_id\t" << uuid_str << "\n";
if(mIsGroupOwned)
{
@@ -772,21 +895,6 @@ std::ostream& operator<<(std::ostream &s, const LLPermissions &perm)
return s;
}
template <>
void LLMetaClassT<LLPermissions>::reflectProperties(LLMetaClass& meta_class)
{
reflectProperty(meta_class, "mCreator", &LLPermissions::mCreator);
reflectProperty(meta_class, "mOwner", &LLPermissions::mOwner);
reflectProperty(meta_class, "mGroup", &LLPermissions::mGroup);
reflectProperty(meta_class, "mIsGroupOwned", &LLPermissions::mIsGroupOwned);
}
// virtual
const LLMetaClass& LLPermissions::getMetaClass() const
{
return LLMetaClassT<LLPermissions>::instance();
}
///----------------------------------------------------------------------------
/// Class LLAggregatePermissions
///----------------------------------------------------------------------------
@@ -1021,7 +1129,7 @@ void mask_to_string(U32 mask, char* str)
else
{
*str = ' ';
}
}
str++;
if (mask & PERM_EXPORT)

View File

@@ -31,7 +31,6 @@
#include "llsd.h"
#include "lluuid.h"
#include "llxmlnode.h"
#include "reflective.h"
#include "llinventorytype.h"
// prototypes
@@ -89,7 +88,7 @@ enum ExportPolicy {
// logical consistency.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLPermissions : public LLReflective
class LLPermissions
{
private:
LLUUID mCreator; // null if object created by system
@@ -329,17 +328,14 @@ public:
BOOL importFile(LLFILE* fp);
BOOL exportFile(LLFILE* fp) const;
BOOL importStream(std::istream& input_stream);
BOOL exportStream(std::ostream& output_stream) const;
BOOL importLegacyStream(std::istream& input_stream);
BOOL exportLegacyStream(std::ostream& output_stream) const;
bool operator==(const LLPermissions &rhs) const;
bool operator!=(const LLPermissions &rhs) const;
friend std::ostream& operator<<(std::ostream &s, const LLPermissions &perm);
// Reflection.
friend class LLMetaClassT<LLPermissions>;
virtual const LLMetaClass& getMetaClass() const;
};
// Inlines

View File

@@ -87,13 +87,15 @@ U32 LLSaleInfo::getCRC32() const
BOOL LLSaleInfo::exportFile(LLFILE* fp) const
{
llofstream ofs(fp);
return exportStream(ofs);
fprintf(fp, "\tsale_info\t0\n\t{\n");
fprintf(fp, "\t\tsale_type\t%s\n", lookup(mSaleType));
fprintf(fp, "\t\tsale_price\t%d\n", mSalePrice);
fprintf(fp,"\t}\n");
return TRUE;
}
BOOL LLSaleInfo::exportStream(std::ostream& output_stream) const
BOOL LLSaleInfo::exportLegacyStream(std::ostream& output_stream) const
{
if (!output_stream.good()) return FALSE;
output_stream << "\tsale_info\t0\n\t{\n";
output_stream << "\t\tsale_type\t" << lookup(mSaleType) << "\n";
output_stream << "\t\tsale_price\t" << mSalePrice << "\n";
@@ -137,40 +139,25 @@ bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask)
// because I can't find any non-test code references to it. 2009-05-04 JC
BOOL LLSaleInfo::importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask)
{
llifstream ifs(fp);
return importStream(ifs, has_perm_mask, perm_mask);
}
BOOL LLSaleInfo::importStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask)
{
has_perm_mask = FALSE;
const S32 BUFSIZE = 16384;
// *NOTE: Changing the buffer size will require changing the scanf
// calls below.
char buffer[BUFSIZE]; /* Flawfinder: ignore */
char keyword[255]; /* Flawfinder: ignore */
char valuestr[255]; /* Flawfinder: ignore */
char buffer[MAX_STRING]; /* Flawfinder: ignore */
char keyword[MAX_STRING]; /* Flawfinder: ignore */
char valuestr[MAX_STRING]; /* Flawfinder: ignore */
BOOL success = TRUE;
keyword[0] = '\0';
valuestr[0] = '\0';
while(input_stream.good())
while(success && (!feof(fp)))
{
input_stream.getline(buffer, MAX_STRING);
if (input_stream.eof())
if (fgets(buffer, MAX_STRING, fp) == NULL)
{
LL_WARNS() << "Bad sale info: early end of input stream"
<< LL_ENDL;
return FALSE;
}
if (input_stream.fail())
{
LL_WARNS() << "Bad sale info: failed to read from input stream"
<< LL_ENDL;
return FALSE;
buffer[0] = '\0';
}
sscanf( /* Flawfinder: ignore */
buffer,
" %254s %254s",
@@ -208,7 +195,63 @@ BOOL LLSaleInfo::importStream(std::istream& input_stream, BOOL& has_perm_mask, U
<< "' in sale info import" << LL_ENDL;
}
}
return TRUE;
return success;
}
BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask)
{
has_perm_mask = FALSE;
// *NOTE: Changing the buffer size will require changing the scanf
// calls below.
char buffer[MAX_STRING]; /* Flawfinder: ignore */
char keyword[MAX_STRING]; /* Flawfinder: ignore */
char valuestr[MAX_STRING]; /* Flawfinder: ignore */
BOOL success = TRUE;
keyword[0] = '\0';
valuestr[0] = '\0';
while(success && input_stream.good())
{
input_stream.getline(buffer, MAX_STRING);
sscanf( /* Flawfinder: ignore */
buffer,
" %254s %254s",
keyword, valuestr);
if(!keyword[0])
{
continue;
}
if(0 == strcmp("{",keyword))
{
continue;
}
if(0 == strcmp("}", keyword))
{
break;
}
else if(0 == strcmp("sale_type", keyword))
{
mSaleType = lookup(valuestr);
}
else if(0 == strcmp("sale_price", keyword))
{
sscanf(valuestr, "%d", &mSalePrice);
mSalePrice = llclamp(mSalePrice, 0, S32_MAX);
}
else if (!strcmp("perm_mask", keyword))
{
//LL_INFOS() << "found deprecated keyword perm_mask" << LL_ENDL;
has_perm_mask = TRUE;
sscanf(valuestr, "%x", &perm_mask);
}
else
{
LL_WARNS() << "unknown keyword '" << keyword
<< "' in sale info import" << LL_ENDL;
}
}
return success;
}
void LLSaleInfo::setSalePrice(S32 price)

View File

@@ -95,11 +95,11 @@ public:
BOOL exportFile(LLFILE* fp) const;
BOOL importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask);
BOOL exportStream(std::ostream& output_stream) const;
BOOL exportLegacyStream(std::ostream& output_stream) const;
LLSD asLLSD() const;
operator LLSD() const { return asLLSD(); }
bool fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask);
BOOL importStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask);
BOOL importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask);
LLSD packMessage() const;
void unpackMessage(const LLSD& sales);

View File

@@ -13,6 +13,7 @@ set(llmath_SOURCE_FILES
llbbox.cpp
llbboxlocal.cpp
llcalc.cpp
llcalcparser.cpp
llcamera.cpp
llcoordframe.cpp
llline.cpp

View File

@@ -28,61 +28,59 @@
#include "llcalc.h"
#include "llcalcparser.h"
#include "llmath.h"
#include "llcalcparser.h"
// Variable names for use in the build floater
// must be lower case for parser definition
// case-insensitive for actual parsing
const char* LLCalc::X_POS = "px";
const char* LLCalc::Y_POS = "py";
const char* LLCalc::Z_POS = "pz";
const char* LLCalc::X_SCALE = "sx";
const char* LLCalc::Y_SCALE = "sy";
const char* LLCalc::Z_SCALE = "sz";
const char* LLCalc::X_ROT = "rx";
const char* LLCalc::Y_ROT = "ry";
const char* LLCalc::Z_ROT = "rz";
const char* LLCalc::HOLLOW = "hlw";
const char* LLCalc::CUT_BEGIN = "cb";
const char* LLCalc::CUT_END = "ce";
const char* LLCalc::PATH_BEGIN = "pb";
const char* LLCalc::PATH_END = "pe";
const char* LLCalc::TWIST_BEGIN = "tb";
const char* LLCalc::TWIST_END = "te";
const char* LLCalc::X_SHEAR = "shx";
const char* LLCalc::Y_SHEAR = "shy";
const char* LLCalc::X_TAPER = "tpx";
const char* LLCalc::Y_TAPER = "tpy";
const char* LLCalc::RADIUS_OFFSET = "rof";
const char* LLCalc::REVOLUTIONS = "rev";
const char* LLCalc::SKEW = "skw";
const char* LLCalc::X_HOLE = "hlx";
const char* LLCalc::Y_HOLE = "hly";
const char* LLCalc::TEX_U_SCALE = "tsu";
const char* LLCalc::TEX_V_SCALE = "tsv";
const char* LLCalc::TEX_U_OFFSET = "tou";
const char* LLCalc::TEX_V_OFFSET = "tov";
const char* LLCalc::TEX_ROTATION = "trot";
const char* LLCalc::TEX_TRANSPARENCY = "trns";
const char* LLCalc::TEX_GLOW = "glow";
const char* LLCalc::X_POS = "PX";
const char* LLCalc::Y_POS = "PY";
const char* LLCalc::Z_POS = "PZ";
const char* LLCalc::X_SCALE = "SX";
const char* LLCalc::Y_SCALE = "SY";
const char* LLCalc::Z_SCALE = "SZ";
const char* LLCalc::X_ROT = "RX";
const char* LLCalc::Y_ROT = "RY";
const char* LLCalc::Z_ROT = "RZ";
const char* LLCalc::HOLLOW = "HLW";
const char* LLCalc::CUT_BEGIN = "CB";
const char* LLCalc::CUT_END = "CE";
const char* LLCalc::PATH_BEGIN = "PB";
const char* LLCalc::PATH_END = "PE";
const char* LLCalc::TWIST_BEGIN = "TB";
const char* LLCalc::TWIST_END = "TE";
const char* LLCalc::X_SHEAR = "SHX";
const char* LLCalc::Y_SHEAR = "SHY";
const char* LLCalc::X_TAPER = "TPX";
const char* LLCalc::Y_TAPER = "TPY";
const char* LLCalc::RADIUS_OFFSET = "ROF";
const char* LLCalc::REVOLUTIONS = "REV";
const char* LLCalc::SKEW = "SKW";
const char* LLCalc::X_HOLE = "HLX";
const char* LLCalc::Y_HOLE = "HLY";
const char* LLCalc::TEX_U_SCALE = "TSU";
const char* LLCalc::TEX_V_SCALE = "TSV";
const char* LLCalc::TEX_U_OFFSET = "TOU";
const char* LLCalc::TEX_V_OFFSET = "TOV";
const char* LLCalc::TEX_ROTATION = "TROT";
const char* LLCalc::TEX_TRANSPARENCY = "TRNS";
const char* LLCalc::TEX_GLOW = "GLOW";
LLCalc* LLCalc::sInstance = NULL;
//TODO: Make this a static global class
LLCalc::LLCalc() : mLastErrorPos(0)
{
// Init table of constants
/*setVar("PI", F_PI);
setVar("TWO_PI", F_TWO_PI);
setVar("PI_BY_TWO", F_PI_BY_TWO);
setVar("SQRT_TWO_PI", F_SQRT_TWO_PI);
setVar("SQRT2", F_SQRT2);
setVar("SQRT3", F_SQRT3);
setVar("DEG_TO_RAD", DEG_TO_RAD);
setVar("RAD_TO_DEG", RAD_TO_DEG);
setVar("GRAVITY", GRAVITY);*/
mConstants["PI"] = F_PI;
mConstants["TWO_PI"] = F_TWO_PI;
mConstants["PI_BY_TWO"] = F_PI_BY_TWO;
mConstants["SQRT_TWO_PI"] = F_SQRT_TWO_PI;
mConstants["SQRT2"] = F_SQRT2;
mConstants["SQRT3"] = F_SQRT3;
mConstants["DEG_TO_RAD"] = DEG_TO_RAD;
mConstants["RAD_TO_DEG"] = RAD_TO_DEG;
mConstants["GRAVITY"] = GRAVITY;
}
LLCalc::~LLCalc()
@@ -99,7 +97,7 @@ void LLCalc::cleanUp()
//static
LLCalc* LLCalc::getInstance()
{
if (!sInstance) sInstance = new LLCalc();
if (!sInstance) sInstance = new LLCalc();
return sInstance;
}
@@ -118,35 +116,47 @@ void LLCalc::clearAllVariables()
mVariables.clear();
}
/*
void LLCalc::updateVariables(LLSD& vars)
{
LLSD::map_iterator cIt = vars.beginMap();
for(; cIt != vars.endMap(); cIt++)
{
setVar(cIt->first, (F32)(LLSD::Real)cIt->second);
}
}
*/
bool LLCalc::evalString(const std::string& expression, F32& result)
{
mLastErrorPos = 0;
std::string::const_iterator itr = expression.begin();
expression::grammar<F32,std::string::const_iterator> calc;
calc.constant.add
("pi", F_PI)
("two_pi", F_TWO_PI)
("pi_by_two", F_PI_BY_TWO)
("sqrt_two_pi", F_SQRT_TWO_PI)
("sqrt2", F_SQRT2)
("sqrt3", F_SQRT3)
("deg_to_rad", DEG_TO_RAD)
("rad_to_deg", RAD_TO_DEG)
("gravity", GRAVITY)
;
for(calc_map_t::const_iterator iter = mVariables.begin();
iter != mVariables.end();
++iter)
{
calc.constant.add(iter->first, iter->second);
}
std::string expr_upper = expression;
LLStringUtil::toUpper(expr_upper);
LLCalcParser calc(result, &mConstants, &mVariables);
if (!expression::parse<F32,std::string::const_iterator>(itr, expression.end(), calc, result) || itr != expression.end())
mLastErrorPos = 0;
std::string::iterator start = expr_upper.begin();
parse_info<std::string::iterator> info;
try
{
mLastErrorPos = itr - expression.begin();
info = parse(start, expr_upper.end(), calc, space_p);
LL_DEBUGS() << "Math expression: " << expression << " = " << result << LL_ENDL;
}
catch(parser_error<std::string, std::string::iterator> &e)
{
mLastErrorPos = e.where - expr_upper.begin();
LL_INFOS() << "Calc parser exception: " << e.descriptor << " at " << mLastErrorPos << " in expression: " << expression << LL_ENDL;
return false;
}
if (!info.full)
{
mLastErrorPos = info.stop - expr_upper.begin();
LL_INFOS() << "Unhandled syntax error at " << mLastErrorPos << " in expression: " << expression << LL_ENDL;
return false;
}
LL_DEBUGS() << "Math expression: " << expression << " = " << result << LL_ENDL;
return true;
}

View File

@@ -86,6 +86,7 @@ public:
private:
std::string::size_type mLastErrorPos;
calc_map_t mConstants;
calc_map_t mVariables;
// "There shall be only one"

View File

@@ -0,0 +1,63 @@
/*
* LLCalcParser.cpp
* Copyright 2008 Aimee Walton.
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2008, 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 "llcalcparser.h"
using namespace boost::spirit::classic;
F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const
{
LLCalc::calc_map_t::iterator iter;
std::string name(start, end);
if (mConstants)
{
iter = mConstants->find(name);
if (iter != mConstants->end())
{
return (*iter).second;
}
}
else
{
// This should never happen!
throw_(end, std::string("Missing constants table"));
}
if (mVariables)
{
iter = mVariables->find(name);
if (iter != mVariables->end())
{
return (*iter).second;
}
}
throw_(end, std::string("Unknown symbol " + name));
return 0.f;
}

View File

@@ -27,218 +27,162 @@
#ifndef LL_CALCPARSER_H
#define LL_CALCPARSER_H
#include <boost/spirit/version.hpp>
#if !defined(SPIRIT_VERSION) || SPIRIT_VERSION < 0x2010
#error "At least Spirit version 2.1 required"
#endif
#include <boost/spirit/include/classic_attribute.hpp>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_error_handling.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/phoenix1_binders.hpp>
#include <boost/spirit/include/classic_symbols.hpp>
using namespace boost::spirit::classic;
// Add this in if we want boost math constants.
#include <boost/bind.hpp>
#include "llcalc.h"
#include "llmath.h"
#if defined(LL_WINDOWS)
#pragma warning(push)
// warning C4348: 'boost::spirit::terminal<...>::result_helper': redefinition of default parameter: parameter 3, 4
#pragma warning(disable: 4348)
#endif
//#include <boost/math/constants/constants.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
#if defined(LL_WINDOWS)
#pragma warning(pop)
#endif
namespace expression {
//TODO: If we can find a better way to do this with boost::pheonix::bind lets do it
//namespace { // anonymous
template <typename T>
T min_glue(T a, T b)
struct LLCalcParser : grammar<LLCalcParser>
{
return std::min(a, b);
}
template <typename T>
T max_glue(T a, T b)
{
return std::max(a, b);
}
struct lazy_pow_
{
template <typename X, typename Y>
struct result { typedef X type; };
template <typename X, typename Y>
X operator()(X x, Y y) const
LLCalcParser(F32& result, LLCalc::calc_map_t* constants, LLCalc::calc_map_t* vars) :
mResult(result), mConstants(constants), mVariables(vars) {};
struct value_closure : closure<value_closure, F32>
{
return std::pow(x, y);
}
};
struct lazy_ufunc_
{
template <typename F, typename A1>
struct result { typedef A1 type; };
template <typename F, typename A1>
A1 operator()(F f, A1 a1) const
member1 value;
};
template <typename ScannerT>
struct definition
{
return f(a1);
}
};
struct lazy_bfunc_
{
template <typename F, typename A1, typename A2>
struct result { typedef A1 type; };
template <typename F, typename A1, typename A2>
A1 operator()(F f, A1 a1, A2 a2) const
{
return f(a1, a2);
}
};
//} // end namespace anonymous
template <typename FPT, typename Iterator>
struct grammar
: boost::spirit::qi::grammar<
Iterator, FPT(), boost::spirit::ascii::space_type
>
{
// symbol table for constants
// to be added by the actual calculator
struct constant_
: boost::spirit::qi::symbols<
typename std::iterator_traits<Iterator>::value_type,
FPT
>
{
constant_()
// Rule declarations
rule<ScannerT> statement, identifier;
rule<ScannerT, value_closure::context_t> expression, term,
power,
unary_expr,
factor,
unary_func,
binary_func,
group;
// start() should return the starting symbol
rule<ScannerT> const& start() const { return statement; }
definition(LLCalcParser const& self)
{
}
} constant;
// symbol table for unary functions like "abs"
struct ufunc_
: boost::spirit::qi::symbols<
typename std::iterator_traits<Iterator>::value_type,
FPT (*)(FPT)
>
{
ufunc_()
{
this->add
("abs" , (FPT (*)(FPT)) std::abs )
("acos" , (FPT (*)(FPT)) std::acos )
("asin" , (FPT (*)(FPT)) std::asin )
("atan" , (FPT (*)(FPT)) std::atan )
("ceil" , (FPT (*)(FPT)) std::ceil )
("cos" , (FPT (*)(FPT)) std::cos )
("cosh" , (FPT (*)(FPT)) std::cosh )
("exp" , (FPT (*)(FPT)) std::exp )
("floor" , (FPT (*)(FPT)) std::floor)
("log" , (FPT (*)(FPT)) std::log )
("log10" , (FPT (*)(FPT)) std::log10)
("sin" , (FPT (*)(FPT)) std::sin )
("sinh" , (FPT (*)(FPT)) std::sinh )
("sqrt" , (FPT (*)(FPT)) std::sqrt )
("tan" , (FPT (*)(FPT)) std::tan )
("tanh" , (FPT (*)(FPT)) std::tanh )
using namespace phoenix;
assertion<std::string> assert_domain("Domain error");
// assertion<std::string> assert_symbol("Unknown symbol");
assertion<std::string> assert_syntax("Syntax error");
identifier =
lexeme_d[(alpha_p | '_') >> *(alnum_p | '_')]
;
}
} ufunc;
// symbol table for binary functions like "pow"
struct bfunc_
: boost::spirit::qi::symbols<
typename std::iterator_traits<Iterator>::value_type,
FPT (*)(FPT, FPT)
>
{
bfunc_()
{
using boost::bind;
this->add
("pow" , (FPT (*)(FPT, FPT)) std::pow )
("atan2", (FPT (*)(FPT, FPT)) std::atan2)
("min" , (FPT (*)(FPT, FPT)) min_glue)
("max" , (FPT (*)(FPT, FPT)) max_glue)
group =
'(' >> expression[group.value = arg1] >> assert_syntax(ch_p(')'))
;
}
} bfunc;
boost::spirit::qi::rule<
Iterator, FPT(), boost::spirit::ascii::space_type
> expression, term, factor, primary;
grammar() : grammar::base_type(expression)
{
using boost::spirit::qi::real_parser;
using boost::spirit::qi::real_policies;
real_parser<FPT,real_policies<FPT> > real;
using boost::spirit::qi::_1;
using boost::spirit::qi::_2;
using boost::spirit::qi::_3;
using boost::spirit::qi::no_case;
using boost::spirit::qi::_val;
boost::phoenix::function<lazy_pow_> lazy_pow;
boost::phoenix::function<lazy_ufunc_> lazy_ufunc;
boost::phoenix::function<lazy_bfunc_> lazy_bfunc;
expression =
term [_val = _1]
>> *( ('+' >> term [_val += _1])
| ('-' >> term [_val -= _1])
unary_func =
((str_p("SIN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_sin)(self,arg1)]) |
(str_p("COS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_cos)(self,arg1)]) |
(str_p("TAN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_tan)(self,arg1)]) |
(str_p("ASIN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_asin)(self,arg1)]) |
(str_p("ACOS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_acos)(self,arg1)]) |
(str_p("ATAN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_atan)(self,arg1)]) |
(str_p("SQRT") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_sqrt)(self,arg1)]) |
(str_p("LOG") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_log)(self,arg1)]) |
(str_p("EXP") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_exp)(self,arg1)]) |
(str_p("ABS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_fabs)(self,arg1)]) |
(str_p("FLR") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_floor)(self,arg1)]) |
(str_p("CEIL") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_ceil)(self,arg1)])
) >> assert_syntax(ch_p(')'))
;
binary_func =
((str_p("ATAN2") >> '(' >> expression[binary_func.value = arg1] >> ',' >>
expression[binary_func.value = bind(&LLCalcParser::_atan2)(self, binary_func.value, arg1)]) |
(str_p("MIN") >> '(' >> expression[binary_func.value = arg1] >> ',' >>
expression[binary_func.value = bind(&LLCalcParser::_min)(self, binary_func.value, arg1)]) |
(str_p("MAX") >> '(' >> expression[binary_func.value = arg1] >> ',' >>
expression[binary_func.value = bind(&LLCalcParser::_max)(self, binary_func.value, arg1)])
) >> assert_syntax(ch_p(')'))
;
// *TODO: Localisation of the decimal point?
// Problem, LLLineEditor::postvalidateFloat accepts a comma when appropriate
// for the current locale. However to do that here could clash with using
// the comma as a separator when passing arguments to functions.
factor =
(ureal_p[factor.value = arg1] |
group[factor.value = arg1] |
unary_func[factor.value = arg1] |
binary_func[factor.value = arg1] |
// Lookup throws an Unknown Symbol error if it is unknown, while this works fine,
// would be "neater" to handle symbol lookup from here with an assertive parser.
// constants_p[factor.value = arg1]|
identifier[factor.value = bind(&LLCalcParser::lookup)(self, arg1, arg2)]
) >>
// Detect and throw math errors.
assert_domain(eps_p(bind(&LLCalcParser::checkNaN)(self, factor.value)))
;
unary_expr =
!ch_p('+') >> factor[unary_expr.value = arg1] |
'-' >> factor[unary_expr.value = -arg1]
;
power =
unary_expr[power.value = arg1] >>
*('^' >> assert_syntax(unary_expr[power.value = bind(&powf)(power.value, arg1)]))
;
term =
power[term.value = arg1] >>
*(('*' >> assert_syntax(power[term.value *= arg1])) |
('/' >> assert_syntax(power[term.value /= arg1])) |
('%' >> assert_syntax(power[term.value = bind(&fmodf)(term.value, arg1)]))
)
;
term =
factor [_val = _1]
>> *( ('*' >> factor [_val *= _1])
| ('/' >> factor [_val /= _1])
expression =
assert_syntax(term[expression.value = arg1]) >>
*(('+' >> assert_syntax(term[expression.value += arg1])) |
('-' >> assert_syntax(term[expression.value -= arg1]))
)
;
factor =
primary [_val = _1]
>> *( ("**" >> factor [_val = lazy_pow(_val, _1)])
)
statement =
!ch_p('=') >> ( expression )[var(self.mResult) = arg1] >> (end_p)
;
primary =
real [_val = _1]
| '(' >> expression [_val = _1] >> ')'
| ('-' >> primary [_val = -_1])
| ('+' >> primary [_val = _1])
| (no_case[ufunc] >> '(' >> expression >> ')')
[_val = lazy_ufunc(_1, _2)]
| (no_case[bfunc] >> '(' >> expression >> ','
>> expression >> ')')
[_val = lazy_bfunc(_1, _2, _3)]
| no_case[constant] [_val = _1]
;
}
}
};
private:
// Member functions for semantic actions
F32 lookup(const std::string::iterator&, const std::string::iterator&) const;
F32 _min(const F32& a, const F32& b) const { return llmin(a, b); }
F32 _max(const F32& a, const F32& b) const { return llmax(a, b); }
bool checkNaN(const F32& a) const { return !llisnan(a); }
//FIX* non ambiguous function fix making SIN() work for calc -Cryogenic Blitz
F32 _sin(const F32& a) const { return sin(DEG_TO_RAD * a); }
F32 _cos(const F32& a) const { return cos(DEG_TO_RAD * a); }
F32 _tan(const F32& a) const { return tan(DEG_TO_RAD * a); }
F32 _asin(const F32& a) const { return asin(a * RAD_TO_DEG); }
F32 _acos(const F32& a) const { return acos(a * RAD_TO_DEG); }
F32 _atan(const F32& a) const { return atan(a * RAD_TO_DEG); }
F32 _sqrt(const F32& a) const { return sqrt(a); }
F32 _log(const F32& a) const { return log(a); }
F32 _exp(const F32& a) const { return exp(a); }
F32 _fabs(const F32& a) const { return fabs(a); }
F32 _floor(const F32& a) const { return (F32)llfloor(a); }
F32 _ceil(const F32& a) const { return llceil(a); }
F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
LLCalc::calc_map_t* mConstants;
LLCalc::calc_map_t* mVariables;
// LLCalc::calc_map_t* mUserVariables;
F32& mResult;
};
template <typename FPT, typename Iterator>
bool parse(Iterator &iter,
Iterator end,
const grammar<FPT,Iterator> &g,
FPT &result)
{
return boost::spirit::qi::phrase_parse(
iter, end, g, boost::spirit::ascii::space, result);
}
} // end namespace expression
#endif // LL_CALCPARSER_H

View File

@@ -57,7 +57,7 @@ set_target_properties(SLPlugin
if (WINDOWS)
set_target_properties(SLPlugin
PROPERTIES
LINK_FLAGS "/OPT:NOREF"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\""
)
EMBED_MANIFEST(SLPlugin 1)
endif()

View File

@@ -13,7 +13,7 @@ include_directories(
)
set(llxml_SOURCE_FILES
aixml.cpp
#aixml.cpp
llcontrol.cpp
llxmlnode.cpp
llxmlparser.cpp
@@ -23,7 +23,7 @@ set(llxml_SOURCE_FILES
set(llxml_HEADER_FILES
CMakeLists.txt
aixml.h
#aixml.h
llcontrol.h
llcontrolgroupreader.h
llxmlnode.h

View File

@@ -8,7 +8,6 @@ include(BuildPackagesInfo)
include(BuildVersion)
include(CMakeCopyIfDifferent)
include(DBusGlib)
include(ELFIO)
include(FMODSTUDIO)
include(GLOD)
include(FindOpenGL)
@@ -53,7 +52,6 @@ include_directories(
${STATEMACHINE_INCLUDE_DIRS}
${DBUSGLIB_INCLUDE_DIRS}
${HUNSPELL_INCLUDE_DIR}
${ELFIO_INCLUDE_DIR}
${JSONCPP_INCLUDE_DIR}
${GLOD_INCLUDE_DIRS}
${LLAUDIO_INCLUDE_DIRS}
@@ -78,7 +76,7 @@ include_directories(
set(viewer_SOURCE_FILES
NACLantispam.cpp
aihttpview.cpp
aixmllindengenepool.cpp
#aixmllindengenepool.cpp
alfloaterregiontracker.cpp
aoremotectrl.cpp
ascentfloatercontactgroups.cpp
@@ -609,7 +607,7 @@ set(viewer_HEADER_FILES
NACLantispam.h
aihttpview.h
aixmllindengenepool.h
#aixmllindengenepool.h
alfloaterregiontracker.h
aoremotectrl.h
ascentfloatercontactgroups.h
@@ -1656,24 +1654,25 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${UI_LIBRARIES}
${WINDOWS_LIBRARIES}
${XMLRPCEPI_LIBRARIES}
${ELFIO_LIBRARIES}
${HUNSPELL_LIBRARY}
${LLPHYSICSEXTENSIONS_LIBRARIES}
${LLAPPEARANCE_LIBRARIES}
)
if (LINUX)
add_custom_command(
OUTPUT secondlife-stripped
COMMAND strip
ARGS --strip-debug -o secondlife-stripped ${VIEWER_BINARY_NAME}
DEPENDS ${VIEWER_BINARY_NAME}
)
set(product Singularity-${ARCH}-${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION})
# These are the generated targets that are copied to package/
set(COPY_INPUT_DEPENDENCIES
${VIEWER_BINARY_NAME}
linux-crash-logger
AlchemyPlugin
media_plugin_gstreamer010
llcommon
)
add_dependencies(${VIEWER_BINARY_NAME} generate_viewer_version)
set(product ${VIEWER_BRANDING_NAME_CAMELCASE}-${ARCH}-${${ROOT_PROJECT_NAME}_VERSION})
add_custom_command(
OUTPUT ${product}.tar.bz2
COMMAND ${PYTHON_EXECUTABLE}
@@ -1681,21 +1680,20 @@ if (LINUX)
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
--arch=${ARCH}
--artwork=${ARTWORK_DIR}
--branding_id=${VIEWER_BRANDING_ID}
--build=${CMAKE_CURRENT_BINARY_DIR}
--buildtype=${CMAKE_BUILD_TYPE}
--channel=${VIEWER_CHANNEL}
--versionfile=${CMAKE_CURRENT_BINARY_DIR}/viewer_version.txt
--configuration=${CMAKE_CFG_INTDIR}
--dest=${CMAKE_CURRENT_BINARY_DIR}/packaged
--grid=${GRID}
--installer_name=${product}
--login_channel=${VIEWER_LOGIN_CHANNEL}
--source=${CMAKE_CURRENT_SOURCE_DIR}
--standalone=${STANDALONE}
--touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched
--extra_libraries="${MANIFEST_LIBRARIES}"
DEPENDS
secondlife-stripped
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
${COPY_INPUT_DEPENDENCIES}
)
add_custom_command(
@@ -1706,28 +1704,27 @@ if (LINUX)
--arch=${ARCH}
--actions=copy
--artwork=${ARTWORK_DIR}
--branding_id=${VIEWER_BRANDING_ID}
--build=${CMAKE_CURRENT_BINARY_DIR}
--buildtype=${CMAKE_BUILD_TYPE}
--channel=${VIEWER_CHANNEL}
--configuration=${CMAKE_CFG_INTDIR}
--dest=${CMAKE_CURRENT_BINARY_DIR}/packaged
--grid=${GRID}
--installer_name=${product}
--login_channel=${VIEWER_LOGIN_CHANNEL}
--channel=${VIEWER_CHANNEL}
--versionfile=${CMAKE_CURRENT_BINARY_DIR}/viewer_version.txt
--source=${CMAKE_CURRENT_SOURCE_DIR}
--standalone=${STANDALONE}
--extra_libraries="${MANIFEST_LIBRARIES}"
DEPENDS
secondlife-stripped
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
${COPY_INPUT_DEPENDENCIES}
COMMENT "Performing viewer_manifest copy"
)
add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_gstreamer010 media_plugin_webkit basic_plugin_filepicker)
add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_gstreamer010 basic_plugin_filepicker)
add_custom_target(copy_l_viewer_manifest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.copy_touched)
if (PACKAGE)
add_custom_target(llpackage ALL DEPENDS ${product}.tar.bz2)
add_dependencies(llpackage copy_l_viewer_manifest)
check_message_template(llpackage)
endif (PACKAGE)
endif (LINUX)
@@ -1788,17 +1785,17 @@ if (DARWIN)
COMMAND ${PYTHON_EXECUTABLE}
ARGS
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
--arch=${ARCH}
--artwork=${ARTWORK_DIR}
--branding_id=${VIEWER_BRANDING_ID}
--build=${CMAKE_CURRENT_BINARY_DIR}
--buildtype=${CMAKE_BUILD_TYPE}
--channel=${VIEWER_CHANNEL}
--configuration=${CMAKE_CFG_INTDIR}
--dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app
--grid=${GRID}
--login_channel=${VIEWER_LOGIN_CHANNEL}
--channel=${VIEWER_CHANNEL}
--versionfile=${CMAKE_CURRENT_BINARY_DIR}/viewer_version.txt
--source=${CMAKE_CURRENT_SOURCE_DIR}
--extra_libraries="${MANIFEST_LIBRARIES}"
--touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched
DEPENDS
${VIEWER_BINARY_NAME}

View File

@@ -55,7 +55,7 @@
#include "statemachine/aifilepicker.h"
#include "hippogridmanager.h"
#include "aixmllindengenepool.h"
//#include "aixmllindengenepool.h"
#include "aifile.h"
using namespace LLAvatarAppearanceDefines;
@@ -314,6 +314,7 @@ void LLFloaterCustomize::onBtnImport()
void LLFloaterCustomize::onBtnImport_continued(AIFilePicker* filepicker)
{
#if 0
if (!filepicker->hasFilename())
{
// User canceled import.
@@ -456,6 +457,7 @@ void LLFloaterCustomize::onBtnImport_continued(AIFilePicker* filepicker)
{
AIAlert::add("AIXMLImportWearableTypeMismatch", args("[TYPE]", label)("[ARCHETYPENAME]", wearable_types));
}
#endif
}
// reX: new function
@@ -500,6 +502,7 @@ void LLFloaterCustomize::onBtnExport()
//static
void LLFloaterCustomize::onBtnExport_continued(LLViewerWearable* edit_wearable, AIFilePicker* filepicker)
{
#if 0
if (!filepicker->hasFilename())
{
// User canceled export.
@@ -527,6 +530,7 @@ void LLFloaterCustomize::onBtnExport_continued(LLViewerWearable* edit_wearable,
{
AIAlert::add_modal("AIXMLExportSuccess", AIArgs("[FILE]", filename));
}
#endif
}
void LLFloaterCustomize::onBtnOk()

View File

@@ -624,7 +624,7 @@ LLSD LLFloaterReporter::gatherReport()
std::ostringstream details;
details << "V" << LLVersionInfo::getVersion() << std::endl << std::endl; // client version moved to body of email for abuse reports
details << "V" << LLVersionInfo::getVersion() << std::endl; // client version moved to body of email for abuse reports
std::string object_name = getChild<LLUICtrl>("object_name")->getValue().asString();
if (!object_name.empty() && !mOwnerName.empty())

View File

@@ -42,7 +42,6 @@
#include "llinventoryfunctions.h"
#include "lllocaltextureobject.h"
#include "llpaneleditwearable.h"
#include "aixmllindengenepool.h"
using namespace LLAvatarAppearanceDefines;
@@ -136,7 +135,7 @@ LLWearable::EImportResult LLViewerWearable::importStream( std::istream& input_st
return result;
}
#if 0
AIArchetype LLViewerWearable::getArchetype(void) const
{
AIArchetype archetype(this);
@@ -150,7 +149,7 @@ AIArchetype LLViewerWearable::getArchetype(void) const
}
return archetype;
}
#endif
// Avatar parameter and texture definitions can change over time.
// This function returns true if parameters or textures have been added or removed
// since this wearable was created.
@@ -600,18 +599,7 @@ void LLViewerWearable::saveNewAsset() const
//LL_INFOS() << *this << LL_ENDL;
const std::string filename = asset_id_to_filename(mAssetID);
LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */
BOOL successful_save = FALSE;
if(fp && exportFile(fp))
{
successful_save = TRUE;
}
if(fp)
{
fclose(fp);
fp = NULL;
}
if(!successful_save)
if(! exportFile(filename))
{
std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str());
LL_WARNS() << buffer << LL_ENDL;

View File

@@ -29,7 +29,6 @@
#include "llwearable.h"
#include "llavatarappearancedefines.h"
#include "aixmllindengenepool.h"
class LLVOAvatar;
class LLAPRFile;
@@ -69,7 +68,9 @@ public:
/*virtual*/ EImportResult importStream( std::istream& input_stream, LLAvatarAppearance* avatarp );
// Singu extension.
#if 0
AIArchetype getArchetype(void) const;
#endif
void setParamsToDefaults();
void setTexturesToDefaults();

View File

@@ -111,7 +111,7 @@
#include "llsdutil.h"
#include "llfloaterexploreanimations.h"
#include "aixmllindengenepool.h"
//#include "aixmllindengenepool.h"
#include "aifile.h"
#include "llavatarname.h"
@@ -8670,6 +8670,7 @@ void LLVOAvatar::dumpArchetypeXML(const std::string& prefix, bool group_by_weara
void LLVOAvatar::dumpArchetypeXML_cont(std::string const& fullpath, bool group_by_wearables)
{
#if 0
try
{
AIFile outfile(fullpath, "wb");
@@ -8745,6 +8746,7 @@ void LLVOAvatar::dumpArchetypeXML_cont(std::string const& fullpath, bool group_b
{
AIAlert::add_modal("AIXMLdumpArchetypeXMLError", AIArgs("[FILE]", fullpath), error);
}
#endif
}

View File

@@ -1002,7 +1002,6 @@ class Linux_i686_Manifest(LinuxManifest):
self.path("libcollada14dom.so.2.2", "libcollada14dom.so")
self.path("libcrypto.so*")
self.path("libELFIO.so")
self.path("libssl.so*")
self.path("libtcmalloc_minimal.so.0")
self.path("libtcmalloc_minimal.so.0.2.2")
@@ -1058,7 +1057,6 @@ class Linux_x86_64_Manifest(LinuxManifest):
self.path("libcollada14dom.so.2.2", "libcollada14dom.so")
self.path("libcrypto.so.*")
self.path("libELFIO.so")
self.path("libjpeg.so*")
self.path("libpng*.so*")
self.path("libz.so*")

View File

@@ -33,6 +33,11 @@ set(basic_plugin_base_HEADER_FILES
basic_plugin_base.h
)
set_source_files_properties(${basic_plugin_base_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND basic_plugin_base_SOURCE_FILES ${basic_plugin_base_HEADER_FILES})
add_library(basic_plugin_base
${basic_plugin_base_SOURCE_FILES}
)

View File

@@ -47,6 +47,11 @@ set(media_plugin_base_HEADER_FILES
media_plugin_base.h
)
set_source_files_properties(${media_plugin_base_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND media_plugin_base_SOURCE_FILES ${media_plugin_base_HEADER_FILES})
add_library(media_plugin_base
${media_plugin_base_SOURCE_FILES}
)
@@ -54,8 +59,3 @@ add_library(media_plugin_base
target_link_libraries(media_plugin_base
${BASIC_PLUGIN_BASE_LIBRARIES}
)
add_dependencies(media_plugin_base
${BASIC_PLUGIN_BASE_LIBRARIES}
)