Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions lib/shoes_minimal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Minimal Shoes module for Ruby 3.x compatibility testing
# This replaces the full shoes.rb temporarily to avoid crashes during initialization

# The App and Dialog classes are defined by the C code in shoes_ruby_init
# We don't define them here to avoid conflicts

class Shoes
# Define the args! method that shoes_start_begin expects
# Accept optional argument for macOS compatibility
def self.args!(launch_flag = nil)
# Return the path to the script to load
# In a real implementation, this would parse command line arguments
ARGV.first || nil
end

# Define clean method that shoes_final expects
def self.clean
# Cleanup method called during shutdown
end

# Define visit method for loading scripts
def self.visit(path)
$stderr.puts "Shoes.visit called with: #{path}"
# Load and execute the script
if path && File.exist?(path)
$stderr.puts "Loading script: #{path}"
begin
# Actually execute the script in the main context
load path
$stderr.puts "Script executed successfully"
rescue => e
$stderr.puts "Error executing script: #{e.message}"
$stderr.puts e.backtrace.join("\n")
end
end
# Return nil to prevent further processing
nil
end

# Define show_log for error handling
def self.show_log
puts "Shoes.show_log called"
end

# The app method is defined in C as shoes_app_main
# Let's check what methods are available
$stderr.puts "[Ruby] Shoes singleton methods: #{singleton_methods.inspect}"

# Check if Shoes module has the App class defined
if const_defined?(:App)
$stderr.puts "[Ruby] App class is defined"
else
$stderr.puts "[Ruby] App class is NOT defined"
end

# Don't override the C implementation if it exists
unless singleton_methods.include?(:app)
$stderr.puts "[Ruby] Defining fallback Shoes.app method"
def self.app(opts = {}, &block)
$stderr.puts "[Ruby] Warning: C version of Shoes.app not found, using stub"
nil
end
else
$stderr.puts "[Ruby] Shoes.app method already defined by C"
end

# Define splash method for the idle timer
def self.splash
$stderr.puts "Shoes.splash called"
end
end

# Skip the problematic secret_exit_hook for now
# We'll implement proper exit handling later

puts "[Shoes] Minimal shoes.rb loaded successfully"
17 changes: 6 additions & 11 deletions make/darwin/minosx/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
SHOES_TGT_ARCH = RbConfig::CONFIG['arch']
SHOES_GEM_ARCH = arch_2_gem[RbConfig::CONFIG['arch']]
#osxsdk = arch_2_sdk[RbConfig::CONFIG['arch']]
osxsdk = 'MacOSX10.12.sdk' # 12 is as high as we can go w/o code changes
osxminv = osxsdk[/(\d+\.\d+)/]
osxsdk = 'MacOSX.sdk' # Use the default SDK symlink
osxminv = '10.15' # Set a reasonable minimum version

$stderr.puts "arch #{SHOES_TGT_ARCH} -> #{SHOES_GEM_ARCH}"

Expand All @@ -107,12 +107,12 @@
# nothing much is going to change for 10.10 deps - don't bother with pkg-config
# because it does go wrong in this situation.
GLIB_CFLAGS = "-I#{ShoesDeps}/include/glib-2.0 -I#{ShoesDeps}/lib/glib-2.0/include"
GLIB_CFLAGS << " -I#{ShoesDeps}/include/librsvg-2.0/librsvg -I#{ShoesDeps}/include/gdk-pixbuf-2.0/"
GLIB_CFLAGS << " -I#{ShoesDeps}/include/librsvg-2.0 -I#{ShoesDeps}/include/gdk-pixbuf-2.0/"
GLIB_LDFLAGS = "-L#{ShoesDeps}/lib -lglib-2.0 -lgobject-2.0 -lintl #{ShoesDeps}/lib/librsvg-2.2.dylib"
GLIB_LDFLAGS << " -lyaml-0.2"
CAIRO_CFLAGS = "-I#{ShoesDeps}/include/cairo"
CAIRO_LDFLAGS = "-L#{ShoesDeps}/lib -lcairo"
PANGO_CFLAGS = "-I#{ShoesDeps}/include/pango-1.0"
PANGO_CFLAGS = "-I#{ShoesDeps}/include/pango-1.0 -I#{ShoesDeps}/include/harfbuzz"
PANGO_LDFLAGS = "-L#{ShoesDeps}/lib -lpango-1.0"
#RUBY_CFLAGS = "-I#{EXT_RUBY}/include/ruby-2.3.0/x86_64-darwin14 -I#{EXT_RUBY}/include/ruby-2.3.0 "
RUBY_CFLAGS =`pkg-config --cflags "#{pkgruby}"`.strip+" "
Expand Down Expand Up @@ -140,7 +140,7 @@
LINUX_CFLAGS << " -Wno-deprecated-declarations"
end

