Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #233

Merged
merged 34 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
97c806f
fix event list gen for sub packages
mcorino Dec 18, 2023
4e049b6
add missing ignore
mcorino Dec 18, 2023
7ac27d8
improve wxGenericStaticBitmap generation
mcorino Dec 18, 2023
5cdcb5b
cleanup doc gen
mcorino Dec 21, 2023
654ecc8
add dependency to guarantee correct build order for event list gen
mcorino Dec 21, 2023
8d723b6
add missing parentheses
mcorino Dec 21, 2023
feab8b5
add gc_as_marked / GC_MANAGE_AS_MARKED GC type to better direct doc gen
mcorino Dec 21, 2023
4a0653c
replace gc_as_untracked by gs_as_marked
mcorino Dec 21, 2023
53521d1
support intra-module inheritance
mcorino Dec 22, 2023
628116c
remove incorrect class rename
mcorino Dec 22, 2023
a9182f4
add persistence support with docs
mcorino Dec 23, 2023
87e89ed
add persistence support
mcorino Dec 23, 2023
f70fc4e
fix setting path to explicit root ('/')
mcorino Dec 23, 2023
bff3d08
add PersistentComboBox for wxw >= 3.3.0
mcorino Dec 23, 2023
f608cb2
add additional virtual methods missing from docs
mcorino Dec 29, 2023
1dd7737
improve config support (add C++ wrapper)
mcorino Jan 3, 2024
f12dc46
update config tests
mcorino Jan 3, 2024
ffdd19f
add initial persistence tests
mcorino Jan 3, 2024
d451b0c
fix typo in version check
mcorino Jan 3, 2024
3e92b7c
add output type mappings
mcorino Jan 4, 2024
b36ef2b
add missing typemap
mcorino Jan 4, 2024
6ce9df4
improve bool coercion
mcorino Jan 4, 2024
899f146
better handle platform differences config compare
mcorino Jan 4, 2024
aea3d44
fix problems with custom methods
mcorino Jan 4, 2024
7de1853
add missing doc
mcorino Jan 4, 2024
c70a916
add custom persistence test
mcorino Jan 4, 2024
51ef0da
work around WXMSW CI build problems
mcorino Jan 4, 2024
280c4e8
add extra asserts
mcorino Jan 4, 2024
c92f746
make tests less sensitive to CI build env
mcorino Jan 4, 2024
0aceafb
fix boolean encoding with Wx::ConfigWx
mcorino Jan 4, 2024
3c6103e
fix ConfigWx#number_of_xxx methods
mcorino Jan 4, 2024
1dae760
write smallest possible integer size
mcorino Jan 5, 2024
75f3318
properly initialize variables before reading
mcorino Jan 5, 2024
d94798c
use smaller integer to write bool value
mcorino Jan 5, 2024
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
28 changes: 23 additions & 5 deletions ext/wxruby3/include/wxruby-Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static int wxrb_CountConfig(VALUE key, VALUE value, VALUE rbCounter)
}

static VALUE g_cConfigBase;
static VALUE g_cConfigWx;
static VALUE g_cConfig;

/*
Expand Down Expand Up @@ -88,12 +89,18 @@ class wxRbHashConfig : public wxConfigBase

virtual ~wxRbHashConfig()
{
DATA_PTR(m_cfgInstance) = 0; // make sure it never get's deleted twice
if (!NIL_P(m_cfgInstance))
{
DATA_PTR(m_cfgInstance) = 0; // make sure it never get's deleted twice
}
}

// Get wrapped Ruby ConfigBase instance
// Get wrapped Ruby Config instance
VALUE GetRubyConfig() const { return m_cfgInstance; }

// Reset wrapped Ruby Config instance
void ResetRubyConfig() { m_cfgInstance = Qnil; }

// implement inherited pure virtual functions
virtual void SetPath(const wxString& strPath) override { DoSetPath(strPath, true /* create missing components */); }
virtual const wxString& GetPath() const override { return m_strPath; }
Expand Down Expand Up @@ -806,7 +813,7 @@ class wxRbHashConfig : public wxConfigBase

