Skip to content

Commit

Permalink
Merge 019ea57 into 6c10f18
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed Dec 17, 2014
2 parents 6c10f18 + 019ea57 commit 9aca261
Show file tree
Hide file tree
Showing 23 changed files with 638 additions and 404 deletions.
12 changes: 12 additions & 0 deletions .decent_ci-Linux.yaml
@@ -1,12 +1,24 @@
compilers:
- name: "clang"
version: "3.5"
skip_packaging: true
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
- name: "clang"
build_tag: AddressSanitizer
version: "3.5"
skip_packaging: true
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_ADDRESS_SANITIZER:BOOL=ON
- name: "clang"
build_tag: ThreadSanitizer
version: "3.5"
skip_packaging: true
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_THREAD_SANITIZER:BOOL=ON
- name: "gcc"
version: "4.8"
cmake_extra_flags: -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DBUILD_TESTING:BOOL=ON
- name: "gcc"
version: "4.6"
skip_packaging: true
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
- name: cppcheck
compiler_extra_flags: --enable=all -I include --inline-suppr
Expand Down
1 change: 1 addition & 0 deletions .decent_ci-MacOS.yaml
Expand Up @@ -4,4 +4,5 @@ compilers:
- name: clang
build_type: Debug
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=$COMMIT_SHA
skip_packaging: true

2 changes: 2 additions & 0 deletions .decent_ci-Windows.yaml
Expand Up @@ -3,11 +3,13 @@ compilers:
version: 14
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA%
compiler_extra_flags: /ANALYZE
skip_packaging: true
- name: Visual Studio
version: 14
architecture: Win64
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA%
compiler_extra_flags: /ANALYZE
skip_packaging: true
- name: Visual Studio
version: 12
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA%
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Expand Up @@ -232,6 +232,8 @@ if(BUILD_SAMPLES)
target_link_libraries(memory_leak_test ${LIBS})
add_executable(inheritance samples/inheritance.cpp)
target_link_libraries(inheritance ${LIBS})
add_executable(fun_call_performance samples/fun_call_performance.cpp)
target_link_libraries(fun_call_performance ${LIBS})
endif()


Expand Down Expand Up @@ -294,6 +296,10 @@ if(BUILD_TESTING)
target_link_libraries(object_lifetime_test ${LIBS})
add_test(NAME Object_Lifetime_Test COMMAND object_lifetime_test)

add_executable(object_lifetime_test2 unittests/object_lifetime_test2.cpp)
target_link_libraries(object_lifetime_test2 ${LIBS})
add_test(NAME Object_Lifetime_Test2 COMMAND object_lifetime_test2)

add_executable(function_ordering_test unittests/function_ordering_test.cpp)
target_link_libraries(function_ordering_test ${LIBS})
add_test(NAME Function_Ordering_Test COMMAND function_ordering_test)
Expand Down
6 changes: 3 additions & 3 deletions include/chaiscript/dispatchkit/bootstrap.hpp
Expand Up @@ -202,12 +202,12 @@ namespace chaiscript

static void print(const std::string &s)
{
std::cout << s;
fwrite(s.c_str(), 1, s.size(), stdout);
}

static void println(const std::string &s)
{
std::cout << s << std::endl;
puts(s.c_str());
}


Expand Down Expand Up @@ -443,7 +443,7 @@ namespace chaiscript
operators::assign<bool>(m);
operators::equal<bool>(m);

