Clean up tab vs space issues
discovered by @axelstudios
This commit is contained in:
parent
be9632d0ad
commit
46e7d0ab99
@ -229,7 +229,7 @@ namespace chaiscript
|
|||||||
std::advance(itr, pos);
|
std::advance(itr, pos);
|
||||||
container.erase(itr);
|
container.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ContainerType>
|
template<typename ContainerType>
|
||||||
@ -547,13 +547,13 @@ namespace chaiscript
|
|||||||
m->add(fun(find_func( [](const String *s, const String &f, size_t pos) { return s->find_last_not_of(f, pos); } ) ), "find_last_not_of");
|
m->add(fun(find_func( [](const String *s, const String &f, size_t pos) { return s->find_last_not_of(f, pos); } ) ), "find_last_not_of");
|
||||||
m->add(fun(find_func( [](const String *s, const String &f, size_t pos) { return s->find_first_not_of(f, pos); } ) ), "find_first_not_of");
|
m->add(fun(find_func( [](const String *s, const String &f, size_t pos) { return s->find_first_not_of(f, pos); } ) ), "find_first_not_of");
|
||||||
|
|
||||||
m->add(fun( std::function<void (String *)>( [](String *s) { return s->clear(); } ) ), "clear");
|
m->add(fun( std::function<void (String *)>( [](String *s) { return s->clear(); } ) ), "clear");
|
||||||
m->add(fun( std::function<bool (const String *)>( [](const String *s) { return s->empty(); } ) ), "empty");
|
m->add(fun( std::function<bool (const String *)>( [](const String *s) { return s->empty(); } ) ), "empty");
|
||||||
m->add(fun( std::function<size_t (const String *)>( [](const String *s) { return s->size(); } ) ), "size");
|
m->add(fun( std::function<size_t (const String *)>( [](const String *s) { return s->size(); } ) ), "size");
|
||||||
|
|
||||||
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->c_str(); } ) ), "c_str");
|
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->c_str(); } ) ), "c_str");
|
||||||
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->data(); } ) ), "data");
|
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->data(); } ) ), "data");
|
||||||
m->add(fun( std::function<String (const String *, size_t, size_t)>( [](const String *s, size_t pos, size_t len) { return s->substr(pos, len); } ) ), "substr");
|
m->add(fun( std::function<String (const String *, size_t, size_t)>( [](const String *s, size_t pos, size_t len) { return s->substr(pos, len); } ) ), "substr");
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,10 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Result>
|
template<typename Result>
|
||||||
struct Cast_Helper_Inner<const Result> : Cast_Helper_Inner<Result>
|
struct Cast_Helper_Inner<const Result> : Cast_Helper_Inner<Result>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast_Helper_Inner for casting to a const & type
|
* Cast_Helper_Inner for casting to a const & type
|
||||||
@ -221,9 +221,9 @@ namespace chaiscript
|
|||||||
struct Cast_Helper_Inner<const Boxed_Value &> : Cast_Helper_Inner<Boxed_Value>
|
struct Cast_Helper_Inner<const Boxed_Value &> : Cast_Helper_Inner<Boxed_Value>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Cast_Helper_Inner for casting to a std::reference_wrapper type
|
* Cast_Helper_Inner for casting to a std::reference_wrapper type
|
||||||
*/
|
*/
|
||||||
template<typename Result>
|
template<typename Result>
|
||||||
@ -263,7 +263,7 @@ namespace chaiscript
|
|||||||
struct Cast_Helper
|
struct Cast_Helper
|
||||||
{
|
{
|
||||||
typedef typename Cast_Helper_Inner<T>::Result_Type Result_Type;
|
typedef typename Cast_Helper_Inner<T>::Result_Type Result_Type;
|
||||||
|
|
||||||
static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions)
|
static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions)
|
||||||
{
|
{
|
||||||
return Cast_Helper_Inner<T>::cast(ob, t_conversions);
|
return Cast_Helper_Inner<T>::cast(ob, t_conversions);
|
||||||
|
@ -114,7 +114,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by Proxy_Function_Impl to determine if it is equivalent to another
|
* Used by Proxy_Function_Impl to determine if it is equivalent to another
|
||||||
@ -155,7 +155,7 @@ namespace chaiscript
|
|||||||
#endif
|
#endif
|
||||||
template<typename ... InnerParams>
|
template<typename ... InnerParams>
|
||||||
static Ret do_call(const std::function<Ret (Params...)> &f,
|
static Ret do_call(const std::function<Ret (Params...)> &f,
|
||||||
const std::vector<Boxed_Value> &, const Dynamic_Cast_Conversions &t_conversions, InnerParams &&... innerparams)
|
const std::vector<Boxed_Value> &, const Dynamic_Cast_Conversions &t_conversions, InnerParams &&... innerparams)
|
||||||
{
|
{
|
||||||
return f(boxed_cast<Params>(std::forward<InnerParams>(innerparams), &t_conversions)...);
|
return f(boxed_cast<Params>(std::forward<InnerParams>(innerparams), &t_conversions)...);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
throw exception::arity_error(static_cast<int>(params.size()), sizeof...(Params));
|
throw exception::arity_error(static_cast<int>(params.size()), sizeof...(Params));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// http://www.chaiscript.com
|
// http://www.chaiscript.com
|
||||||
|
|
||||||
#ifndef CHAISCRIPT_ALGEBRAIC_HPP_
|
#ifndef CHAISCRIPT_ALGEBRAIC_HPP_
|
||||||
#define CHAISCRIPT_ALGEBRAIC_HPP_
|
#define CHAISCRIPT_ALGEBRAIC_HPP_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -128,5 +128,5 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _CHAISCRIPT_ALGEBRAIC_HPP */
|
#endif /* _CHAISCRIPT_ALGEBRAIC_HPP */
|
||||||
|
|
||||||
|
@ -584,5 +584,5 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _CHAISCRIPT_COMMON_HPP */
|
#endif /* _CHAISCRIPT_COMMON_HPP */
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
print(i)
|
print(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 10; i >= 0; i -= 2) {
|
for (var i = 10; i >= 0; i -= 2) {
|
||||||
print(i)
|
print(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
||||||
for (; i < 5; ++i) {
|
for (; i < 5; ++i) {
|
||||||
print(i)
|
print(i)
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
//functions of zero params don't need them:
|
//functions of zero params don't need them:
|
||||||
def meet {
|
def meet {
|
||||||
print("Hello")
|
print("Hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
def greet(x) {
|
def greet(x) {
|
||||||
print("Hello, " + x.to_string())
|
print("Hello, " + x.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
//but you need parens for invocation:
|
//but you need parens for invocation:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
var i = 0
|
var i = 0
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
print("i is 0")
|
print("i is 0")
|
||||||
}
|
}
|
||||||
else if (i == 1) {
|
else if (i == 1) {
|
||||||
print("i is 1")
|
print("i is 1")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("i is not 0 or 1")
|
print("i is not 0 or 1")
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
print("i: " + i.to_string())
|
print("i: " + i.to_string())
|
||||||
if (i == 5) {
|
if (i == 5) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var j = 0
|
var j = 0
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
while (true) {
|
while (true) {
|
||||||
++j;
|
++j;
|
||||||
if (j == 5) {
|
if (j == 5) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
print("j: " + j.to_string())
|
print("j: " + j.to_string())
|
||||||
|
@ -35,28 +35,28 @@ class test
|
|||||||
chaiscript::ChaiScript::State backupState;
|
chaiscript::ChaiScript::State backupState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
test()
|
test()
|
||||||
: chai(chaiscript::Std_Lib::library())
|
: chai(chaiscript::Std_Lib::library())
|
||||||
{
|
{
|
||||||
backupState = chai.get_state();
|
backupState = chai.get_state();
|
||||||
}
|
}
|
||||||
~test(){}
|
~test(){}
|
||||||
|
|
||||||
void ResetState()
|
void ResetState()
|
||||||
{
|
{
|
||||||
chai.set_state(backupState);
|
chai.set_state(backupState);
|
||||||
chai.add(chaiscript::fun(&fuction),"Whatever()");
|
chai.add(chaiscript::fun(&fuction),"Whatever()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunFile(std::string sFile)
|
void RunFile(std::string sFile)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
chaiscript::Boxed_Value val = chai.eval_file(sFile);
|
chaiscript::Boxed_Value val = chai.eval_file(sFile);
|
||||||
}
|
|
||||||
catch (std::exception &e) {
|
|
||||||
std::cout << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (std::exception &e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ var x = -(1 + 2 - 3 * 4 / 2)
|
|||||||
print("Answer: " + x.to_string())
|
print("Answer: " + x.to_string())
|
||||||
|
|
||||||
if (x >= 2 && x <= 4) {
|
if (x >= 2 && x <= 4) {
|
||||||
print("x is between 2 and 4")
|
print("x is between 2 and 4")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
var x = 4
|
var x = 4
|
||||||
def do_it() {
|
def do_it() {
|
||||||
var x = 1
|
var x = 1
|
||||||
print(x)
|
print(x)
|
||||||
var y = fun(x) { x + 1 }
|
var y = fun(x) { x + 1 }
|
||||||
print(y(9))
|
print(y(9))
|
||||||
}
|
}
|
||||||
do_it()
|
do_it()
|
||||||
print(x)
|
print(x)
|
||||||
|
@ -11,6 +11,6 @@ var size = vec.size()
|
|||||||
print("Vector Size: " + size.to_string());
|
print("Vector Size: " + size.to_string());
|
||||||
|
|
||||||
while (i < size) {
|
while (i < size) {
|
||||||
print(i.to_string() + ": " + to_string(vec[i]))
|
print(i.to_string() + ": " + to_string(vec[i]))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
var i = 0
|
var i = 0
|
||||||
while (i < 10) {
|
while (i < 10) {
|
||||||
print("i: " + i.to_string())
|
print("i: " + i.to_string())
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
var i = 0
|
var i = 0
|
||||||
while (i < 10) {
|
while (i < 10) {
|
||||||
if (++i == 5) {
|
if (++i == 5) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert_equal(5, i);
|
assert_equal(5, i);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
def bob(x, y, z) {
|
def bob(x, y, z) {
|
||||||
x + y + z
|
x + y + z
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob(x, y) {
|
def bob(x, y) {
|
||||||
x - y
|
x - y
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob(x) {
|
def bob(x) {
|
||||||
-x
|
-x
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob() {
|
def bob() {
|
||||||
10
|
10
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal(10, bob())
|
assert_equal(10, bob())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
def sam() {
|
def sam() {
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal(5, sam())
|
assert_equal(5, sam())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
def greet {
|
def greet {
|
||||||
return("hello")
|
return("hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ bool test_type_conversion(const Boxed_Value &bv, bool expectedpass)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
std::cerr << "Error with type conversion test. From: "
|
std::cerr << "Error with type conversion test. From: "
|
||||||
<< (bv.is_const()?(std::string("const ")):(std::string())) << bv.get_type_info().name()
|
<< (bv.is_const()?(std::string("const ")):(std::string())) << bv.get_type_info().name()
|
||||||
<< " To: "
|
<< " To: "
|
||||||
<< (std::is_const<To>::value?(std::string("const ")):(std::string())) << typeid(To).name()
|
<< (std::is_const<To>::value?(std::string("const ")):(std::string())) << typeid(To).name()
|
||||||
<< " test was expected to " << ((expectedpass)?(std::string("succeed")):(std::string("fail"))) << " but did not" << std::endl;
|
<< " test was expected to " << ((expectedpass)?(std::string("succeed")):(std::string("fail"))) << " but did not" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
auto i = 0
|
auto i = 0
|
||||||
while (i < 10) {
|
while (i < 10) {
|
||||||
if (++i == 5) {
|
if (++i == 5) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert_equal(5, i);
|
assert_equal(5, i);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
def bob(x, y, z) {
|
def bob(x, y, z) {
|
||||||
x + y + z
|
x + y + z
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob(x, y) {
|
def bob(x, y) {
|
||||||
x - y
|
x - y
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob(x) {
|
def bob(x) {
|
||||||
-x
|
-x
|
||||||
}
|
}
|
||||||
|
|
||||||
def bob() {
|
def bob() {
|
||||||
10
|
10
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal(10, bob())
|
assert_equal(10, bob())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
def sam() {
|
def sam() {
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal(5, sam())
|
assert_equal(5, sam())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
def greet {
|
def greet {
|
||||||
return("hello")
|
return("hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user