void SetRootPath()
{
m_strPath.Empty();
m_strPath.Clear();
m_cfgGroup = m_cfgHash;
m_cfgGroupKeys = Qnil;
}
Expand All @@ -815,7 +822,7 @@ class wxRbHashConfig : public wxConfigBase
// if path doesn't exist and createMissingComponents == false
bool DoSetPath(const wxString& strPath, bool createMissingComponents)
{
if ( strPath.empty() )
if ( strPath.IsEmpty() || strPath == cfgSepStr)
{
SetRootPath();
return true;
Expand Down Expand Up @@ -913,7 +920,8 @@ static const char * __iv_Config_data = "@data";

WXRUBY_EXPORT bool wxRuby_IsRubyConfig(VALUE rbConfig)
{
return rb_obj_is_kind_of(rbConfig, g_cConfig) == Qtrue;
return rb_obj_is_kind_of(rbConfig, g_cConfig) == Qtrue ||
rb_obj_is_kind_of(rbConfig, g_cConfigWx) == Qtrue;
}

// Wrap a Ruby hash for input type mapping
Expand All @@ -933,6 +941,12 @@ WXRUBY_EXPORT wxConfigBase* wxRuby_Ruby2ConfigBase(VALUE rbConfig)
// return wrapper
return config;
}
else if (rb_obj_is_kind_of(rbConfig, g_cConfigWx) == Qtrue)
{
wxConfigBase* cfg;
Data_Get_Struct(rbConfig, wxConfigBase, cfg);
return cfg;
}
return nullptr;
}

Expand All @@ -946,6 +960,10 @@ WXRUBY_EXPORT VALUE wxRuby_ConfigBase2Ruby(wxConfigBase* config)
{
return hsh_config->GetRubyConfig();
}
else
{
return Data_Wrap_Struct(g_cConfigWx, 0, 0, config);
}
}
return Qnil;
}
Expand Down
79 changes: 79 additions & 0 deletions ext/wxruby3/include/wxruby-Persistence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) 2023 M.J.N. Corino, The Netherlands
//
// This software is released under the MIT license.

/*
* WxRuby3 persistence classes
*/

#ifndef _WXRUBY_PERSISTENCE_HASH_H
#define _WXRUBY_PERSISTENCE_HASH_H

#include <wx/persist.h>
#include <wx/config.h>

#include <map>

/*
This class serves as a base for any Ruby defined persistence manager in order to provide
customized save and restore methods for Ruby values but also as a replacement for the
default global persistence manager instance.
*/
class WxRubyPersistenceManager : public wxPersistenceManager
{
private:
typedef std::map<VALUE, VALUE> rb_object_to_rb_po_map_t;
rb_object_to_rb_po_map_t rb_object_po_map_;

public:
WxRubyPersistenceManager() : wxPersistenceManager() {}

bool SaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value);

VALUE RestoreRubyValue(const wxPersistentObject& who, const wxString& name);


bool DoSaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value);

VALUE DoRestoreRubyValue(const wxPersistentObject& who, const wxString& name);

void RegisterRbPO(VALUE rb_obj, VALUE rb_po)
{
rb_object_po_map_[rb_obj] = rb_po;
}

VALUE FindRbPO(VALUE rb_obj)
{
VALUE rb_po = Qnil;
if (rb_object_po_map_.count(rb_obj) > 0)
{
rb_po = rb_object_po_map_[rb_obj];
}
return rb_po;
}

VALUE UnregisterRbPO(VALUE rb_obj)
{
VALUE rb_po = Qnil;
if (rb_object_po_map_.count(rb_obj) > 0)
{
rb_po = rb_object_po_map_[rb_obj];
rb_object_po_map_.erase(rb_obj);
}
return rb_po;
}

void GC_markPO();

static void UnregisterPersistentObject(VALUE rb_obj);
};

class WxRubyPersistentObject : public wxPersistentObject
{
public:
virtual ~WxRubyPersistentObject();
protected:
WxRubyPersistentObject(VALUE rb_obj);
};

#endif /* _WXRUBY_PERSISTENCE_HASH_H */
6 changes: 6 additions & 0 deletions ext/wxruby3/swig/memory_management.i
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ GC_NEVER(kls);
%define GC_MANAGE_AS_UNTRACKED(kls)
%enddef

// Strategy for objects that are GC marked through customized, tailored, mechanisms outside
// of the standard SWIG object tracking option.
// The different naming is mostly to allow doc gen to properly recognize these objects.
%define GC_MANAGE_AS_MARKED(kls)
%enddef

// Sizers attached to windows are automatically destroyed by wxWidgets,
// so they should not be deleted.
//
Expand Down
16 changes: 16 additions & 0 deletions lib/wx/core/book_ctrl_base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

module Wx

class BookCtrlBase

# create PersistentObject for toplevel windows (incl. Dialog and Frame)
def create_persistent_object
PersistentBookCtrl.new(self)
end

end

end
Loading