Skip to content

Commit

Permalink
Update Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
bullno1 committed Jan 1, 2017
1 parent f5d66b2 commit fe1d048
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 135 deletions.
5 changes: 0 additions & 5 deletions examples/fib.lip

This file was deleted.

12 changes: 0 additions & 12 deletions examples/hello-2016.lip

This file was deleted.

17 changes: 0 additions & 17 deletions examples/test.lip

This file was deleted.

65 changes: 53 additions & 12 deletions genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ solution "lip"
debugdir "."

flags {
"ExtraWarnings",
"FatalWarnings",
"StaticRuntime",
"Symbols",
"NoEditAndContinue",
"NoNativeWChar",
"NoExceptions"
}

defines {
"_CRT_SECURE_NO_WARNINGS"
}

configuration "Release"
flags { "OptimizeSpeed" }
flags { "OptimizeSpeed" }

configuration "Debug"
targetsuffix "_d"
targetsuffix "_d"

project "repl"
kind "ConsoleApp"
Expand All @@ -32,27 +34,66 @@ solution "lip"
}

includedirs {
"include"
"include",
"deps/linenoise-ng/include",
"deps/cargo"
}

links {
"liblip"
"lip",
"cargo",
"linenoise-ng"
}

project "liblip"
kind "StaticLib"
project "tests"
kind "ConsoleApp"
language "C"

