Skip to content
Open
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# All files generated by standalone contexts are ignored in git statistic
src/das/**/*.cpp binary
src/das/**/*.h binary

utils/dasFormatter/ds_parser.cpp binary
utils/dasFormatter/ds_parser.hpp binary
src/parser/ds_lexer.cpp binary
src/parser/ds2_lexer.cpp binary
src/parser/ds_parser.cpp binary
src/parser/ds2_parser.cpp binary
src/parser/ds_parser.output binary
src/parser/ds2_parser.output binary
src/parser/lex.yy.h binary
src/parser/lex2.yy.h binary
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ jobs:
repository: profelis/das-fmt # Path to repository with das-fmt scripts
path: das-fmt

- name: "Run simple checks"
run: |
set -euo pipefail
case "${{ matrix.target }}${{ matrix.architecture }}" in
windows*)
;;
*)
bash ci/simple_checks.sh
;;
esac

- name: "Build: Daslang"
run: |
set -eux
Expand Down
27 changes: 27 additions & 0 deletions ci/simple_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# check for tabs
! grep -rn $'\t' --exclude=*lexer.cpp \
--exclude=MacOSXBundleInfo.plist.in\
--exclude=*.yy.h\
utils src include || {
echo "tabs found!"; exit 1
}
# check for trailing spaces
! grep -rn '[ ]$' --exclude=*lexer.cpp\
--exclude=*.yy.h\
--exclude=fast_float.h\
utils src include || {
echo "trailing spaces found!";
exit 1
}
# check for std::
! grep -rn --include='*.cpp'\
--include='*.hpp'\
--include='*.h'\
--exclude-dir=modules\
--exclude-dir=web\
--exclude-dir='3rdparty'\
--exclude='*lexer.cpp'\
--exclude={'fast_float.h','flat_hash_map.hpp','das_config.h','callable.h','format.cpp','unitTest.h'}\
'std::' || {
echo "do not use std::!"; exit 1
}
8 changes: 4 additions & 4 deletions examples/test/test_handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ void builtin_printw(char * utf8string) {
#endif

void builtin_printw(char * utf8string) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
wstring_convert<codecvt_utf8<wchar_t>> utf8_conv;
auto outs = utf8_conv.from_bytes(utf8string);
#if defined(_MSC_VER)
_setmode(_fileno(stdout), _O_U8TEXT);
#else
std::wcout.sync_with_stdio(false);
std::wcout.imbue(std::locale("en_US.utf8"));
wcout.sync_with_stdio(false);
wcout.imbue(locale("en_US.utf8"));
#endif
std::wcout << outs;
wcout << outs;
#if defined(_MSC_VER)
_setmode(_fileno(stdout), _O_TEXT);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/tutorial08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int main( int, char * [] ) {
for ( auto it : ptr_ref_count::ref_count_ids ) {
ids.push_back(it);
}
std::sort(ids.begin(), ids.end());
sort(ids.begin(), ids.end());
for ( auto it : ids ) {
tp << " " << HEX << it << DEC;
}
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ namespace das
arguments[0]->name = argName;
return this;
}
FunctionPtr args ( std::initializer_list<const char *> argList ) {
FunctionPtr args ( initializer_list<const char *> argList ) {
if ( argList.size()==0 ) return this;
DAS_VERIFYF(argList.size() == arguments.size(), "during a processing of the '%s' function\n", cppName.c_str());
int argIndex = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/ast/ast_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ namespace das
addExtern<decltype(&das_nequ_val<TT,TT>), das_nequ_val<TT,TT>>(mod, lib, "!=", SideEffects::none, "das_nequ_val");
}

void setParents ( Module * mod, const char * child, const std::initializer_list<const char *> & parents );
void setParents ( Module * mod, const char * child, const initializer_list<const char *> & parents );
}

MAKE_TYPE_FACTORY(das_string, das::string);
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/misc/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace das
EE value;
string name;
};
Enum ( std::initializer_list<InitEnum> ie ) {
Enum ( initializer_list<InitEnum> ie ) {
name2enum.reserve(ie.size());
enum2name.reserve(ie.size());
for ( const auto & e : ie ) {
Expand Down
32 changes: 16 additions & 16 deletions include/daScript/misc/job_que.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ namespace das {
int append(int size);
bool isValid() const { return mMagic==STATUS_MAGIC; }
protected:
mutable mutex mCompleteMutex;
uint32_t mRemaining = 0;
condition_variable mCond;
atomic<int> mRef{0};
uint32_t mMagic = STATUS_MAGIC;
mutable mutex mCompleteMutex;
uint32_t mRemaining = 0;
condition_variable mCond;
atomic<int> mRef{0};
uint32_t mMagic = STATUS_MAGIC;
};

class JobQue {
Expand Down Expand Up @@ -79,17 +79,17 @@ namespace das {
priority = _priority;
category = _category;
}
Job function = nullptr;
JobPriority priority = JobPriority::Inactive;
JobCategory category = 0;
Job function = nullptr;
JobPriority priority = JobPriority::Inactive;
JobCategory category = 0;
};
struct ThreadEntry {
ThreadEntry( unique_ptr<thread> && thread) {
threadPointer = das::move(thread);
};
unique_ptr<thread> threadPointer;
JobPriority currentPriority = JobPriority::Inactive;
JobCategory currentCategory = 0;
unique_ptr<thread> threadPointer;
JobPriority currentPriority = JobPriority::Inactive;
JobCategory currentCategory = 0;
};
protected:
void join();
Expand All @@ -98,14 +98,14 @@ namespace das {
protected:
condition_variable mCond;
int mSleepMs;
atomic<bool> mShutdown{false};
atomic<int> mThreadCount{0};
atomic<bool> mShutdown{false};
atomic<int> mThreadCount{0};
static thread::id mTheMainThread;
mutex mFifoMutex;
protected:
deque<JobEntry> mFifo;
vector<ThreadEntry> mThreads;
atomic<int> mJobsRunning{0};
deque<JobEntry> mFifo;
vector<ThreadEntry> mThreads;
atomic<int> mJobsRunning{0};
protected:
mutex mEvalMainThreadMutex;
vector<Job> mEvalMainThread;
Expand Down
22 changes: 13 additions & 9 deletions include/daScript/misc/wyhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ static constexpr uint64_t _wyp[4] = {UINT64_C(0xa0761d6478bd642f), UINT64_C(0xe7

//wyhash main function
static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret=_wyp){
const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0],secret[1]); uint64_t a, b;
const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0],secret[1]);
uint64_t a, b;
if(_likely_(len<=16)){
if(_likely_(len>=4)){ a=(_wyr4(p)<<32)|_wyr4(p+((len>>3)<<2)); b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-((len>>3)<<2)); }
else if(_likely_(len>0)){ a=_wyr3(p,len); b=0;}
Expand Down Expand Up @@ -166,15 +167,16 @@ static inline constexpr double wy2u01(uint64_t r){ const double _wynorm=1.0/(UIN
//convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash.
static inline constexpr double wy2gau(uint64_t r){ const double _wynorm=1.0/(UINT64_C(1)<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;}

#ifdef WYTRNG
#ifdef WYTRNG
#include <sys/time.h>
//The wytrand true random number generator, passed BigCrush.
static inline uint64_t wytrand(uint64_t *seed){
struct timeval t; gettimeofday(&t,0);
uint64_t teed=(((uint64_t)t.tv_sec)<<32)|t.tv_usec;
teed=_wymix(teed^_wyp[0],*seed^_wyp[1]);
*seed=_wymix(teed^_wyp[0],_wyp[2]);
return _wymix(*seed,*seed^_wyp[3]);
struct timeval t;
gettimeofday(&t,0);
uint64_t teed=(((uint64_t)t.tv_sec)<<32)|t.tv_usec;
teed=_wymix(teed^_wyp[0],*seed^_wyp[1]);
*seed=_wymix(teed^_wyp[0],_wyp[2]);
return _wymix(*seed,*seed^_wyp[3]);
}
#endif

Expand Down Expand Up @@ -221,7 +223,8 @@ static inline constexpr uint64_t _wyr4_const(const uint8_t *p) { return ((uint64
//wyhash main function
static inline constexpr uint64_t wyhash_const(const uint8_t *p, size_t len, uint64_t seed, const uint64_t *secret=_wyp){

seed^=_wymix_const(seed^secret[0],secret[1]); uint64_t a=0, b=0;
seed^=_wymix_const(seed^secret[0],secret[1]);
uint64_t a=0, b=0;
if(_likely_(len<=16)){
if(_likely_(len>=4)){ a=(_wyr4_const(p)<<32)|_wyr4_const(p+((len>>3)<<2)); b=(_wyr4_const(p+len-4)<<32)|_wyr4_const(p+len-4-((len>>3)<<2)); }
else if(_likely_(len>0)){ a=_wyr3(p,len); b=0;}
Expand Down Expand Up @@ -256,7 +259,8 @@ static inline constexpr uint64_t wyhash_const(const char *p, uint64_t seed, cons
size_t len = 0;
for (;p[len]; ++len){}

seed^=_wymix_const(seed^secret[0],secret[1]); uint64_t a=0, b=0;
seed^=_wymix_const(seed^secret[0],secret[1]);
uint64_t a=0, b=0;
if(_likely_(len<=16)){
if(_likely_(len>=4)){ a=(_wyr4_const(p)<<32)|_wyr4_const(p+((len>>3)<<2)); b=(_wyr4_const(p+len-4)<<32)|_wyr4_const(p+len-4-((len>>3)<<2)); }
else if(_likely_(len>0)){ a=_wyr3(p,len); b=0;}
Expand Down
8 changes: 4 additions & 4 deletions include/daScript/simulate/aot.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ namespace das {
static __forceinline TT get ( const TT * ptr, TT value ) {
return ptr ? *((TT *)ptr) : value;
}
template <typename LPTRX>
template <typename LPTRX>
static __forceinline TT get ( LPTRX ** ptr, nullptr_t pqq ) {
return ptr ? *((TT *)ptr) : ((TT)pqq);
}
Expand Down Expand Up @@ -628,7 +628,7 @@ namespace das {
}

template <typename TT>
struct das_index<TT, std::enable_if_t<std::is_base_of_v<std::vector<typename TT::value_type>, TT>>>
struct das_index<TT, enable_if_t<is_base_of_v<vector<typename TT::value_type>, TT>>>
: das_default_vector_index<vector<typename TT::value_type>, typename TT::value_type> {};

template <typename TT, typename VecT, uint32_t size>
Expand Down Expand Up @@ -1043,7 +1043,7 @@ namespace das {
template <int variantSize, int variantAlign, typename ...TA>
struct alignas(variantAlign) TVariant : Variant {
template<int N> using NthType =
typename std::tuple_element<N, std::tuple<TA...>>::type;
typename tuple_element<N, tuple<TA...>>::type;

struct alignas(1) TData {
char data[variantSize - sizeof(int32_t)];
Expand All @@ -1054,7 +1054,7 @@ namespace das {

template <typename T, size_t idx>
void set(T val, size_t align) {
static_assert(std::is_same_v<NthType<idx>, T>);
static_assert(is_same_v<NthType<idx>, T>);
index = idx;
new(data.data + align) T(val);
}
Expand Down
4 changes: 2 additions & 2 deletions include/daScript/simulate/aot_builtin_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace das {

enum class ConversionResult {
ok
, invalid_argument = int(std::errc::invalid_argument) // fast_float.h
, out_of_range = int(std::errc::result_out_of_range) // fast_float.h
, invalid_argument = int(errc::invalid_argument) // fast_float.h
, out_of_range = int(errc::result_out_of_range) // fast_float.h
};

bool delete_string ( char * & str, Context * context, LineInfoArg * at );
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/simulate/simulate.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace das
} }

#if DAS_ENABLE_EXCEPTIONS
class dasException final : public std::exception {
class dasException final : public exception {
public:
dasException ( const char * why, const LineInfo & at )
: exceptionAt(at), exceptionWhat(why ? why : "") {}
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast_aot_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace das {
vector<pair<K, V>> sorted_vector(unsorted_map.begin(), unsorted_map.end());

// Sort the vector by key
std::sort(sorted_vector.begin(), sorted_vector.end(),
sort(sorted_vector.begin(), sorted_vector.end(),
[](const auto& a, const auto& b) {
return a.first < b.first;
});
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace das {

void setParents ( Module * mod, const char * child, const std::initializer_list<const char *> & parents ) {
void setParents ( Module * mod, const char * child, const initializer_list<const char *> & parents ) {
auto chA = mod->findAnnotation(child);
DAS_VERIFYF(chA,"missing child annotation");
DAS_VERIFYF(chA->rtti_isBasicStructureAnnotation(),"expecting basic structure annotation");
Expand Down
12 changes: 6 additions & 6 deletions src/builtin/module_builtin_ast_serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace das {
for ( auto & p : refs ) {
auto it = objects.find(p.second);
if ( it == objects.end() ) {
throw std::runtime_error{"ast serializer function ref not found"};
throw runtime_error{"ast serializer function ref not found"};
} else {
*p.first = it->second.get();
}
Expand All @@ -84,7 +84,7 @@ namespace das {

va_end(args);

throw std::runtime_error{err};
throw runtime_error{err};
}

#define SERIALIZER_VERIFYF(cond, ...) { \
Expand Down Expand Up @@ -144,7 +144,7 @@ namespace das {
try {
cb(*this);
return true;
} catch ( const std::runtime_error & e ) {
} catch ( const runtime_error & e ) {
failed = true;
return false;
}
Expand Down Expand Up @@ -1396,7 +1396,7 @@ namespace das {
Module * module = nullptr; ser << module;
string mangledName; ser << mangledName;
field = ( Structure::FieldDeclaration * ) 1;
ser.fieldRefs.emplace_back(&field, module, std::move(mangledName), name);
ser.fieldRefs.emplace_back(&field, module, move(mangledName), name);
}
}

Expand Down Expand Up @@ -2278,7 +2278,7 @@ namespace das {
deser->setModuleName(name);
program->library.addModule(deser);
ser << *deser;
} catch ( const std::runtime_error & r ) {
} catch ( const runtime_error & r ) {
delete deser;
LOG(LogLevel::warning) << "das: serialize: " << r.what();
program->failToCompile = true;
Expand All @@ -2300,7 +2300,7 @@ namespace das {
try {
program->serialize(*this);
return true;
} catch ( const std::runtime_error & r ) {
} catch ( const runtime_error & r ) {
program->failToCompile = true;
LOG(LogLevel::warning) << "das: serialize: " << r.what();
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/builtin/module_builtin_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ namespace debugapi {

// invoke_debug_agent_method("category","function",....)

extern std::recursive_mutex g_DebugAgentMutex;
extern recursive_mutex g_DebugAgentMutex;
extern das_safe_map<string, DebugAgentInstance> g_DebugAgents;

#define MAX_DEBUG_AGENT_ARGS 16
Expand Down
Loading