Sha256: a1d7eafce312a83c4c3a415215aaeb96b633a9b9705a07151c8afc2d6af367e1

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

// Copyright (c) 2023 M.J.N. Corino, The Netherlands
//
// This software is released under the MIT license.

#ifndef WXRUBY_EXPORT
#define WXRUBY_EXPORT WXRB_EXPORT_FLAG
#endif

#include "wxruby-ClientData.h"

#include <set>

static std::set<wxRubyClientData*> __s_WxRubyClientDataSet;
static std::set<wxRubyUserData*> __s_WxRubyUserDataSet;

WXRB_EXPORT_FLAG void wxRuby_RegisterClientData(wxRubyClientData* pcd)
{
  __s_WxRubyClientDataSet.insert(pcd);
}

WXRB_EXPORT_FLAG void wxRuby_RegisterUserData(wxRubyUserData* pud)
{
  __s_WxRubyUserDataSet.insert(pud);
}

static ID client_data_unlinked_id()
{
  static ID __s_client_data_unlinked_id {};
  if (__s_client_data_unlinked_id == ID())
  {
    __s_client_data_unlinked_id = rb_intern("client_data_unlinked");
  }
  return __s_client_data_unlinked_id;
}

WXRB_EXPORT_FLAG void wxRuby_UnregisterClientData(wxRubyClientData* pcd)
{
  VALUE rbcd = pcd->GetData();
  __s_WxRubyClientDataSet.erase(pcd);
  if (!NIL_P(rbcd) && rb_respond_to(rbcd, client_data_unlinked_id()))
  {
    wxRuby_Funcall(rbcd, client_data_unlinked_id(), 0);
  }
}

WXRB_EXPORT_FLAG void wxRuby_UnregisterUserData(wxRubyUserData* pud)
{
  VALUE rbud = pud->GetData();
  __s_WxRubyUserDataSet.erase(pud);
  if (!NIL_P(rbud) && rb_respond_to(rbud, client_data_unlinked_id()))
  {
    wxRuby_Funcall(rbud, client_data_unlinked_id(), 0);
  }
}

static void wxRuby_GC_mark_ClientData()
{
  for (wxRubyClientData* pcd : __s_WxRubyClientDataSet)
    rb_gc_mark(pcd->GetData());
  for (wxRubyUserData* pud : __s_WxRubyUserDataSet)
    rb_gc_mark(pud->GetData());
}

typedef void (*WXRBMarkFunction)();
WXRUBY_EXPORT void wxRuby_AppendMarker(WXRBMarkFunction marker);

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wxruby3-1.3.1 rakelib/lib/core/include/client_data.inc
wxruby3-1.3.0 rakelib/lib/core/include/client_data.inc
wxruby3-1.2.1 rakelib/lib/core/include/client_data.inc
wxruby3-1.2.0 rakelib/lib/core/include/client_data.inc
wxruby3-1.1.2 rakelib/lib/core/include/client_data.inc
wxruby3-1.1.1 rakelib/lib/core/include/client_data.inc
wxruby3-1.1.0 rakelib/lib/core/include/client_data.inc
wxruby3-1.0.1 rakelib/lib/core/include/client_data.inc
wxruby3-0.9.8 rakelib/lib/core/include/client_data.inc
wxruby3-0.9.7 rakelib/lib/core/include/client_data.inc
wxruby3-0.9.5 rakelib/lib/core/include/client_data.inc
wxruby3-0.9.4 rakelib/lib/core/include/client_data.inc
wxruby3-0.9.3 rakelib/lib/core/include/client_data.inc