Commit Graph

50 Commits (85f2447b3ddf7e4b91cd5963cb2e7668d48ab2a9)

Author SHA1 Message Date
Andrey Lihatskiy 85f2447b3d Merge branch 'main' into marchcat/a-merge
# Conflicts:
#	autobuild.xml
#	indra/llimage/llimage.cpp
#	indra/llui/llsearcheditor.cpp
#	indra/llui/llview.cpp
#	indra/newview/llagent.cpp
#	indra/newview/llappviewer.cpp
#	indra/newview/llfloatercamera.cpp
#	indra/newview/llfloatereditsky.cpp
#	indra/newview/llfloatereditwater.cpp
#	indra/newview/llinventoryfunctions.cpp
#	indra/newview/lloutfitgallery.cpp
#	indra/newview/lloutfitslist.cpp
#	indra/newview/llpanelgroupbulkban.cpp
#	indra/newview/llsidepanelappearance.cpp
#	indra/newview/llvovolume.cpp
2024-04-24 19:28:15 +03:00
Lars Næsbye Christensen ba4e7b989b llcommon: BOOL (int) to real bool/LSTATUS 2024-02-09 01:02:29 +02:00
Ansariel ba74152c82 Replace BOOST_FOREACH with standard C++ range-based for-loops 2024-01-09 20:44:50 +02:00
Nat Goodspeed f7d2d40b30 DRTVWR-587: Fix LL::apply(function, LLSD array).
We define a specialization of LLSDParam<const char*> to support passing an
LLSD object to a const char* function parameter. Needless to remark, passing
object.asString().c_str() would be Bad: destroying the temporary std::string
returned by asString() would immediately invalidate the pointer returned by
its c_str(). But when you pass LLSDParam<const char*>(object) as the
parameter, that specialization itself stores the std::string so the c_str()
pointer remains valid as long as the LLSDParam object does.

Then there's LLSDParam<LLSD>, used when we don't have the parameter type
available to select the LLSDParam specialization. LLSDParam<LLSD> defines a
templated conversion operator T() that constructs an LLSDParam<T> to provide
the actual parameter value. So far, so good.

The trouble was with the implementation of LLSDParam<LLSD>: it constructed a
_temporary_ LLSDParam<T>, implicitly called its operator T() and immediately
destroyed it. Destroying LLSDParam<const char*> destroyed its stored string,
thus invalidating the c_str() pointer before the target function was entered.

Instead, make LLSDParam<LLSD>::operator T() capture each LLSDParam<T> it
constructs, extending its lifespan to the lifespan of the LLSDParam<LLSD>
instance. For this, derive each LLSDParam specialization from LLSDParamBase, a
trivial base class that simply establishes the virtual destructor. We can then
capture any specialization as a pointer to LLSDParamBase.

Also restore LazyEventAPI tests on Mac.
2023-10-29 11:56:17 -04:00
Nat Goodspeed 7fcb2bdb05 DRTVWR-587: Make LLSDParam<LLSD> simplify type when delegating.
LLSDParam<LLSD> is the generic case, when we need to pass LLSDParam adapters
to some set of function parameters whose types we don't specifically know. Its
templated conversion operator notices the actual parameter type T and
delegates conversion to the specific LLSDParam<T> specialization.

But when T has picked up references, e.g. somewhere along the way in the
LL::apply() machinery, the compiler might not choose the desired conversion
because we don't have a sufficiently specific LLSDParam specialization.

LLSDParam<LLSD> can address that by using std::decay_t<T> when delegating to
the specific LLSDParam specialization. This removes references, const and
volatile.
2023-07-27 16:29:41 -04:00
Nat Goodspeed 2c894ecb25 DRTVWR-558: Extend LLEventDispatcher::add() overloads.
Add LL::always_return<T>(), which takes a callable and variadic arguments. It
calls the callable with those arguments and, if the returned type is
convertible to T, converts it and returns it. Otherwise it returns T().
always_return() is generalized from, and supersedes,
LLEventDispatcher::ReturnLLSD.

