mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-02-07 10:19:57 +08:00
Further small refactorings, tweaks.
This commit is contained in:
parent
55717cb115
commit
a8aa4ce273
@ -1286,7 +1286,7 @@ namespace chaiscript
|
||||
return m_stack_holder->stacks.back();
|
||||
}
|
||||
|
||||
parser::ChaiScript_Parser_Base &get_parser()
|
||||
parser::ChaiScript_Parser_Base &get_parser() const
|
||||
{
|
||||
return m_parser.get();
|
||||
}
|
||||
|
||||
@ -629,7 +629,7 @@ namespace chaiscript
|
||||
fpp.save_params(params);
|
||||
|
||||
try {
|
||||
retval = t_ss->call_member(m_fun_name, m_loc, std::move(params), has_function_params, t_ss.conversions());
|
||||
retval = t_ss->call_member(m_fun_name, m_loc, params, has_function_params, t_ss.conversions());
|
||||
}
|
||||
catch(const exception::dispatch_error &e){
|
||||
if (e.functions.empty())
|
||||
@ -1097,7 +1097,7 @@ namespace chaiscript
|
||||
vec.push_back(detail::clone_if_necessary(child->eval(t_ss), m_loc, t_ss));
|
||||
}
|
||||
}
|
||||
return const_var(std::move(vec));
|
||||
return const_var(vec);
|
||||
}
|
||||
catch (const exception::dispatch_error &) {
|
||||
throw exception::eval_error("Can not find appropriate 'clone' or copy constructor for vector elements");
|
||||
@ -1123,7 +1123,7 @@ namespace chaiscript
|
||||
detail::clone_if_necessary(child->children[1]->eval(t_ss), m_loc, t_ss)));
|
||||
}
|
||||
|
||||
return const_var(std::move(retval));
|
||||
return const_var(retval);
|
||||
}
|
||||
catch (const exception::dispatch_error &e) {
|
||||
throw exception::eval_error("Can not find appropriate copy constructor or 'clone' while inserting into Map.", e.parameters, e.functions, false, *t_ss);
|
||||
|
||||
@ -113,7 +113,7 @@ int main(int /*argc*/, char * /*argv*/[]) {
|
||||
//Call bound version of do_callbacks
|
||||
chai("do_callbacks()");
|
||||
|
||||
std::function<void ()> caller = chai.eval<std::function<void ()> >(
|
||||
const std::function<void ()> caller = chai.eval<std::function<void ()> >(
|
||||
R"(fun() { system.do_callbacks("From Functor"); })"
|
||||
);
|
||||
caller();
|
||||
@ -165,8 +165,8 @@ int main(int /*argc*/, char * /*argv*/[]) {
|
||||
chai.add(fun(&bound_log, std::string("Msg")), "BoundFun");
|
||||
|
||||
//Dynamic objects test
|
||||
chai.add(chaiscript::Proxy_Function(new dispatch::detail::Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
||||
chai.add(chaiscript::Proxy_Function(new dispatch::detail::Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
|
||||
chai.add(std::static_pointer_cast<dispatch::Proxy_Function_Base>(std::make_shared<dispatch::detail::Dynamic_Object_Function>("TestType", fun(&hello_world))), "hello_world");
|
||||
chai.add(std::static_pointer_cast<dispatch::Proxy_Function_Base>(std::make_shared<dispatch::detail::Dynamic_Object_Constructor>("TestType", fun(&hello_constructor))), "TestType");
|
||||
// chai.add(fun(std::function<Boxed_Value (dispatch::Dynamic_Object &)>(std::bind(&dispatch::detail::Dynamic_Object_Attribute::func, "TestType", "attr", std::placeholders::_1))), "attr");
|
||||
|
||||
chai.eval("var x = TestType()");
|
||||
|
||||
@ -75,7 +75,7 @@ int main()
|
||||
Factory f{};
|
||||
chai.add(chaiscript::var(&f), "f");
|
||||
|
||||
std::string script = R""(
|
||||
const std::string script = R""(
|
||||
f.make_entity(10,10,1,1,"entity1").updater = fun(e){ e.x += 1; e.y += 1 };
|
||||
f.make_entity(10,10,10,10,"entity2").updater = fun(e){ e.x += 2; e.y += 2 };
|
||||
f.make_entity(10,10,20,20,"entity3");
|
||||
|
||||
@ -272,6 +272,7 @@ int main(int argc, char *argv[])
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
// TODO:: Use _dupenv_s instead
|
||||
const char *usepath = getenv("CHAI_USE_PATH");
|
||||
const char *modulepath = getenv("CHAI_MODULE_PATH");
|
||||
|
||||
@ -375,7 +376,7 @@ int main(int argc, char *argv[])
|
||||
mode = eFile;
|
||||
}
|
||||
|
||||
chaiscript::Boxed_Value val; /* never accessed? */
|
||||
chaiscript::Boxed_Value val;
|
||||
try {
|
||||
switch (mode) {
|
||||
case eInteractive: interactive(chai); break;
|
||||
|
||||
@ -76,7 +76,7 @@ int main()
|
||||
chai.add(chaiscript::user_type<BaseClass>(), "BaseClass");
|
||||
chai.add(chaiscript::user_type<ChaiScriptDerived>(), "ChaiScriptDerived");
|
||||
|
||||
std::string script = R""(
|
||||
const std::string script = R""(
|
||||
def MakeDerived() {
|
||||
return ChaiScriptDerived(
|
||||
// create a dynamically created array and pass it in to the constructor
|
||||
|
||||
@ -4931,17 +4931,17 @@ inline void AssertionHandler::handleExceptionNotThrownAsExpected() {
|
||||
m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
|
||||
}
|
||||
|
||||
void AssertionHandler::handleUnexpectedExceptionNotThrown() {
|
||||
inline void AssertionHandler::handleUnexpectedExceptionNotThrown() {
|
||||
m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction );
|
||||
}
|
||||
|
||||
void AssertionHandler::handleThrowingCallSkipped() {
|
||||
inline void AssertionHandler::handleThrowingCallSkipped() {
|
||||
m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
|
||||
}
|
||||
|
||||
// This is the overload that takes a string and infers the Equals matcher from it
|
||||
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
|
||||
inline void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
|
||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
||||
}
|
||||
|
||||
@ -4950,11 +4950,11 @@ inline void AssertionHandler::handleExceptionNotThrownAsExpected() {
|
||||
// start catch_assertionresult.cpp
|
||||
|
||||
namespace Catch {
|
||||
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
|
||||
inline AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
|
||||
lazyExpression(_lazyExpression),
|
||||
resultType(_resultType) {}
|
||||
|
||||
std::string AssertionResultData::reconstructExpression() const {
|
||||
inline std::string AssertionResultData::reconstructExpression() const {
|
||||
|
||||
if( reconstructedExpression.empty() ) {
|
||||
if( lazyExpression ) {
|
||||
@ -4966,13 +4966,13 @@ namespace Catch {
|
||||
return reconstructedExpression;
|
||||
}
|
||||
|
||||
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
|
||||
inline AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
|
||||
: m_info( info ),
|
||||
m_resultData( data )
|
||||
{}
|
||||
|
||||
// Result was a success
|
||||
bool AssertionResult::succeeded() const {
|
||||
inline bool AssertionResult::succeeded() const {
|
||||
return Catch::isOk( m_resultData.resultType );
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user