-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathStd.h
65 lines (53 loc) · 1.91 KB
/
Std.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <windows.h>
#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>
#include <QFileDialog>
#include <pluginsdk/_plugins.h>
#include <pluginsdk/_scriptapi.h>
#include <pluginsdk/_scriptapi_debug.h>
#include <pluginsdk/_scriptapi_register.h>
#include <pluginsdk/_scriptapi_stack.h>
#include <pluginsdk/_scriptapi_assembler.h>
#include <functional>
#include <iomanip>
#include <regex>
#ifndef DLL_EXPORT
#define DLL_EXPORT __declspec(dllexport)
#endif //DLL_EXPORT
template <typename T> struct TypeWrapper {
typedef T f_arg;
typedef T chai_arg;
static inline f_arg convert(chai_arg a) { return a; }
};
template <> struct TypeWrapper<void> {
typedef void f_arg;
typedef void chai_arg;
static inline f_arg convert(chai_arg ) { }
};
template <> struct TypeWrapper <const char*> {
typedef const char* f_arg;
typedef const std::string& chai_arg;
static inline f_arg convert(chai_arg a) { return a.c_str(); }
};
template <> struct TypeWrapper <const unsigned char*> {
typedef const unsigned char* f_arg;
typedef const std::vector<unsigned char>& chai_arg;
static inline f_arg convert(chai_arg a) { return &a[0]; }
};
template <> struct TypeWrapper <unsigned char*> { };
template <> struct TypeWrapper <char*> { };
template < typename... args >
static inline std::function< void (typename TypeWrapper<args>::chai_arg...) >
FunctionWrapper( void (*fn)(args...), int __pref ) {
return [=] (typename TypeWrapper<args>::chai_arg... in) {
fn( (TypeWrapper<args>::convert(in))... );
};
};
template < typename rtn, typename... args >
static inline std::function< typename TypeWrapper<rtn>::chai_arg (typename TypeWrapper<args>::chai_arg...) >
FunctionWrapper( rtn (*fn)(args...), int __pref) {
return [=] (typename TypeWrapper<args>::chai_arg... in) {
return TypeWrapper<rtn>::convert( fn( (TypeWrapper<args>::convert(in))... ) );
};
};