OSX_ARCH = '-arch x86_64'
OSX_ARCH = '-arch arm64' # Build for Apple Silicon

ENV['CC'] = CC
ENV['TGT_RUBY_PATH'] = EXT_RUBY
Expand All @@ -157,14 +157,9 @@
# Sigh - shoesdeps and homebrew versions can be out of sync.
# The following dylibs (may) need explicit copying.
SOLOCS = {
'libcurl.dylib' => "/usr/lib/libcurl.4.dylib",
'libxml2.2.dylib' => "/usr/lib/libxml2.2.dylib",
'libexpat.1.dylib' => "/usr/lib/libexpat.1.dylib",
'libz.1.dylib' => "/usr/lib/libz.1.dylib",
'libgobject-2.0.0.dylib' => "#{libdll}/libgobject-2.0.0.dylib",
'libgdk_pixbuf-2.0.0.dylib' => "#{libdll}/libgdk_pixbuf-2.0.0.dylib",
'libgio-2.0.0.dylib' => "#{libdll}/libgio-2.0.0.dylib",
'libgmodule-2.0.0.dylib' => "#{libdll}/libgmodule-2.0.0.dylib",
'libcroco-0.6.3.dylib' => "#{libdll}/libcroco-0.6.3.dylib",
'libgmodule-2.0.0.dylib' => "#{libdll}/libgmodule-2.0.0.dylib"
}

104 changes: 98 additions & 6 deletions shoes/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,42 @@ shoes_code shoes_app_start(VALUE allapps, char *uri) {
shoes_code code;
shoes_app *app;

fprintf(stderr, "[SHOES] shoes_app_start: Starting with %ld apps\n", RARRAY_LEN(allapps));
for (i = 0; i < RARRAY_LEN(allapps); i++) {
VALUE appobj2 = rb_ary_entry(allapps, i);
fprintf(stderr, "[SHOES] shoes_app_start: Processing app %d\n", i);
Data_Get_Struct(appobj2, shoes_app, app);
if (!app->started) {
fprintf(stderr, "[SHOES] shoes_app_start: Opening app %d\n", i);
code = shoes_app_open(app, uri);
app->started = TRUE;
if (code != SHOES_OK)
return code;
}
}

fprintf(stderr, "[SHOES] shoes_app_start: Calling shoes_app_loop\n");
return shoes_app_loop();
}