m->add(fun(&to_string<const std::string &>), "to_string");
m->add(fun<std::string (const std::string &t_ss)>([](const std::string &s) -> std::string { return s; }), "to_string");
m->add(fun(&Bootstrap::bool_to_string), "to_string");
m->add(fun(&unknown_assign), "=");
m->add(fun(&throw_exception), "throw");
Expand Down
4 changes: 2 additions & 2 deletions include/chaiscript/dispatchkit/boxed_cast.hpp
Expand Up @@ -89,13 +89,13 @@ namespace chaiscript
if (t_conversions && t_conversions->convertable_type<Type>())
{
try {
// std::cout << "trying an up conversion " << typeid(Type).name() << std::endl;
// std::cout << "trying an up conversion " << typeid(Type).name() << '\n';
// We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it
// either way, we are not responsible if it doesn't work
return detail::Cast_Helper<Type>::cast(t_conversions->boxed_type_conversion<Type>(bv), t_conversions);
} catch (...) {
try {
// std::cout << "trying a down conversion " << typeid(Type).name() << std::endl;
// std::cout << "trying a down conversion " << typeid(Type).name() << '\n';
// try going the other way - down the inheritance graph
return detail::Cast_Helper<Type>::cast(t_conversions->boxed_type_down_conversion<Type>(bv), t_conversions);
} catch (const chaiscript::detail::exception::bad_any_cast &) {
Expand Down
41 changes: 19 additions & 22 deletions include/chaiscript/dispatchkit/dispatchkit.hpp
Expand Up @@ -443,17 +443,13 @@ namespace chaiscript


/// Adds a named object to the current scope
/// \warning This version does not check the validity of the name
/// it is meant for internal use only
void add_object(const std::string &name, const Boxed_Value &obj) const
{
auto &stack = get_stack_data();
validate_object_name(name);

auto &scope = stack.back();
if (scope.find(name) != scope.end())
if (!get_stack_data().back().insert(std::make_pair(name, obj)).second)
{
throw chaiscript::exception::name_conflict_error(name);
} else {
scope.insert(std::make_pair(name, obj));
}
}

Expand Down Expand Up @@ -497,11 +493,13 @@ namespace chaiscript
void new_scope()
{
get_stack_data().emplace_back();
m_stack_holder->call_params.emplace_back();
}

/// Pops the current scope from the stack
void pop_scope()
{
m_stack_holder->call_params.pop_back();
StackData &stack = get_stack_data();
if (stack.size() > 1)
{
Expand Down Expand Up @@ -796,7 +794,7 @@ namespace chaiscript
/// Dump object info to stdout
void dump_object(const Boxed_Value &o) const
{
std::cout << (o.is_const()?"const ":"") << type_name(o) << std::endl;
std::cout << (o.is_const()?"const ":"") << type_name(o) << '\n';
}

/// Dump type info to stdout
Expand Down Expand Up @@ -830,7 +828,7 @@ namespace chaiscript
}
}

std::cout << ") " << std::endl;
std::cout << ") \n";
}

/// Returns true if a call can be made that consists of the first parameter
Expand All @@ -850,28 +848,28 @@ namespace chaiscript
/// Dump all system info to stdout
void dump_system() const
{
std::cout << "Registered Types: " << std::endl;
std::cout << "Registered Types: \n";
std::vector<std::pair<std::string, Type_Info> > types = get_types();
for (std::vector<std::pair<std::string, Type_Info> >::const_iterator itr = types.begin();
itr != types.end();
++itr)
{
std::cout << itr->first << ": ";
std::cout << itr->second.bare_name();
std::cout << std::endl;
std::cout << '\n';
}

std::cout << std::endl;
std::cout << '\n';
std::vector<std::pair<std::string, Proxy_Function > > funcs = get_functions();

std::cout << "Functions: " << std::endl;
std::cout << "Functions: \n";
for (std::vector<std::pair<std::string, Proxy_Function > >::const_iterator itr = funcs.begin();
itr != funcs.end();
++itr)
{
dump_function(*itr);
}
std::cout << std::endl;
std::cout << '\n';
}

/// return true if the Boxed_Value matches the registered type by name
Expand Down Expand Up @@ -918,7 +916,7 @@ namespace chaiscript
void save_function_params(std::initializer_list<Boxed_Value> t_params)
{
Stack_Holder &s = *m_stack_holder;
s.call_params.insert(s.call_params.begin(), std::move(t_params));
s.call_params.back().insert(s.call_params.back().begin(), std::move(t_params));
}

void save_function_params(std::vector<Boxed_Value> &&t_params)
Expand All @@ -927,14 +925,14 @@ namespace chaiscript

for (auto &&param : t_params)
{
s.call_params.insert(s.call_params.begin(), std::move(param));
s.call_params.back().insert(s.call_params.back().begin(), std::move(param));
}
}

void save_function_params(const std::vector<Boxed_Value> &t_params)
{
Stack_Holder &s = *m_stack_holder;
s.call_params.insert(s.call_params.begin(), t_params.begin(), t_params.end());
s.call_params.back().insert(s.call_params.back().begin(), t_params.begin(), t_params.end());
}

void new_function_call()
Expand All @@ -945,7 +943,7 @@ namespace chaiscript
m_conversions.enable_conversion_saves(true);
}

++m_stack_holder->call_depth;
++s.call_depth;

save_function_params(m_conversions.take_saves());
}
Expand All @@ -959,9 +957,7 @@ namespace chaiscript

if (s.call_depth == 0)
{
/// \todo Critical: this needs to be smarter, memory can expand quickly
/// in tight loops involving function calls
s.call_params.clear();
s.call_params.back().clear();
m_conversions.enable_conversion_saves(false);
}
}
Expand Down Expand Up @@ -1153,11 +1149,12 @@ namespace chaiscript
: call_depth(0)
{
stacks.emplace_back(1);
call_params.emplace_back();
}

std::deque<StackData> stacks;

std::list<Boxed_Value> call_params;
std::deque<std::list<Boxed_Value>> call_params;
int call_depth;
};