defines {
"_CRT_SECURE_NO_WARNINGS"
includedirs {
"include",
"src"
}

files {
"src/tests/*.h",
"src/tests/*.c"
}

links {
"lip"
}

project "lip"
kind "StaticLib"
language "C"

includedirs {
"include"
}

files {
"src/lip/*.h",
"src/lip/*.c"
"include/lip/*.h",
"src/lip/**"
}

project "linenoise-ng"
kind "StaticLib"
language "C++"

includedirs {
"deps/linenoise-ng/include",
}

files {
"deps/linenoise-ng/include/*.h",
"deps/linenoise-ng/src/*.cpp"
}

project "cargo"
kind "StaticLib"
language "C"

files {
"deps/cargo/*.h",
"deps/cargo/*.c"
}
86 changes: 12 additions & 74 deletions include/lip/bind.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef LIP_BIND_H
#define LIP_BIND_H

#include "pp.h"

#define lip_function(name) \
lip_exec_status_t name(lip_vm_t* vm, lip_value_t* result)

Expand All @@ -12,7 +14,7 @@

#define lip_bind_args(...) \
lip_bind_prepare(vm); \
const unsigned int arity_min = 0 + lip_pp_map(lip_bind_count_arity, __VA_ARGS__); \
const unsigned int arity_min = 0 lip_pp_map(lip_bind_count_arity, __VA_ARGS__); \
const unsigned int arity_max = lip_pp_len(__VA_ARGS__); \
if(arity_min != arity_max) { \
lip_bind_assert_argc_at_least(arity_min); \
Expand All @@ -21,6 +23,7 @@
lip_bind_assert_argc(arity_min); \
} \
lip_pp_map(lip_bind_arg, __VA_ARGS__)

#define lip_bind_arg(i, spec) \
lip_bind_arg1( \
i, \
Expand All @@ -33,8 +36,11 @@
lip_pp_concat(lip_pp_concat(lip_bind_, lip_pp_nth(1, extra, required)), _arg)( \
i, type, name, extra \
)

#define lip_bind_count_arity(i, spec) \
+ lip_pp_concat(lip_bind_count_arity_, lip_pp_nth(1, lip_pp_nth(3, spec, (required)), required))
lip_bind_count_arity1(i, lip_pp_nth(1, lip_pp_nth(3, spec, (required)), required))
#define lip_bind_count_arity1(i, spec) \
+ lip_pp_concat(lip_bind_count_arity_, spec)
#define lip_bind_count_arity_required 1
#define lip_bind_count_arity_optional 0

Expand Down Expand Up @@ -117,92 +123,24 @@

#define lip_bind_assert(cond, msg) \
do { if(!(cond)) { lip_throw(msg); } } while(0)

#define lip_bind_assert_fmt(cond, fmt, ...) \
do { if(!(cond)) { lip_throw_fmt(fmt, __VA_ARGS__); } } while(0)

#define lip_return(val) do { *result = val; return LIP_EXEC_OK; } while(0)

#define lip_throw(err) \
do { \
*result = lip_make_string_copy(vm, lip_string_ref(err)); \
lip_bind_track_native_location(vm); \
return LIP_EXEC_ERROR; \
} while(0)

#define lip_throw_fmt(fmt, ...) \
do { \
*result = lip_make_string(vm, fmt, __VA_ARGS__); \
lip_bind_track_native_location(vm); \
return LIP_EXEC_ERROR; \
} while(0)

// Terrible preprocessor abuses ahead

#define lip_pp_map(f, ...) \
lip_pp_map1(f, lip_pp_concat(lip_pp_apply, lip_pp_len(__VA_ARGS__)), __VA_ARGS__)
#define lip_pp_map1(f, apply_n, ...) \
apply_n(lip_pp_tail((lip_pp_seq())), f, __VA_ARGS__)
#define lip_pp_apply1(seq, f, a) f(lip_pp_head(seq), a)
#define lip_pp_apply2(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply1(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply3(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply2(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply4(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply3(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply5(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply4(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply6(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply5(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply7(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply6(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply8(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply7(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply9(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply8(lip_pp_tail(seq), f, __VA_ARGS__)
#define lip_pp_apply10(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_apply9(lip_pp_tail(seq), f, __VA_ARGS__)

#define lip_pp_len(...) lip_pp_len1(__VA_ARGS__, lip_pp_inv_seq())
#define lip_pp_len1(...) lip_pp_len2(__VA_ARGS__)
#define lip_pp_len2( \
x15, x14, x13, x12, \
x11, x10, x9, x8, \
x7, x6, x5, x4, \
x3, x2, x1, N, \
...) N
#define lip_pp_inv_seq() \
15, 14, 13, 12, 11, 10, 9, 8, \
7, 6, 5, 4, 3, 2, 1, 0
#define lip_pp_seq() \
0, 1, 2, 3, 4, 5, 6, 7, \
8, 9, 10, 11, 12, 13, 14, 15

#define lip_pp_concat(a, b) lip_pp_concat1(a, b)
#define lip_pp_concat1(a, b) a ## b

#define lip_pp_nth(n, tuple, default_) \
lip_pp_nth_(n, lip_pp_pad(tuple, default_))
#define lip_pp_nth_(n, tuple) lip_pp_concat(lip_pp_nth, n) tuple
#define lip_pp_nth1(x, ...) x
#define lip_pp_nth2(x, ...) lip_pp_nth1(__VA_ARGS__)
#define lip_pp_nth3(x, ...) lip_pp_nth2(__VA_ARGS__)
#define lip_pp_nth4(x, ...) lip_pp_nth3(__VA_ARGS__)
#define lip_pp_nth5(x, ...) lip_pp_nth4(__VA_ARGS__)
#define lip_pp_nth6(x, ...) lip_pp_nth5(__VA_ARGS__)
#define lip_pp_nth7(x, ...) lip_pp_nth6(__VA_ARGS__)
#define lip_pp_nth8(x, ...) lip_pp_nth7(__VA_ARGS__)
#define lip_pp_nth9(x, ...) lip_pp_nth8(__VA_ARGS__)
#define lip_pp_nth10(x, ...) lip_pp_nth9(__VA_ARGS__)

#define lip_pp_pad(tuple, val) (lip_pp_expand(tuple), val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val)

#define lip_pp_expand(...) lip_pp_expand1 __VA_ARGS__
#define lip_pp_expand1(...) __VA_ARGS__

#define lip_pp_head(x) lip_pp_head_ x
#define lip_pp_head_(x, ...) x

#define lip_pp_tail(x) lip_pp_tail_ x
#define lip_pp_tail_(x, ...) (__VA_ARGS__)

#define lip_pp_sep(x) lip_pp_concat(lip_pp_sep_, x)
#define lip_pp_sep_1
#define lip_pp_sep_2 ,
#define lip_pp_sep_3 ,
#define lip_pp_sep_4 ,
#define lip_pp_sep_5 ,
#define lip_pp_sep_6 ,
#define lip_pp_sep_7 ,
#define lip_pp_sep_8 ,
#define lip_pp_sep_9 ,
#define lip_pp_sep_10 ,

#endif
2 changes: 1 addition & 1 deletion include/lip/extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LIP_ENUM(lip_stream_status_t, LIP_STREAM)
# define LIP_UNLIKELY(cond) __builtin_expect(cond, 0)
#else
# define LIP_LIKELY(cond) cond
# define LIP_UNLIKELY(cond)
# define LIP_UNLIKELY(cond) cond
#endif

#define lip_error_m(T) \
Expand Down
81 changes: 81 additions & 0 deletions include/lip/pp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#ifndef LIP_PP_H
#define LIP_PP_H

#define lip_pp_map(f, ...) \
lip_pp_msvc_vararg_expand( \
lip_pp_map1(f, lip_pp_concat(lip_pp_apply, lip_pp_len(__VA_ARGS__)), __VA_ARGS__) \
)
#define lip_pp_map1(f, apply_n, ...) \
lip_pp_msvc_vararg_expand( \
apply_n(lip_pp_tail((lip_pp_seq())), f, __VA_ARGS__) \
)
#define lip_pp_apply1(seq, f, a) f(lip_pp_head(seq), a)
#define lip_pp_apply2(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply1(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply3(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply2(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply4(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply3(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply5(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply4(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply6(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply5(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply7(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply6(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply8(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply7(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply9(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply8(lip_pp_tail(seq), f, __VA_ARGS__))
#define lip_pp_apply10(seq, f, a, ...) f(lip_pp_head(seq), a) lip_pp_msvc_vararg_expand(lip_pp_apply9(lip_pp_tail(seq), f, __VA_ARGS__))

#define lip_pp_len(...) lip_pp_msvc_vararg_expand(lip_pp_len1(__VA_ARGS__, lip_pp_inv_seq()))
#define lip_pp_len1(...) lip_pp_msvc_vararg_expand(lip_pp_len2(__VA_ARGS__))
#define lip_pp_len2( \
x15, x14, x13, x12, \
x11, x10, x9, x8, \
x7, x6, x5, x4, \
x3, x2, x1, N, \
...) N
#define lip_pp_inv_seq() \
15, 14, 13, 12, 11, 10, 9, 8, \
7, 6, 5, 4, 3, 2, 1, 0
#define lip_pp_seq() \
0, 1, 2, 3, 4, 5, 6, 7, \
8, 9, 10, 11, 12, 13, 14, 15