shoes_code shoes_app_open(shoes_app *app, char *path) {
shoes_code code = SHOES_OK;
int dialog = (rb_obj_class(app->self) == cDialog);
int dialog;
shoes_settings *st;

fprintf(stderr, "[SHOES] shoes_app_open: app=%p, path=%s\n", (void*)app, path);
if (!app) {
fprintf(stderr, "[SHOES] shoes_app_open: ERROR - app is NULL!\n");
return SHOES_QUIT;
}

if (!app->self) {
fprintf(stderr, "[SHOES] shoes_app_open: ERROR - app->self is NULL!\n");
return SHOES_QUIT;
}

dialog = (rb_obj_class(app->self) == cDialog);

Data_Get_Struct(shoes_world->settings, shoes_settings, st);

if (st->use_menus == Qtrue) {
Expand All @@ -422,42 +440,71 @@ shoes_code shoes_app_open(shoes_app *app, char *path) {
code = shoes_native_app_open_menu(app, path, dialog, st);
else
#endif
fprintf(stderr, "[SHOES] shoes_app_open: Calling shoes_native_app_open\n");
code = shoes_native_app_open(app, path, dialog, st);
fprintf(stderr, "[SHOES] shoes_app_open: shoes_native_app_open returned %lu\n", code);

if (code != SHOES_OK)
return code;

fprintf(stderr, "[SHOES] shoes_app_open: About to set title, app->title=%p\n", (void*)app->title);
#ifndef MTITTLE
shoes_app_title(app, app->title);
#else
shoes_settings *st;
Data_Get_Struct(shoes_settings_globalv, shoes_settings, st);
shoes_app_title(app, st->app_name);
#endif
if (app->slot != NULL)
fprintf(stderr, "[SHOES] shoes_app_open: Title set\n");
fprintf(stderr, "[SHOES] shoes_app_open: app->slot=%p\n", (void*)app->slot);
if (app->slot != NULL) {
fprintf(stderr, "[SHOES] shoes_app_open: Calling shoes_native_slot_reset\n");
shoes_native_slot_reset(app->slot);
fprintf(stderr, "[SHOES] shoes_app_open: shoes_native_slot_reset done\n");
}
#ifndef SHOES_QUARTZ
if (app->have_menu)
shoes_slot_init_menu(app->canvas, app->slot, 0, 0, app->width, app->height, TRUE, TRUE);
else
#endif
fprintf(stderr, "[SHOES] shoes_app_open: Calling shoes_slot_init\n");
shoes_slot_init(app->canvas, app->slot, 0, 0, app->width, app->height, TRUE, TRUE);
fprintf(stderr, "[SHOES] shoes_app_open: shoes_slot_init done\n");

fprintf(stderr, "[SHOES] shoes_app_open: Calling shoes_app_goto with path=%s\n", path);
code = shoes_app_goto(app, path);
fprintf(stderr, "[SHOES] shoes_app_open: shoes_app_goto returned %lu\n", code);
if (code != SHOES_OK)
return code;

if (!app->hidden)
fprintf(stderr, "[SHOES] shoes_app_open: app->hidden=%d\n", app->hidden);
if (!app->hidden) {
fprintf(stderr, "[SHOES] shoes_app_open: Calling shoes_native_app_show\n");
shoes_native_app_show(app);
fprintf(stderr, "[SHOES] shoes_app_open: shoes_native_app_show done\n");
}
fprintf(stderr, "[SHOES] shoes_app_open: Returning %lu\n", code);
return code;
}

shoes_code shoes_app_loop() {
if (shoes_world->mainloop)
fprintf(stderr, "[SHOES] shoes_app_loop: Starting\n");
if (shoes_world->mainloop) {
fprintf(stderr, "[SHOES] shoes_app_loop: Already in mainloop, returning\n");
return SHOES_OK;
}

// Check if we have any apps to display
if (RARRAY_LEN(shoes_world->apps) == 0) {
fprintf(stderr, "[SHOES] shoes_app_loop: No apps to display, exiting\n");
return SHOES_OK;
}

shoes_world->mainloop = TRUE;
INFO("RUNNING LOOP.\n");
fprintf(stderr, "[SHOES] shoes_app_loop: Calling shoes_native_loop\n");
shoes_native_loop();
fprintf(stderr, "[SHOES] shoes_app_loop: shoes_native_loop returned\n");
return SHOES_OK;
}

Expand Down Expand Up @@ -525,13 +572,51 @@ shoes_code shoes_app_visit(shoes_app *app, char *path) {
shoes_exec exec;
shoes_canvas *canvas;
VALUE meth;

fprintf(stderr, "[SHOES] shoes_app_visit: app=%p, path=%s\n", (void*)app, path);
fprintf(stderr, "[SHOES] shoes_app_visit: app->canvas=%p\n", (void*)app->canvas);

Data_Get_Struct(app->canvas, shoes_canvas, canvas);
fprintf(stderr, "[SHOES] shoes_app_visit: canvas=%p\n", (void*)canvas);

if (!canvas) {
fprintf(stderr, "[SHOES] shoes_app_visit: ERROR - canvas is NULL!\n");
return SHOES_QUIT;
}

fprintf(stderr, "[SHOES] shoes_app_visit: canvas->slot=%p\n", (void*)canvas->slot);
if (!canvas->slot) {
fprintf(stderr, "[SHOES] shoes_app_visit: ERROR - canvas->slot is NULL!\n");
return SHOES_QUIT;
}

canvas->slot->scrolly = 0;
fprintf(stderr, "[SHOES] shoes_app_visit: Set scrolly to 0\n");

fprintf(stderr, "[SHOES] shoes_app_visit: Calling shoes_native_slot_clear\n");
shoes_native_slot_clear(canvas);
fprintf(stderr, "[SHOES] shoes_app_visit: shoes_native_slot_clear done\n");

fprintf(stderr, "[SHOES] shoes_app_visit: Calling shoes_app_clear\n");
shoes_app_clear(app);
fprintf(stderr, "[SHOES] shoes_app_visit: shoes_app_clear done\n");

fprintf(stderr, "[SHOES] shoes_app_visit: Calling shoes_app_reset_styles\n");
shoes_app_reset_styles(app);
meth = rb_funcall(cShoes, s_run, 1, app->location = rb_str_new2(path));
fprintf(stderr, "[SHOES] shoes_app_visit: shoes_app_reset_styles done\n");

fprintf(stderr, "[SHOES] shoes_app_visit: cShoes=%p, s_run=%ld\n", (void*)cShoes, (long)s_run);
fprintf(stderr, "[SHOES] shoes_app_visit: Calling rb_funcall(cShoes, s_run, ...)\n");

// Check if cShoes responds to 'run'
if (!rb_respond_to(cShoes, s_run)) {
fprintf(stderr, "[SHOES] ERROR: cShoes does not respond to 'run'\n");
// For now, just skip this call
meth = rb_ary_new3(2, Qnil, rb_str_new2(path));
} else {
meth = rb_funcall(cShoes, s_run, 1, app->location = rb_str_new2(path));
fprintf(stderr, "[SHOES] shoes_app_visit: rb_funcall returned\n");
}

VALUE app_block = rb_iv_get(app->self, "@main_app");
if (!NIL_P(app_block))
Expand Down Expand Up @@ -667,7 +752,7 @@ shoes_code shoes_app_motion(shoes_app *app, int x, int y, int mods) {
shoes_canvas_send_motion(app->canvas, x, y, Qnil, modifiers);
return SHOES_OK;
}
EXTERN ID s_shift_key, s_control_key;
extern ID s_shift_key, s_control_key;

shoes_code shoes_app_click(shoes_app *app, int button, int x, int y, int mods) {
app->mouseb = button;
Expand Down Expand Up @@ -983,7 +1068,12 @@ static void shoes_style_set(VALUE styles, VALUE klass, VALUE k, VALUE v) {
ID2SYM(rb_intern("" # k)), rb_str_new2("" # v))

void shoes_app_reset_styles(shoes_app *app) {
fprintf(stderr, "[SHOES] shoes_app_reset_styles: Starting\n");
app->styles = rb_hash_new();

// TODO: These constants need to be defined first
// For now, skip the styles to avoid crashes
#if 0
STYLE(cBanner, size, 48);
STYLE(cTitle, size, 34);
STYLE(cSubtitle, size, 26);
Expand All @@ -1005,6 +1095,8 @@ void shoes_app_reset_styles(shoes_app *app) {
STYLE(cSup, size, x-small);
STYLE(cSub, rise, -10);
STYLE(cSub, size, x-small);
#endif
fprintf(stderr, "[SHOES] shoes_app_reset_styles: Done\n");
}

void shoes_app_style(shoes_app *app, VALUE klass, VALUE hsh) {
Expand Down
14 changes: 7 additions & 7 deletions shoes/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,13 @@ static void shoes_canvas_memdraw(VALUE self, VALUE block) {
DRAW(self, canvas->app, rb_funcall(block, s_call, 0));
}

typedef cairo_public cairo_surface_t * (cairo_surface_function_t) (const char *filename, double width, double height);
typedef cairo_surface_t * (*cairo_surface_function_t) (const char *filename, double width, double height);

static cairo_surface_function_t * shoes_get_snapshot_surface(VALUE _format) {
static cairo_surface_function_t shoes_get_snapshot_surface(VALUE _format) {
ID format = SYM2ID (_format);
if (format == rb_intern ("pdf")) return & cairo_pdf_surface_create;
if (format == rb_intern ("ps")) return & cairo_ps_surface_create;
if (format == rb_intern ("svg")) return & cairo_svg_surface_create;
if (format == rb_intern ("pdf")) return cairo_pdf_surface_create;
if (format == rb_intern ("ps")) return cairo_ps_surface_create;
if (format == rb_intern ("svg")) return cairo_svg_surface_create;
return NULL;
}

Expand All @@ -678,8 +678,8 @@ VALUE shoes_canvas_snapshot(int argc, VALUE *argv, VALUE self) {
":format=>:pdf|:ps|:svg}, &block)\n");
} else {
const char * filename = RSTRING_PTR(_filename);
cairo_surface_t * surface = shoes_get_snapshot_surface(_format)
(filename, canvas->width, canvas->height);
cairo_surface_function_t func = shoes_get_snapshot_surface(_format);
cairo_surface_t * surface = func ? func(filename, canvas->width, canvas->height) : NULL;
if (surface == NULL) {
rb_raise(rb_eArgError, "Failed to create %s surface for file %s\n",
RSTRING_PTR(rb_inspect(_format)),
Expand Down
2 changes: 1 addition & 1 deletion shoes/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "shoes/config.h"
#include "shoes/code.h"
#include <rsvg.h>
#include <librsvg/rsvg.h>

struct _shoes_app;

Expand Down
4 changes: 4 additions & 0 deletions shoes/console/cocoa-term.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ - (void) stdOutDataSink: (NSNotification *) notification
// create the bridge object before Ruby is initialized called from
// world.c
void shoes_osx_setup_stdout() {
// Temporarily disable stdout redirection for debugging
bridge = NULL;
return;

if (osx_cshoes_launch) {
bridge = NULL;
} else {
Expand Down
Loading