Expand Down
4 changes: 0 additions & 4 deletions include/chaiscript/dispatchkit/type_conversions.hpp
Expand Up @@ -429,11 +429,7 @@ namespace chaiscript
static_assert(std::is_convertible<From, To>::value, "Types are not automatically convertible");
auto func = [](const Boxed_Value &t_bv) -> Boxed_Value {
// not even attempting to call boxed_cast so that we don't get caught in some call recursion
std::cout << " Type conversion to : " << typeid(To).name() << " from " << typeid(From).name() << std::endl;
auto &&from = detail::Cast_Helper<From>::cast(t_bv, nullptr);
std::cout << "Ptr" << static_cast<const void *>(from) << std::endl;
std::cout << "Ptr" << from << std::endl;

To to(from);
return chaiscript::Boxed_Value(to);
};
Expand Down
20 changes: 10 additions & 10 deletions include/chaiscript/language/chaiscript_common.hpp
Expand Up @@ -37,7 +37,7 @@ namespace chaiscript
Comparison, Addition, Subtraction, Multiplication, Division, Modulus, Array_Call, Dot_Access, Quoted_String, Single_Quoted_String,
Lambda, Block, Def, While, If, For, Inline_Array, Inline_Map, Return, File, Prefix, Break, Continue, Map_Pair, Value_Range,
Inline_Range, Annotation, Try, Catch, Finally, Method, Attr_Decl, Shift, Equality, Bitwise_And, Bitwise_Xor, Bitwise_Or,
Logical_And, Logical_Or, Reference, Switch, Case, Default, Ternary_Cond, Noop, Class
Logical_And, Logical_Or, Reference, Switch, Case, Default, Ternary_Cond, Noop, Class, Binary
};
};

Expand All @@ -50,7 +50,7 @@ namespace chaiscript
"Comparison", "Addition", "Subtraction", "Multiplication", "Division", "Modulus", "Array_Call", "Dot_Access", "Quoted_String", "Single_Quoted_String",
"Lambda", "Block", "Def", "While", "If", "For", "Inline_Array", "Inline_Map", "Return", "File", "Prefix", "Break", "Continue", "Map_Pair", "Value_Range",
"Inline_Range", "Annotation", "Try", "Catch", "Finally", "Method", "Attr_Decl", "Shift", "Equality", "Bitwise_And", "Bitwise_Xor", "Bitwise_Or",
"Logical_And", "Logical_Or", "Reference", "Switch", "Case", "Default", "Ternary Condition", "Noop"};
"Logical_And", "Logical_Or", "Reference", "Switch", "Case", "Default", "Ternary Condition", "Noop", "Class", "Binary"};

return ast_node_types[ast_node_type];
}
Expand Down Expand Up @@ -118,19 +118,19 @@ namespace chaiscript

ss << what();
if (call_stack.size() > 0) {
ss << "during evaluation at (" << fname(call_stack[0]) << " " << startpos(call_stack[0]) << ")" << std::endl;
ss << std::endl << detail << std::endl;
ss << "during evaluation at (" << fname(call_stack[0]) << " " << startpos(call_stack[0]) << ")\n";
ss << '\n' << detail << '\n';
ss << " " << fname(call_stack[0]) << " (" << startpos(call_stack[0]) << ") '" << pretty(call_stack[0]) << "'";
for (size_t j = 1; j < call_stack.size(); ++j) {
if (id(call_stack[j]) != chaiscript::AST_Node_Type::Block
&& id(call_stack[j]) != chaiscript::AST_Node_Type::File)
{
ss << std::endl;
ss << '\n';
ss << " from " << fname(call_stack[j]) << " (" << startpos(call_stack[j]) << ") '" << pretty(call_stack[j]) << "'";
}
}
}
ss << std::endl;
ss << '\n';
return ss.str();
}

Expand Down Expand Up @@ -264,13 +264,13 @@ namespace chaiscript
std::stringstream ss;
if (t_functions.size() == 1)
{
ss << " Expected: " << format_types(t_functions[0], t_dot_notation, t_ss) << std::endl;
ss << " Expected: " << format_types(t_functions[0], t_dot_notation, t_ss) << '\n';
} else {
ss << " " << t_functions.size() << " overloads available:" << std::endl;
ss << " " << t_functions.size() << " overloads available:\n";

for (const auto & t_function : t_functions)
{
ss << " " << format_types((t_function), t_dot_notation, t_ss) << std::endl;
ss << " " << format_types((t_function), t_dot_notation, t_ss) << '\n';
}

}
Expand Down Expand Up @@ -430,7 +430,7 @@ namespace chaiscript
std::ostringstream oss;

oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") "
<< this->text << " : " << this->start.line << ", " << this->start.column << std::endl;
<< this->text << " : " << this->start.line << ", " << this->start.column << '\n';

for (size_t j = 0; j < this->children.size(); ++j) {
oss << this->children[j]->to_string(t_prepend + " ");
Expand Down
4 changes: 2 additions & 2 deletions include/chaiscript/language/chaiscript_engine.hpp
Expand Up @@ -735,11 +735,11 @@ namespace chaiscript
{
try {
const auto name = elem + prefix + t_module_name + postfix;
// std::cerr << "trying location: " << name << std::endl;
// std::cerr << "trying location: " << name << '\n';
load_module(version_stripped_name, name);
return name;
} catch (const chaiscript::exception::load_module_error &e) {
// std::cerr << "error: " << e.what() << std::endl;
// std::cerr << "error: " << e.what() << '\n';
errors.push_back(e);
// Try next set
}
Expand Down

0 comments on commit 9aca261

Please sign in to comment.