Skip to content

Commit

Permalink
[lib] update
Browse files Browse the repository at this point in the history
  • Loading branch information
momentarylapse committed Oct 6, 2024
1 parent f74c55c commit 9e43d30
Show file tree
Hide file tree
Showing 26 changed files with 96 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/lib/base/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Array : public DynamicArray {
(*this)[num - 1] = item;
}
T _cdecl pop() {
T r;
T r{};
if (num > 0) {
//memcpy(&r, &back(), element_size);
//DynamicArray::resize(num - 1);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
// which compiler?

#if defined(_MSC_VER)
#define COMPILER_VISUAL_STUDIO
#define COMPILER_VISUAL_STUDIO
#elif defined(__clang__)
#define COMPILER_CLANG
#elif defined(__GNUC__)
#define COMPILER_GCC
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/lib/hui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ Application::Application(const string &app_name, const string &def_lang, Flags _
else if (os::fs::exists(directory_static | "icon.ico"))
set_property("logo", str(directory_static | "icon.ico"));


// default "icon" used for windows (just name)
set_property("icon", app_name);
}
Expand Down Expand Up @@ -238,6 +237,11 @@ static std::function<void()> _run_after_gui_init_func_;
static void on_gtk_application_activate(GApplication *_g_app, gpointer user_data) {
auto app = reinterpret_cast<Application*>(user_data);
_init_global_css_classes_();

// add local icon theme
auto icon_theme = gtk_icon_theme_get_for_display(gdk_display_get_default());
gtk_icon_theme_add_search_path(icon_theme, str(Application::directory_static | "icons").c_str());

if (_run_after_gui_init_func_)
_run_after_gui_init_func_();
else
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hui/Controls/ControlExpanderGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace hui {

const int FRAME_INDENT = 0; //20;
//const int FRAME_INDENT = 0; //20;

void on_gtk_expander_expand(GObject* object, GParamSpec *param_spec, gpointer user_data) {
auto expander = reinterpret_cast<ControlExpander*>(user_data);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hui/Controls/ControlGridGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace hui {

const int FRAME_MARGIN = 8;
//const int FRAME_MARGIN = 8;


void DBDEL_X(const string &m);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hui/MenuGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Menu::open_popup(Panel *panel) {
#if GTK_CHECK_VERSION(4,0,0)
// transform into panel coordinates
int dx = 0, dy = 0;
panel->apply_foreach(panel->_get_cur_id_(), [this, panel, &dx, &dy] (Control *c) {
panel->apply_foreach(panel->_get_cur_id_(), [panel, &dx, &dy] (Control *c) {
graphene_point_t A{0,0}, B;
if (gtk_widget_compute_point (c->widget, panel->root_control->widget, &A, &B)) {
dx = (int)B.x;
Expand Down
5 changes: 3 additions & 2 deletions src/lib/hui/WindowGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ void Window::_init_(const string &title, int width, int height, Window *_parent,
// icon
#if GTK_CHECK_VERSION(4,0,0)

auto icon_theme = gtk_icon_theme_get_for_display(gtk_widget_get_display(window));
gtk_icon_theme_add_search_path(icon_theme, str(Application::directory_static | "icons").c_str());
//[[maybe_unused]] auto icon_theme = gtk_icon_theme_get_for_display(gdk_display_get_default());

string icon = Application::get_property("icon");
//msg_write(gtk_icon_theme_has_icon(icon_theme, icon.c_str()));
gtk_window_set_default_icon_name("tsunami");
gtk_window_set_icon_name(GTK_WINDOW(window), icon.c_str());
#else
string logo = Application::get_property("logo");
Expand Down
21 changes: 18 additions & 3 deletions src/lib/hui/common_dlg_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,16 +624,31 @@ void about_box(Window *win) {
auto documenters = sa2ca_nt(Application::get_property("documenter").explode(";"));
auto translators = sa2ca_nt(Application::get_property("translator").explode(";"));

GError *error = nullptr;
[[maybe_unused]] GError *error = nullptr;
auto dlg = gtk_about_dialog_new();
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dlg), Application::get_property("name").c_str());
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dlg), Application::get_property("version").c_str());
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dlg), Application::get_property("comment").c_str());
gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dlg), Application::get_property("license").c_str());
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dlg), Application::get_property("website").c_str());
#if GTK_CHECK_VERSION(4,0,0)
auto *_logo = gdk_texture_new_from_file(g_file_new_for_path(Application::get_property("logo").c_str()), &error);
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dlg), GDK_PAINTABLE(_logo));

auto icon_theme = gtk_icon_theme_get_for_display(gdk_display_get_default());
auto icon = gtk_icon_theme_lookup_icon(icon_theme,
"tsunami", // icon name
nullptr,
128, // icon size
1, // scale
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR); // flags);

gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dlg), GDK_PAINTABLE(icon));