Add LL::function_arity<CALLABLE>, which extends
boost::function_types::function_arity by reporting results for both
std::function<CALLABLE> and boost::function<CALLABLE>. Use for
LL::apply(function, LLSD array) as well as for LLEventDispatcher.

Make LLEventDispatcher::add() overloads uniformly distinguish between a
callable (whether non-static member function or otherwise) that accepts a
single LLSD parameter, versus any other signature. Accepting exactly one LLSD
parameter signals that the callable will accept the composite arguments LLSD
blob, instead of asking LLEventDispatcher to unpack the arguments blob into
individual arguments.

Support add(subclass method) overloads for arbitrary-parameters methods as
well as for (const LLSD&) methods. Update tests accordingly: we need no longer
pass the boilerplate lambda instance getter that binds and returns 'this'.

Extract to the two LLEventDispatcher::make_invoker() overloads the LL::apply()
logic formerly found in ReturnLLSD.

Change lleventdispatcher_test.cpp tests from boost::bind(), which accepts
variadic arguments (even though it only passes a fixed set to the target
callable), to fixed-signature lambdas. This is because the revamped add()
overloads care about signature.

Add a test for a non-static method that accepts (const LLSD&), in other words
the composite arguments LLSD blob, and likewise returns LLSD.

(cherry picked from commit 95b787f7d7226ee9de79dfc9816f33c8bf199aad)
2023-07-13 12:49:09 -04:00
Nat Goodspeed 8ac35b6260 DRTVWR-558: Add apply_n(function, std::vector) for variadics.
apply_n(function, LLSD array) has been useful, so for completeness, add the
corresponding function for std::vector.

Add a reference to apply_n() in comments for both apply() functions.

(cherry picked from commit dfb63a92e0e9a419931caf5112e1f590924e0867)
2023-07-13 12:47:58 -04:00
Nat Goodspeed 07c5645f5f DRTVWR-558: LLEventDispatcher uses LL::apply(), not boost::fusion.
While calling a C++ function with arguments taken from a runtime-variable data
structure necessarily involves a bit of hocus-pocus, the best you can say for
the boost::fusion based implementation is that it worked. Sadly, template
recursion limited its applicability to a handful of function arguments. Now
that we have LL::apply(), use that instead. This implementation is much more
straightforward.

In particular, the LLSDArgsSource class, whose job was to dole out elements of
an LLSD array one at a time for the template recursion, goes away entirely.

Make virtual LLEventDispatcher::DispatchEntry::call() return LLSD instead of
void. All LLEventDispatcher target functions so far have been void; any
function that wants to respond to its invoker must do so explicitly by calling
sendReply() or constructing an LLEventAPI::Response instance. Supporting non-
void functions permits LLEventDispatcher to respond implicitly with the
returned value. Of course this requires a wrapper for void target functions
that returns LLSD::isUndefined().

Break out LLEventDispatcher::reply() from callFail(), so we can reply with
success as well as failure.

Make LLEventDispatcher::try_call_log() prepend the actual leaf class name and
description to any error returned by three-arg try_call(). That try_call()
overload reported "LLEventDispatcher(desc): " for a couple specific errors,
but no others. Hoist to try_call_log() to apply uniformly.

Introduce new try_call_one() method to diagnose name-not-found errors and
catch internal DispatchError and LL::apply_error exceptions. try_call_one()
returns a std::pair, containing either an error message or an LLSD value.

Make try_call_log() and three-arg try_call() accept LLSD 'name' instead of
plain std::string, allowing for the possibility of an array or map. That lets
us extend three-arg try_call() to break out new cases for the function selector
LLSD: isUndefined(), isArray(), isMap() and (current case) scalar String.

