<commit_before>
#include <stdio.h>

#include "song.h"

#define return_if_disposed(a) if(self->private->dispose_has_run) return a

enum {
  SONG_NAME=1
};

struct _BtSongPrivate {
  /* used to validate if dispose has run */
  gboolean dispose_has_run;
  
  /* the name for the song */
  gchar *name;
  gpointer data;
};


static void bt_song_real_start_play(BtSong *self) {
  /* emitting signal if we start play */
  g_signal_emit(self, 
                BT_SONG_GET_CLASS(self)->play_signal_id,
                0,
                NULL);
}

/* play method from song */
void bt_song_start_play(BtSong *self) {
  BT_SONG_GET_CLASS(self)->start_play(self);
}

static void song_get_property (GObject      *object,
                               guint         property_id,
                               GValue       *value,
                               GParamSpec   *pspec)
{
  BtSong *self = (BtSong *)object;
  return_if_disposed();
  switch (property_id) {
    case SONG_NAME: {
      g_value_set_string(value, self->private->name);
    } break;
    default: {
      g_assert(FALSE);
      break;
    }
  }
}

static void song_set_property(GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
  BtSong *self = (BtSong *)object;
  return_if_disposed();
  switch (property_id) {
    case SONG_NAME: {
      g_free(self->private->name);
      self->private->name = g_value_dup_string(value);
      //g_print("set the name for song: %s\n",self->private->name);
    } break;
  }
}

static void song_dispose(GObject *object) {
  BtSong *self = (BtSong *)object;
  if (self->private->dispose_has_run) {
    return;
  }
  self->private->dispose_has_run = TRUE;
}

static void song_finalize(GObject *object) {
  BtSong *self = (BtSong *)object;
  g_free(self->private);
}

static void bt_song_init(GTypeInstance *instance, gpointer g_class) {
  BtSong *self = (BtSong*)instance;
  self->private = g_new0(BtSongPrivate,1);
  self->private->dispose_has_run = FALSE;
  //puts(__FUNCTION__);
}

