Skip to content

Commit

Permalink
Make this releasable
Browse files Browse the repository at this point in the history
  • Loading branch information
suyjuris committed May 4, 2022
1 parent feb8e76 commit 46719e2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if [ "$1" = "gcc" ]; then
fi;
elif [ "$1" = "emcc" ]; then
if [ "$2" = "debug" ]; then
$EMCC $CXXFLAGS -ferror-limit=2 -O0 -g4 platform_emscripten.cpp -o obst.js $LDFLAGS_EMCC -s EXPORTED_FUNCTIONS="[$exp_fun]" -s DEMANGLE_SUPPORT=1 -s SAFE_HEAP=0 -s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2 --source-map-base "file://`pwd`/"
$EMCC $CXXFLAGS -ferror-limit=2 -O0 -gsource-map platform_emscripten.cpp -o obst.js $LDFLAGS_EMCC -s EXPORTED_FUNCTIONS="[$exp_fun]" -s DEMANGLE_SUPPORT=1 -s SAFE_HEAP=0 -s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2 --source-map-base "file://`pwd`/"
elif [ "$2" = "release" ]; then
$EMCC $CXXFLAGS -ferror-limit=2 -DNDEBUG -O3 platform_emscripten.cpp -o obst.js -O3 --closure 1 $LDFLAGS_EMCC -s EXPORTED_FUNCTIONS="[$exp_fun]" -s DEMANGLE_SUPPORT=0 -s SAFE_HEAP=0 -s ASSERTIONS=0 -s STACK_OVERFLOW_CHECK=0
$EMCC $CXXFLAGS -ferror-limit=2 -DNDEBUG -O3 platform_emscripten.cpp -o obst.js -Os --closure 1 $LDFLAGS_EMCC -s EXPORTED_FUNCTIONS="[$exp_fun]" -s DEMANGLE_SUPPORT=0 -s SAFE_HEAP=0 -s ASSERTIONS=0 -s STACK_OVERFLOW_CHECK=0
else
echo "Error: second argument must be either debug or release"
fi;
Expand Down
2 changes: 1 addition & 1 deletion global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cassert>
#define assert_false assert(false)
#else
#define assert(x) (void)__builtin_expect(not (expr), 0)
#define assert(x) (void)__builtin_expect(not (x), 0)
#define assert_false __builtin_unreachable()
#endif

Expand Down
14 changes: 10 additions & 4 deletions obst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,10 @@ void bdd_name_amend_setop(Bdd_store* store, u32 a, u32 b, char op) {
}
}

#if 0
void bdd_name_amend_quant(Bdd_store* store, u32 a, char quant, Array_t<u8> levels) {
assert(store->names.size > 0);
array_push_back(&store->name_data, (u8)quant ^ 128);
array_push_back(&store->name_data, (u8)(quant ^ 128));

{s64 level = 0;
s64 i = 0;
Expand All @@ -385,16 +386,17 @@ void bdd_name_amend_quant(Bdd_store* store, u32 a, char quant, Array_t<u8> level

if (do_print) {
for (; store->snapshot_levels[i]; ++i)
array_push_back(&store->name_data, store->snapshot_levels[i] ^ 128);
array_push_back(&store->name_data, (u8)(store->snapshot_levels[i] ^ 128));
if (not first)
array_push_back(&store->name_data, ',' ^ 128);
array_push_back(&store->name_data, (u8)(',' ^ 128));
first = false;
} else {
while (store->snapshot_levels[i]) ++i;
}
++i;
}}
}
#endif

// Assign the next bdd name. This will consume the data given by the bdd_name_amend function.
void bdd_name_assign(Bdd_store* store, Bdd* bdd) {
Expand Down Expand Up @@ -727,6 +729,7 @@ void bdd_creation_amend_bdd(Bdd_store* store, u32 id) {
if (id <= 1) array_printf(&store->creation_data, "</s>");
}

#if 0
void bdd_creation_amend_levels(Bdd_store* store, u32 a, Array_t<u8> levels) {
assert(store->names.size > 0);

Expand All @@ -751,6 +754,7 @@ void bdd_creation_amend_levels(Bdd_store* store, u32 a, Array_t<u8> levels) {
++i;
}}
}
#endif

// Take a temporary bdd and finalise it, i.e. do deduplication and removal of unnecessary
// nodes. This will push a description of the operation performed onto the context stack. (If
Expand Down Expand Up @@ -1352,6 +1356,7 @@ u32 bdd_complement_stepwise(Bdd_store* store, u32 a, u32 bdd = -1) {
return bdd_final;
}