If try_call_one() reports an error, log it and try to send reply, as now. If
it returns LLSD::isUndefined(), e.g. from a void target function wrapper, do
nothing. But if it returns an LLSD map, try to send that back to the invoker.
And if it returns an LLSD scalar or array, wrap it in a map with key "data" to
respond to the invoker. Allowing a target function to return its result rather
than explicitly sending it opens the possibility of batched requests
(aggregate 'name') returning batched responses.

Almost every place that constructs LLEventDispatcher's internal DispatchError
exception called stringize() to format the what() string. Simplify calls by
making DispatchError accept variadic arguments and forward to stringize().

Add LL::invoke() to apply.h. Like LL::apply(), this is a (limited) C++14
foreshadowing of std::invoke(), with preprocessor conditionals to switch to
std::invoke() when that's available. Introduce LL::invoke() to handle a
callable that's actually a pointer to method.

Now our C++14 apply() implementation can accept pointer to method, using
invoke() to generalize the actual function call.

Also anticipate std::bind_front() with LL::bind_front(). For apply(func,
std::array) and our extensions apply(func, std::vector) and apply(func, LLSD),
we can't pass a pointer to method as the func unless the second argument
happens to be an array or vector of pointers (or references) to instances of
exactly the right class -- and of course LLSD can't store such at all. It's
tempting to pass std::bind(std::mem_fn(ptr_to_method), instance), but that
won't work: std::bind() requires a value or placeholder for each argument to
pass to the bound function. The bind() expression above would only work for a
nullary method. std::bind_front() would work, but that doesn't arrive until
C++20. Again, once we get there we'll defer to the std:: implementation.

Instead of the generic __cplusplus, check the appropriate feature-test macro
for availability of each of std::invoke(), std::apply() and std::bind_front().

Change apply() error handling from assert() to new LL::apply_error exception.
LLEventDispatcher must be able to intercept apply() errors. Move validation
and synthesis of the relevant error message to new apply.cpp source file.

Add to llptrto.h new LL::get_ref() and LL::get_ptr() template functions to
unify the cases of a calling template accepting either a pointer or a
reference. Wrapping the parameter in either get_ref() or get_ptr() allows
dereferencing the parameter as desired.

Move LL::apply(function, LLSD) argument validation/manipulation to a non-
template function in llsdutil.cpp: no need to replicate that logic in the
template for every CALLABLE specialization.

The trouble with passing bind_front(std::mem_fn(ptr_to_method), instance) to
apply() is that since bind_front() accepts and forwards variadic additional
arguments, apply() can't infer the arity of the bound ptr_to_method. Address
that by introducing apply_n<arity>(function, LLSD), permitting a caller to
infer the arity of ptr_to_method and explicitly pass it to apply_n().

Polish up lleventdispatcher_test.cpp accordingly. Wrong LLSD type and wrong
number of arguments now produce different (somewhat more informative) error
messages. Moreover, passing too many entries in an LLSD array used to work:
the extra arguments used to be ignored. Now we require that the size of the
array match the arity of the target function. Change the too-many-arguments
tests from success testing to error testing.

Replace 'foreach' aka BOOST_FOREACH macro invocations with range 'for'.
Replace STRINGIZE(item0 << item1 << ...) with stringize(item0, item1, ...).

(cherry picked from commit 9c049563b5480bb7e8ed87d9313822595b479c3b)
2023-07-13 12:47:45 -04:00
Nat Goodspeed 196e49c1f8 DRTVWR-558: Add unit test for VAPPLY().
Add to apply_test.cpp a collect() function that incrementally accumulates an
arbitrary number of arguments into a std::vector<std::string>. Construct a
std::array<std::string> to pass it, using VAPPLY().

Clarify in header comments that LL::apply() can't call a variadic function
with arguments of dynamic size: std::vector or LLSD. The compiler can deduce
how many arguments to pass to a function with a fixed argument list; it can
deduce how many arguments to pass to a variadic function with a fixed number
of arguments. But it can't compile a call to a variadic function with an
arguments data structure whose size can vary at runtime.

