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 d3318b8
Show file tree
Hide file tree
Showing 31 changed files with 108 additions and 100 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
2 changes: 1 addition & 1 deletion src/lib/kaba/compiler/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void* get_nice_memory(int64 size, bool executable, Module *module) {
return mem;
//munmap(mem, size);
//if (config.verbose)
msg_write("...try again");
msg_write("...try again");
}
if (i > 5000) {
#if defined(OS_WINDOWS) || defined(OS_MINGW)
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
9 changes: 3 additions & 6 deletions src/lib/kaba/dynamic/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ extern const Class *TypeSpecialFunction;



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

KABA_LINK_GROUP_BEGIN

void var_assign(void *pa, const void *pb, const Class *type) {
if ((type == TypeInt32) or (type == TypeFloat32)) {
Expand Down Expand Up @@ -381,7 +377,8 @@ DynamicArray array_map(void *fff, DynamicArray *a, const Class *ti, const Class
return r;
}

#pragma GCC pop_options

KABA_LINK_GROUP_END



Expand Down
8 changes: 3 additions & 5 deletions src/lib/kaba/dynamic/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,7 @@ Array<StackFrameInfo> get_stack_trace(const StackFrameInfo& frame) {


// stack unwinding does not work if gcc does not use a stack frame...
#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
KABA_LINK_GROUP_BEGIN

StackFrameInfo get_current_stack_frame() {
void *rbp = nullptr;
Expand Down Expand Up @@ -387,7 +384,8 @@ void _cdecl kaba_raise_exception(KabaException *kaba_exception) {
just_die(kaba_exception, {});
#endif
}
#pragma GCC pop_options

KABA_LINK_GROUP_END


#elif defined(CPU_ARM64)
Expand Down
11 changes: 3 additions & 8 deletions src/lib/kaba/dynamic/sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ extern const Class *TypeAny;
extern const Class *TypePath;





#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
KABA_LINK_GROUP_BEGIN


void array_inplace_reverse(DynamicArray &array) {
Expand Down Expand Up @@ -112,7 +107,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 +216,7 @@ DynamicArray _cdecl array_sort(DynamicArray &array, const Class *type, const str
}


#pragma GCC pop_options
KABA_LINK_GROUP_END



Expand Down
16 changes: 16 additions & 0 deletions src/lib/kaba/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ void add_operator(OperatorID primitive_op, const Class *return_type, const Class



#if defined(COMPILER_GCC)
#define KABA_LINK_GROUP_BEGIN _Pragma("GCC push_options") \
_Pragma("GCC optimize(\"no-omit-frame-pointer\")") \
_Pragma("GCC optimize(\"no-inline\")") \
_Pragma("GCC optimize(\"0\")")
#elif defined(COMPILER_CLANG)
#define KABA_LINK_GROUP_BEGIN _Pragma("clang attribute push (__attribute((noinline)), apply_to = function)")
#endif


#if defined(COMPILER_GCC)
#define KABA_LINK_GROUP_END _Pragma("GCC pop_options")
#elif defined(COMPILER_CLANG)
#define KABA_LINK_GROUP_END _Pragma("clang attribute pop")
#endif




Expand Down
8 changes: 3 additions & 5 deletions src/lib/kaba/lib/lib_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ namespace kaba {
#define gl_p(p) p


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

KABA_LINK_GROUP_BEGIN

xfer<nix::Texture> __LoadTexture(const Path &filename) {
KABA_EXCEPTION_WRAPPER(return nix::Texture::load(filename));
Expand All @@ -36,7 +34,7 @@ xfer<nix::Shader> __ContextCreateShader(nix::Context *ctx, const string &source)
return nullptr;
}

#pragma GCC pop_options
KABA_LINK_GROUP_END

class KabaShader : public nix::Shader {
public:
Expand Down
9 changes: 4 additions & 5 deletions src/lib/kaba/lib/lib_kaba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ extern const Class* TypeSpecialFunctionRef;

string function_link_name(Function *f);

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


KABA_LINK_GROUP_BEGIN

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

#pragma GCC pop_options
KABA_LINK_GROUP_END


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


#pragma GCC push_options
#pragma GCC optimize("no-omit-frame-pointer")
#pragma GCC optimize("no-inline")
#pragma GCC optimize("0")
KABA_LINK_GROUP_BEGIN


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

#pragma GCC pop_options

KABA_LINK_GROUP_END


template<int N>
Expand Down
9 changes: 2 additions & 7 deletions src/lib/kaba/lib/lib_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ namespace kaba {
#define GetDAAddress(x) 0
#endif


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

KABA_LINK_GROUP_BEGIN

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

#pragma GCC pop_options
KABA_LINK_GROUP_END

void SIAddPackageNet(Context *c) {
add_package(c, "net");
Expand Down
Loading

0 comments on commit d3318b8

Please sign in to comment.