//msg_write("ABOUT..." + Application::get_property("logo"));
/*auto *_logo = gdk_texture_new_from_file(g_file_new_for_path(Application::get_property("logo").c_str()), &error);
if (error)
msg_error(error->message);
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dlg), GDK_PAINTABLE(_logo));*/


/*auto icon_theme = gtk_icon_theme_get_for_display(gtk_widget_get_display(dlg));
Expand Down
8 changes: 4 additions & 4 deletions src/lib/kaba/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class Module;
class SyntaxTree;
class Function;
class Serializer;
class CommandList;
class SerialNode;
class SerialNodeParam;
struct CommandList;
struct SerialNode;
struct SerialNodeParam;

class Interpreter {
public:
Interpreter(Module *m);
explicit Interpreter(Module *m);
~Interpreter();

void add_function(Function *f, Serializer *ser);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/kaba/compiler/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Asm {
namespace kaba {

class Serializer;
class SerialNode;
struct SerialNode;



Expand Down
5 changes: 2 additions & 3 deletions src/lib/kaba/compiler/CommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ namespace Asm {
namespace kaba {

class Serializer;
class VirtualRegister;
class SerialNode;
class SerialNodeParam;
struct SerialNode;
struct SerialNodeParam;
class Class;


Expand Down
4 changes: 2 additions & 2 deletions src/lib/kaba/compiler/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "SerialNode.h"

namespace Asm {
class InstructionWithParamsList;
class InstructionParam;
struct InstructionWithParamsList;
struct InstructionParam;
enum class RegID;
enum class InstID;
}
Expand Down
9 changes: 5 additions & 4 deletions src/lib/kaba/dynamic/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ extern const Class *TypeCallableBase;
#define CALL_DEBUG_X 0

// call-by-reference dummy
class CBR {
struct
CBR {
int _dummy_[1024];
};

class vec2 { float a; float b; };
class vec3 { float a; float b; float c; };
class vec4 { float a; float b; float c; float d; };
struct vec2 { float a; float b; };
struct vec3 { float a; float b; float c; };
struct vec4 { float a; float b; float c; float d; };

void call0_void(void *ff, void *ret, const Array<void*> &param) {
((void(*)())ff)();
Expand Down
6 changes: 5 additions & 1 deletion src/lib/kaba/dynamic/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ extern const Class *TypeSpecialFunction;




#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif


void var_assign(void *pa, const void *pb, const Class *type) {
Expand Down Expand Up @@ -381,7 +382,10 @@ DynamicArray array_map(void *fff, DynamicArray *a, const Class *ti, const Class
return r;
}


#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif



Expand Down
6 changes: 5 additions & 1 deletion src/lib/kaba/dynamic/sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ extern const Class *TypePath;



#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif


void array_inplace_reverse(DynamicArray &array) {
Expand Down Expand Up @@ -112,7 +114,7 @@ void _array_sort_p(DynamicArray &array, int offset_by, bool stable) {
template<class T>
void _array_sort_pf(DynamicArray &array, Function *func, bool stable) {
auto f = [func] (void *a, void *b) {
T r1, r2;
T r1{}, r2{};
if (!call_function(func, &r1, {a}) or !call_function(func, &r2, {b}))
kaba_raise_exception(new KabaException("call failed " + func->long_name()));
return (r1 <= r2);
Expand Down Expand Up @@ -221,7 +223,9 @@ DynamicArray _cdecl array_sort(DynamicArray &array, const Class *type, const str
}


#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif



Expand Down
6 changes: 6 additions & 0 deletions src/lib/kaba/lib/lib_kaba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ extern const Class* TypeSpecialFunctionRef;

string function_link_name(Function *f);


#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif

class KabaContext : public Context {
public:
Expand All @@ -36,7 +39,10 @@ class KabaContext : public Context {
}
};


#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif


void show_func(Function *f) {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/kaba/lib/lib_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,12 @@ class KabaRect : public rect {
};


#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif


class KabaAny : public Any {
Expand Down Expand Up @@ -324,7 +326,9 @@ Any pointer2any(const void *p) {
return Any(p);
}

#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif


template<int N>
Expand Down
5 changes: 5 additions & 0 deletions src/lib/kaba/lib/lib_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ namespace kaba {
#endif



#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif


xfer<Socket> __socket_listen__(int port, bool block) {
Expand All @@ -45,7 +48,9 @@ xfer<Socket> __socket_create_udp__(int port) {
return nullptr;
}

#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif

void SIAddPackageNet(Context *c) {
add_package(c, "net");
Expand Down
5 changes: 4 additions & 1 deletion src/lib/kaba/lib/lib_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ Any _os_config_get(Configuration &c, const string &key) {
static shared<Stream> _kaba_stdin;


#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif



Expand Down Expand Up @@ -204,8 +206,9 @@ string _cdecl kaba_shell_execute(const string &cmd) {
return "";
}


#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif

class KabaPath : public Path {
public:
Expand Down
5 changes: 5 additions & 0 deletions src/lib/kaba/lib/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ namespace kaba {

extern const Class *TypeNone;


#ifdef COMPILER_GCC
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
#endif


template<class T>
Expand Down Expand Up @@ -65,7 +68,9 @@ class XOptional : public base::optional<T> {
}*/
};