(cherry picked from commit ceed33396266b123896f7cfb9b90abdf240e1eec)
2023-07-13 12:34:31 -04:00
Nat Goodspeed c682603417 DRTVWR-558: Extend LL::apply() to LLSD array arguments.
Make apply(function, std::array) and apply(function, std::vector) available
even when we borrow the C++17 implementation of apply(function, std::tuple).

Add apply(function, LLSD) with interpretations:

* isUndefined() is treated as an empty array, for calling a nullary function
* scalar LLSD is treated as a single-entry array, for calling a unary function
* isArray() converts function parameters using LLSDParam
* isMap() is an error.

Add unit tests for all flavors of LL::apply().

(cherry picked from commit 3006c24251c6259d00df9e0f4f66b8a617e6026d)
2023-07-13 12:34:12 -04:00
Nat Goodspeed e7c5b9fb0f SL-19647: Eliminate LLSDArray entirely.
Newer C++ compilers have different semantics around LLSDArray's special copy
constructor, which was essential to proper LLSD nesting. In short, we can no
longer trust LLSDArray to behave correctly. Now that we have variadic
functions, get rid of LLSDArray and replace every reference with llsd::array().
2023-05-03 17:38:30 -04:00
Nat Goodspeed a9b82b9d89 SL-15393: Use non-overloaded name for function returning LLSD&. 2021-06-24 02:07:40 +03:00
Nicky Dasmijn 7d5a4d71ac Put hash for boost namespace properly into that by using namespace boost 2020-07-22 06:48:15 +03:00
Nat Goodspeed 61ec84b1d8 DRTVWR-476: Add llsd::clone(), llsd::shallow() aliases
for new llsd_clone(), llsd_shallow() functions.
2020-05-06 16:16:06 -04:00
Nat Goodspeed ca6f092929 DRTVWR-476: Merge branch 'master' of lindenlab/viewer into DRTVWR-476-boost-1.72 2020-05-06 16:06:26 -04:00
Nat Goodspeed 52d15b6445 DRTVWR-476: Add llsd::array() and llsd::map() variadic functions.
llsd::array(), as one might suspect, takes an arbitrary number of arguments of
arbitrary convertible types and returns an LLSD::Array constructed from those
elements. This supercedes the older LLSDArray class.

llsd::map() takes an even number of arguments paired as (LLSD::String,
arbitrary convertible type) and returns an LLSD::Map constructed from those
(key, value) pairs. This supercedes the older LLSDMap class.

These two functions not only have a simpler API -- arbitrary function
arguments rather than an (arg list)(arg list) sequence -- but also
specifically return a final LLSD object, rather than needing conversion to
LLSD from the LLSDArray or LLSDMap object.

Also support LLSD == LLSD and LLSD != LLSD comparisons, using llsd_equals()
with default exact-float-equality semantics.
2020-03-25 18:52:10 -04:00
Nat Goodspeed a2379d6871 SL-11216: Add llsd::drill() function to drill into an LLSD blob.
We include both const and non-const overloads. The latter returns LLSD&, so
you can assign to the located element.