#define lip_pp_concat(a, b) lip_pp_concat1(a, b)
#define lip_pp_concat1(a, b) lip_pp_concat2(a, b)
#define lip_pp_concat2(a, b) a ## b

#define lip_pp_nth(n, tuple, default_) \
lip_pp_nth_(n, lip_pp_pad(tuple, default_))
#define lip_pp_nth_(n, tuple) lip_pp_concat(lip_pp_nth, n) tuple
#define lip_pp_nth1(x, ...) x
#define lip_pp_nth2(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth1(__VA_ARGS__))
#define lip_pp_nth3(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth2(__VA_ARGS__))
#define lip_pp_nth4(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth3(__VA_ARGS__))
#define lip_pp_nth5(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth4(__VA_ARGS__))
#define lip_pp_nth6(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth5(__VA_ARGS__))
#define lip_pp_nth7(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth6(__VA_ARGS__))
#define lip_pp_nth8(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth7(__VA_ARGS__))
#define lip_pp_nth9(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth8(__VA_ARGS__))
#define lip_pp_nth10(x, ...) lip_pp_msvc_vararg_expand(lip_pp_nth9(__VA_ARGS__))

#define lip_pp_pad(tuple, val) (lip_pp_expand(tuple), val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val)

#define lip_pp_expand(...) lip_pp_msvc_vararg_expand(lip_pp_expand1 __VA_ARGS__)
#define lip_pp_expand1(...) __VA_ARGS__

#define lip_pp_head(x) lip_pp_head_ x
#define lip_pp_head_(x, ...) x

#define lip_pp_tail(x) lip_pp_tail_ x
#define lip_pp_tail_(x, ...) (__VA_ARGS__)

#define lip_pp_sep(x) lip_pp_concat(lip_pp_sep_, x)
#define lip_pp_sep_1
#define lip_pp_sep_2 ,
#define lip_pp_sep_3 ,
#define lip_pp_sep_4 ,
#define lip_pp_sep_5 ,
#define lip_pp_sep_6 ,
#define lip_pp_sep_7 ,
#define lip_pp_sep_8 ,
#define lip_pp_sep_9 ,
#define lip_pp_sep_10 ,

#define lip_pp_msvc_vararg_expand(x) x

#endif
14 changes: 0 additions & 14 deletions src/lip/fuck_msvc.h

This file was deleted.

0 comments on commit fe1d048

Please sign in to comment.