#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif

template<class T>
void lib_create_optional(const Class *tt) {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/kaba/parser/Concretifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ shared<Node> apply_macro(Concretifier *con, Function* f, shared<Node> node, shar
con->do_error(format("can not pass %d parameters to a macro expecting %d", params.num, f->num_params), node);

auto b = cp_node(f->block.get());
con->tree->transform_block((Block*)b.get(), [con, f, params] (shared<Node> n) {
con->tree->transform_block((Block*)b.get(), [f, params] (shared<Node> n) {
if (n->kind == NodeKind::AbstractToken) {
for (int i=0; i<params.num; i++) {
if (n->as_token() == f->var[i]->name) {
Expand Down Expand Up @@ -1416,7 +1416,7 @@ shared<Node> Concretifier::concretify_statement_match(shared<Node> node, Block *

node->type = output_type;

bool is_exhaustive = false;
[[maybe_unused]] bool is_exhaustive = false;

if (!has_default) {
if (input_type->is_enum()) {
Expand Down Expand Up @@ -1792,8 +1792,8 @@ shared<Node> Concretifier::concretify_node(shared<Node> node, Block *block, cons
concretify_all_params(node, block, ns);
if (auto t = try_digest_type(tree, node->params[0]))
return add_node_class(tree->request_implicit_class_optional(t, node->token_id), node->token_id);
auto t = node->params[0]->type;
/*if (t->is_optional()) {
/*auto t = node->params[0]->type;
if (t->is_optional()) {
auto n = new Node(NodeKind::MAYBE, 0, t->param[0], node->flags, node->token_id);
n->set_num_params(1);
n->set_param(0, node->params[0]);
Expand Down
Loading

0 comments on commit 9e43d30

Please sign in to comment.