Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help() function to Lua "builtins." #798

Merged
merged 7 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions autobuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1669,11 +1669,11 @@
<key>creds</key>
<string>github</string>
<key>hash</key>
<string>c326445818c4e2e2177d5efde1dd59e7af0d6c9a</string>
<string>59bf3d96f9df4b6981c406abac5c46ae276f9b15</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://api.github.com/repos/secondlife/3p-luau/releases/assets/150694132</string>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.609-9567db9/luau-0.609-9567db9-darwin64-9567db9.tar.zst</string>
</map>
<key>name</key>
<string>darwin64</string>
Expand All @@ -1685,24 +1685,38 @@
<key>creds</key>
<string>github</string>
<key>hash</key>
<string>f3bd40eb043f2f36636d847747db20d0168f42dc</string>
<string>43e2cc2e6e94299f89655435002864925b640e16</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://api.github.com/repos/secondlife/3p-luau/releases/assets/150694133</string>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.609-9567db9/luau-0.609-9567db9-windows64-9567db9.tar.zst</string>
</map>
<key>name</key>
<string>windows64</string>
</map>
<key>linux64</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>549516ada483ddf276183f66b0a7c3d01e4ef1aa</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.609-9567db9/luau-0.609-9567db9-linux64-9567db9.tar.zst</string>
</map>
<key>name</key>
<string>linux64</string>
</map>
</map>
<key>license</key>
<string>MIT</string>
<key>license_file</key>
<string>LICENSES/lua.txt</string>
<string>LICENSES/luau.txt</string>
<key>copyright</key>
<string>Copyright (c) 2019-2023 Roblox Corporation, Copyright (c) 1994–2019 Lua.org, PUC-Rio.</string>
<key>version</key>
<string>0.609</string>
<string>0.609-9567db9</string>
<key>name</key>
<string>luau</string>
<key>description</key>
Expand Down Expand Up @@ -2509,8 +2523,6 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<string>https://bitbucket.org/lindenlab/3p-tracy</string>
<key>source_type</key>
<string>git</string>
<key>version</key>
<string>v0.8.1.578241</string>
</map>
<key>tut</key>
<map>
Expand Down
39 changes: 33 additions & 6 deletions indra/llcommon/llstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,36 @@ struct ll_convert_impl
TO operator()(const FROM& in) const;
};

// Use a function template to get the nice ll_convert<TO>(from_value) API.
/**
* somefunction(ll_convert(data))
* target = ll_convert(data)
* totype otherfunc(const fromtype& data)
* {
* // ...
* return ll_convert(data);
* }
* all infer both the FROM type and the TO type.
*/
template <typename FROM>
class ll_convert
{
private:
const FROM& mRef;

public:
ll_convert(const FROM& ref): mRef(ref) {}

template <typename TO>
inline operator TO() const
{
return ll_convert_impl<TO, FROM>()(mRef);
}
};

// When the TO type must be explicit, use a function template to get
// ll_convert_to<TO>(from_value) API.
template<typename TO, typename FROM>
TO ll_convert(const FROM& in)
TO ll_convert_to(const FROM& in)
{
return ll_convert_impl<TO, FROM>()(in);
}
Expand Down Expand Up @@ -574,8 +601,8 @@ inline size_t ll_convert_length<char> (const char* zstr) { return std::strl
// and longname(const string&, len) so calls written pre-ll_convert() will
// work. Most of these overloads will be unified once we turn on C++17 and can
// use std::string_view.
// It also uses aliasmacro to ensure that both ll_convert<OUTSTR>(const char*)
// and ll_convert<OUTSTR>(const string&) will work.
// It also uses aliasmacro to ensure that both ll_convert(const char*)
// and ll_convert(const string&) will work.
#define ll_convert_forms(aliasmacro, OUTSTR, INSTR, longname) \
LL_COMMON_API OUTSTR longname(const INSTR::value_type* in, size_t len); \
inline auto longname(const INSTR& in, size_t len) \
Expand Down Expand Up @@ -807,7 +834,7 @@ LL_COMMON_API std::string ll_convert_string_to_utf8_string(const std::string& in
template<typename STRING>
STRING windows_message(unsigned long error)
{
return ll_convert<STRING>(windows_message<std::wstring>(error));
return ll_convert(windows_message<std::wstring>(error));
}

/// There's only one real implementation
Expand Down Expand Up @@ -1780,7 +1807,7 @@ auto LLStringUtilBase<T>::getoptenv(const std::string& key) -> boost::optional<s
if (found)
{
// return populated boost::optional
return { ll_convert<string_type>(*found) };
return { ll_convert_to<string_type>(*found) };
}
else
{
Expand Down
Loading
Loading