In fact we already implemented the non-const logic in a less public form as
storeToLLSDPath() in lleventcoro.cpp. Reimplement the latter to use the new
llsd::drill() function.
2020-03-25 16:01:31 -04:00
Rider Linden e2e63598d4 Merge 2018-02-26 09:29:38 -08:00
Rider Linden d7dd10b88b Split for viewer/simhost sync LLSD with simhost. 2017-11-30 11:32:22 -08:00
Rider Linden 28b98374da Mac compile does not like not having a default even if it does nothing. 2017-11-27 11:12:29 -08:00
Rider Linden 66ba27cb91 Added boost::hash<> spec for LLSD 2017-11-27 10:19:43 -08:00
Oz Linden 436119268d add convenience function ll_stream_notation_sd for compact representation of llsd 2016-08-11 14:08:49 -04:00
Oz Linden c8726aba30 remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
callum_linden 5c5821b758 Update to build on Xcode 6.0: clang warned about comparison of unsigned int to >=0 - correct ifx here is to retype the variable as signed 2014-10-17 14:01:08 -07:00
Richard Linden e40065f82c BUILDFIX: #include and dependency cleanup 2013-07-19 15:03:05 -07:00
Graham Madarasz bf6182daa8 Update Mac and Windows breakpad builds to latest 2013-03-29 07:50:08 -07:00
Richard Linden 5a14a67e06 converted a bunch of narrowing implicit conversions to explicit 2012-02-01 13:03:46 -08:00
Nat Goodspeed d814e76cad Introduce BOOST_FOREACH() helpers for LLSD in llsdutil.h.
You can't directly write:
BOOST_FOREACH(LLSD item, someLLSDarray) { ... }
because LLSD has two distinct iteration mechanisms, one for arrays and one for
maps, neither using the standard [const_]iterator typedefs or begin()/end()
methods. But with these helpers, you can write:
BOOST_FOREACH(LLSD item, llsd::inArray(someLLSDarray)) { ... }
or
BOOST_FOREACH(const llsd::MapEntry& pair, llsd::inMap(someLLSDmap)) { ... }
These are in namespace llsd instead of being (e.g.) llsd_inMap because with a
namespace at least your .cpp file can have a local 'using':
using namespace llsd;
BOOST_FOREACH(LLSD item, inArray(someLLSDarray)) { ... }
It's namespace llsd rather than LLSD because LLSD can't be both a namespace
and a class name.
2011-02-03 22:54:16 -05:00
Nat Goodspeed 8b7c903e5c Fix a couple gotchas in LLSDArray, LLSDParam, llsd_equals().
Nested LLSDArray expressions, e.g.:
LLSD array_of_arrays(LLSDArray(LLSDArray(17)(34))
                              (LLSDArray("x")("y")));