static void bt_song_class_init(BtSongClass *klass) {
  
  GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
  GParamSpec *bt_song_param_spec;
  
  gobject_class->set_property = song_set_property;
  gobject_class->get_property = song_get_property;
  gobject_class->dispose = song_dispose;
  gobject_class->finalize = song_finalize;
  
  klass->start_play = bt_song_real_start_play;
  
  /* adding simple signal */
  klass->play_signal_id = g_signal_new("play",
                                        G_TYPE_FROM_CLASS(klass),
                                        G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
                                        G_ABS_STRUCT_OFFSET(BtSongClass,play_event),<commit_msg>* design/gobject/song.c: (bt_song_class_init): * docs/reference/bt-core/bt-core-sections.txt: * src/lib/core/libbtcore/core.h: * src/lib/core/machine.c: * src/lib/core/pattern.c: (bt_pattern_class_init), (bt_pattern_get_type): * src/lib/core/persistence-location.c: (bt_persistence_location_get_type): * src/lib/core/persistence-selection.c: (bt_persistence_selection_get_type): * src/lib/core/plainfile-settings.c: (bt_plainfile_settings_get_type): * src/lib/core/processor-machine.c: (bt_processor_machine_get_type): * src/lib/core/sequence.c: (bt_sequence_get_type): * src/lib/core/settings.c: (bt_settings_get_type): * src/lib/core/setup.c: (bt_setup_class_init), (bt_setup_get_type): * src/lib/core/sink-bin.c: (bt_sink_bin_get_type): * src/lib/core/sink-machine.c: (bt_sink_machine_get_type): * src/lib/core/song-info.c: (bt_song_info_get_type): * src/lib/core/song-io-native.c: (bt_song_io_native_get_type): * src/lib/core/song-io.c: (bt_song_io_get_type): * src/lib/core/song.c: (bt_song_get_type): * src/lib/core/source-machine.c: (bt_source_machine_get_type): * src/lib/core/wave.c: (bt_wave_get_type): * src/lib/core/wavelevel.c: (bt_wavelevel_get_type): * src/lib/core/wavetable.c: (bt_wavetable_get_type): * src/lib/core/wire.c: (bt_wire_get_type): * src/ui/cmd/cmd-application.c: (bt_cmd_application_get_type): * src/ui/edit/bt-edit.c: (usage): * src/ui/edit/edit-application.c: (bt_edit_application_get_type): * src/ui/edit/interaction-controller-menu.c: (bt_interaction_controller_menu_get_type): * src/ui/edit/machine-canvas-item.c: (bt_machine_canvas_item_get_type): * src/ui/edit/machine-menu.c: (bt_machine_menu_get_type): * src/ui/edit/main-menu.c: (bt_main_menu_get_type): * src/ui/edit/main-page-info.c: (bt_main_page_info_get_type): * src/ui/edit/main-page-machines.c: (bt_main_page_machines_get_type): * src/ui/edit/main-page-patterns.c: (bt_main_page_patterns_get_type): * src/ui/edit/main-page-sequence.c: (bt_main_page_sequence_get_type): * src/ui/edit/main-pages.c: (bt_main_pages_get_type): * src/ui/edit/main-statusbar.c: (bt_main_statusbar_get_type): * src/ui/edit/main-toolbar.c: (bt_main_toolbar_get_type): * src/ui/edit/main-window.c: (bt_main_window_get_type): * src/ui/edit/pattern-view.c: (bt_pattern_view_get_type): * src/ui/edit/playback-controller-socket.c: (bt_playback_controller_socket_get_type): * src/ui/edit/render-dialog.c: (bt_render_dialog_init_ui), (bt_render_dialog_get_type): * src/ui/edit/sequence-view.c: (bt_sequence_view_get_type): * src/ui/edit/settings-dialog.c: (bt_settings_dialog_get_type): * src/ui/edit/settings-page-audiodevices.c: (bt_settings_page_audiodevices_get_type): * src/ui/edit/settings-page-interaction-controller.c: (bt_settings_page_interaction_controller_get_type): * src/ui/edit/settings-page-playback-controller.c: (bt_settings_page_playback_controller_get_type): * src/ui/edit/ui-ressources.c: (bt_ui_ressources_get_type): * src/ui/edit/wire-canvas-item.c: (bt_wire_canvas_item_get_type): * tests/bt-test-plugin.c: (bt_test_mono_source_get_type), (bt_test_poly_source_get_type): * tests/bt-test-settings.c: (bt_test_settings_get_type): Remove G_STRUCT_SIZE and G_ABS_STRUCT_OFFSET (was splint tuning and clobbering glib namespace).<commit_after>
#include <stdio.h>

#include "song.h"

#define return_if_disposed(a) if(self->private->dispose_has_run) return a

enum {
  SONG_NAME=1
};

struct _BtSongPrivate {
  /* used to validate if dispose has run */
  gboolean dispose_has_run;
  
  /* the name for the song */
  gchar *name;
  gpointer data;
};


static void bt_song_real_start_play(BtSong *self) {
  /* emitting signal if we start play */
  g_signal_emit(self, 
                BT_SONG_GET_CLASS(self)->play_signal_id,
                0,
                NULL);
}

/* play method from song */
void bt_song_start_play(BtSong *self) {
  BT_SONG_GET_CLASS(self)->start_play(self);
}

static void song_get_property (GObject      *object,
                               guint         property_id,
                               GValue       *value,
                               GParamSpec   *pspec)
{
  BtSong *self = (BtSong *)object;
  return_if_disposed();
  switch (property_id) {
    case SONG_NAME: {
      g_value_set_string(value, self->private->name);
    } break;
    default: {
      g_assert(FALSE);
      break;
    }
  }
}

static void song_set_property(GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
  BtSong *self = (BtSong *)object;
  return_if_disposed();
  switch (property_id) {
    case SONG_NAME: {
      g_free(self->private->name);
      self->private->name = g_value_dup_string(value);
      //g_print("set the name for song: %s\n",self->private->name);
    } break;
  }
}

static void song_dispose(GObject *object) {
  BtSong *self = (BtSong *)object;
  if (self->private->dispose_has_run) {
    return;
  }
  self->private->dispose_has_run = TRUE;
}

static void song_finalize(GObject *object) {
  BtSong *self = (BtSong *)object;
  g_free(self->private);
}

static void bt_song_init(GTypeInstance *instance, gpointer g_class) {
  BtSong *self = (BtSong*)instance;
  self->private = g_new0(BtSongPrivate,1);
  self->private->dispose_has_run = FALSE;
  //puts(__FUNCTION__);
}

static void bt_song_class_init(BtSongClass *klass) {
  
  GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
  GParamSpec *bt_song_param_spec;
  
  gobject_class->set_property = song_set_property;
  gobject_class->get_property = song_get_property;
  gobject_class->dispose = song_dispose;
  gobject_class->finalize = song_finalize;
  
  klass->start_play = bt_song_real_start_play;
  
  /* adding simple signal */
  klass->play_signal_id = g_signal_new("play",
                                        G_TYPE_FROM_CLASS(klass),
                                        G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
                                        (guint)G_STRUCT_OFFSET(BtSongClass,play_event),
{'fraction_non_alphanumeric': 0.12436633997972288, 'fraction_numerical': 0.000901205362171905, 'mean_word_length': 3.286817962337035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '55149', 'n_tokens_mistral': 3271, 'n_tokens_neox': 3210, 'n_words': 461}