#if 0
u32 bdd_existential_stepwise(Bdd_store* store, u32 a, Array_t<u8> levels, u32 bdd = -1) {
Bdd a_bdd = store->bdd_data[a];

Expand Down Expand Up @@ -1392,6 +1397,7 @@ u32 bdd_existential_stepwise(Bdd_store* store, u32 a, Array_t<u8> levels, u32 bd


}
#endif

u32 _bdd_from_number_connect(Bdd_store* store, u32 i, u64 number, Array_t<u8> levels) {
bool flag = number >> levels[0] & 1;
Expand Down Expand Up @@ -3899,7 +3905,7 @@ void opengl_program_link(GLuint program, char* program_name) {
GLint info_size = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_size);

char* info = (char*)malloc(info_size);
char* info = (char*)calloc(1, info_size + 1);
glGetProgramInfoLog(program, info_size, NULL, info);
printf("Error while linking program %s:\n\n", program_name);
puts(info);
Expand Down
23 changes: 12 additions & 11 deletions platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ void _platform_init(Platform_state* platform) {
_platform_init_font(context, Lui_context::FONT_LUI_SMALL, 0);
_platform_init_font(context, Lui_context::FONT_LUI_SANS, 3);
_platform_init_font(context, Lui_context::FONT_LUI_BUTTON, 3);
_platform_init_font(context, Lui_context::FONT_BDD_NORMAL, 3); // The last three sizes do not matter, BDDs are scaled
_platform_init_font(context, Lui_context::FONT_BDD_NORMAL, 3);
_platform_init_font(context, Lui_context::FONT_BDD_ITALICS, 1);
_platform_init_font(context, Lui_context::FONT_BDD_SMALL, 3);

Expand Down Expand Up @@ -2718,7 +2718,7 @@ void _platform_render(Platform_state* platform) {
{auto set = [](s64* var, s64 val, bool* change) { *change |= *var != val; *var = val; };
s64 plw = global_platform.lui_context.panel_left_hidden ? 0 : global_platform.lui_context.width_panel_left;
bool flag = false;
set(&global_context.width, std::max(global_context.screen_w - plw, 400ll), &flag);
set(&global_context.width, std::max(global_context.screen_w - plw, 200ll), &flag);
set(&global_context.height, global_context.screen_h, &flag);
set(&global_context.canvas_x, plw, &flag);
set(&global_context.canvas_y, 0, &flag);
Expand Down Expand Up @@ -2798,8 +2798,8 @@ void _platform_render(Platform_state* platform) {
lui_draw_radio(context, x, y, Lui_context::SLOT_LABEL_UNION, &x, &y);
lui_draw_radio(context, x, y, Lui_context::SLOT_LABEL_INTERSECTION, &x, &y);
lui_draw_radio(context, x, y, Lui_context::SLOT_LABEL_COMPLEMENT, &x, &y);
y += (s64)std::round(font_inst.newline); x = x_ind;
lui_draw_radio(context, x, y, Lui_context::SLOT_LABEL_EXISTENTIAL, &x, &y);
//y += (s64)std::round(font_inst.newline); x = x_ind;
//lui_draw_radio(context, x, y, Lui_context::SLOT_LABEL_EXISTENTIAL, &x, &y);
y += (s64)std::round(font_inst.newline); x = x_orig;}

y += std::round(font_inst.height - font_inst.ascent);
Expand All @@ -2816,13 +2816,13 @@ void _platform_render(Platform_state* platform) {
lui_draw_entry(context, &context->entries[Lui_context::ENTRY_SECONDNODE], x, y, (s64)std::round(font_inst.space*12.f), 1, nullptr, &y, nullptr);
y += (s64)std::round(font_inst.height - font_inst.ascent); x = x_orig;}

{s64 x_orig = x, ha_line;
lui_draw_entry(context, &context->entries[Lui_context::ENTRY_LEVELS], x, y, (s64)std::round(font_inst.space*12.f), 1, nullptr, nullptr, &ha_line, nullptr, true);
y += ha_line;
platform_fmt_draw(Lui_context::SLOT_LABEL_LEVELS, x, y, -1, &x, &y);
y -= ha_line;
lui_draw_entry(context, &context->entries[Lui_context::ENTRY_LEVELS], x, y, (s64)std::round(font_inst.space*30.f), 1, nullptr, &y, nullptr);
y += (s64)std::round(font_inst.height - font_inst.ascent); x = x_orig;}
//{s64 x_orig = x, ha_line;
//lui_draw_entry(context, &context->entries[Lui_context::ENTRY_LEVELS], x, y, (s64)std::round(font_inst.space*12.f), 1, nullptr, nullptr, &ha_line, nullptr, true);
//y += ha_line;
//platform_fmt_draw(Lui_context::SLOT_LABEL_LEVELS, x, y, -1, &x, &y);
//y -= ha_line;
//lui_draw_entry(context, &context->entries[Lui_context::ENTRY_LEVELS], x, y, (s64)std::round(font_inst.space*30.f), 1, nullptr, &y, nullptr);
//y += (s64)std::round(font_inst.height - font_inst.ascent); x = x_orig;}

{s64 w_line, ha_line;
lui_draw_button_right(context, Lui_context::SLOT_BUTTON_OP, x, y, w, &ha_line, &w_line);
Expand Down Expand Up @@ -3119,6 +3119,7 @@ void linux_handle_selection_response(Platform_state* platform, XSelectionEvent*
XDeleteProperty(platform->display, platform->window, platform->sel_target);

if (ev->selection == platform->sel_primary) {
// TODO This should not press buttons
Key key1 = Key::create_mouse(Key::LEFT_DOWN, platform->lui_context.pointer_x, platform->lui_context.pointer_y);
Key key2 = Key::create_mouse(Key::LEFT_UP, platform->lui_context.pointer_x, platform->lui_context.pointer_y);
array_append(&global_platform.lui_context.input_queue, {key1, key2});
Expand Down

0 comments on commit 46719e2

Please sign in to comment.