would quietly produce bad results because the outermost LLSDArray was being
constructed with the compiler's implicit LLSDArray(const LLSDArray&) rather
than LLSDArray(const LLSD&) as the reader assumes. Fixed with an explicit copy
constructor to Do The Right Thing.
Generalized LLSDParam<float> specialization into a macro to resolve similar
conversion ambiguities for float, LLUUID, LLDate, LLURI and LLSD::Binary.
Added optional bits= argument to llsd_equals() to permit comparing embedded
Real values using is_approx_equal_fraction() rather than strictly bitwise.
Omitting bits= retains current bitwise-comparison behavior.
2011-01-31 18:00:58 -05:00
Nat Goodspeed 2770d6f881 Introduce LLSDArray, LLSDMap, LLSDParam.
LLSDArray is a helper to construct an LLSD::Array value inline.
LLSDMap is a helper to construct an LLSD::Map value inline.
LLSDParam is a customization point, a way for generic code to support
unforseen parameter types as conversion targets for LLSD values.
2011-01-28 20:14:38 -05:00
Oz Linden 06b0d72efa Change license from GPL to LGPL (version 2.1) 2010-08-13 07:24:57 -04:00
palmer@eniac54.lindenlab.com 1af41b3ba7 Fixes to build on linux for DEV-35401.
Moves libllcommon.so to a staging dir for unit tests to work
and gets rid of LL_COMMON_API in forward declarations
2009-07-30 18:52:34 -07:00
Brad Kittenbrink 7fe359b293 Added new LL_COMMON_API dll export declaration for new llsd_equals function. 2009-05-29 01:34:21 +00:00
Nat Goodspeed a81c084deb Add llsd_equals(), a function whose absence sorely puzzles me 2009-05-26 22:36:38 +00:00
Brad Kittenbrink 01d390825a DEV-27646 dll linkage for login module.
Ok, finally got this to a point where it doesn't break the build and I can check
in. llcommon can be built as a shared library (disabled but can be enabled with
cmake cache var LLCOMMON_LINK_SHARED.

reviewed by Mani on tuesday (I still need to get his suggested changes
re-reviewed)
2009-05-22 23:27:16 +00:00
Nat Goodspeed dc93462991 svn merge -r113003:119136 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-2 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-3 2009-05-11 20:05:46 +00:00
Steven Bennetts a4000c3744 merge trunk@116587 skinning-7@119389 -> viewer-2.0.0-skinning-7 2009-05-08 07:43:08 +00:00
Aaron Brashears e3cf284388 Result of svn merge -r107256:107258 svn+ssh://svn/svn/user/phoenix/license_2009_merge into trunk. QAR-1165 2009-01-08 00:05:06 +00:00
Jon Wolk ae464867e6 svn merge -r 90938:92097 svn+ssh://svn.lindenlab.com/svn/linden/branches/qar-730/qar-730-merge -> release. This is for QAR-730: Combination merge of QAR-432 and QAR-601 2008-07-15 00:41:08 +00:00
Bryan O'Sullivan 9db949eec3 svn merge -r88066:88786 svn+ssh://svn.lindenlab.com/svn/linden/branches/cmake-9-merge
dataserver-is-deprecated
for-fucks-sake-whats-with-these-commit-markers
2008-06-02 21:14:31 +00:00
Josh Bell a089a401ee svn merge -r 84911:86069 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-21-Server --> release
Backport fixes made in the production branch to the trunk now that it is live on the grid:
* DEV-14443 Launcher not producing colo prefix when looking up sim class
* DEV-10840 "/etc/init.d/backbone stop" returns before all child backbones exited; "backbone restart" results in defunct children
* DEV-12558: Able to make anyone's object shout error messages
* QAR-483 user start location migration prelude
* QAR-490 havok4-6
* Revert havok4-5/4-6 code changes causing parcel access check issues
* Revert QAR-277 sqlite-backbone
* DEV-12357 SEC-53: Script that crashes regions
* QAR-486 New proc and query for Web Classifieds Fix
2008-04-28 19:40:54 +00:00
Dave Kaprielian 68988bddeb svn merge -r84476:84911 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-21-Server
Includes pullout of migrate-start-location-2, webservice changes made to 1.20, DEV-7229, and other web-ds changes. Reviewed by Josh.
2008-04-16 00:28:54 +00:00
Aaron Brashears 3f08a67dc6 Result of svn merge -r84383:84400 svn+ssh://svn/svn/linden/branches/migrate-start-location-2 intinto release. QAR-458 2008-04-09 18:03:28 +00:00
Jon Wolk 7dd08303a3 svn merge -r 75354:76103 svn+ssh://svn.lindenlab.com/svn/linden/branches/voice-group-moderation-3 -> release. Finished product of QAR-134 2007-12-19 00:56:59 +00:00
Aaron Brashears 5595a99623 Result of svn merge -r71162:71205 svn+ssh://svn/svn/linden/branches/new-license into release. only changes files which are not deployed or the comments section of code. 2007-10-04 23:19:43 +00:00
Aaron Brashears f118e7c80b result of merge manually performed through diff and patch. svn diff svn+ssh://svn/svn/linden/release@63615 svn+ssh://svn/svn/linden/branches/release-candidate@63637 | patch -p0 in release 2007-06-13 18:02:37 +00:00
Don Kjer 4ecb9cb63e svn merge -r 59163:61099 svn+ssh://svn/svn/linden/branches/release-candidate into release 2007-05-01 21:39:25 +00:00
Steven Bennetts 934e15973e merge release@57486 release-candidate@57503 2007-01-31 19:36:32 +00:00
Josh Bell fc664e93e6 Port fix for SL-32157 "PowerPC Mac crashes when crossing regions or teleporting with capabilities turned on" from Branch 1-13-2 r56710 via partial merge of release-candidate -r 56743:56744 2007-01-15 19:49:52 +00:00
James Cook 420b91db29 Print done when done. 2007-01-02 08:33:20 +00:00