<commit_before>#include <sqlite3.h>
#include <libsoup/soup.h>
#include "mojito-core.h"
#include "mojito-utils.h"
#include "generic.h"

#include "mojito-source-blog.h"

G_DEFINE_TYPE (MojitoCore, mojito_core, G_TYPE_OBJECT)

#define GET_PRIVATE(o) \
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOJITO_TYPE_CORE, MojitoCorePrivate))

struct _MojitoCorePrivate {
  GList *sources;
  sqlite3 *db;
  SoupSession *session;
};

static void
mojito_core_dispose (GObject *object)
{
  MojitoCorePrivate *priv = MOJITO_CORE (object)->priv;

  if (priv->session) {
    g_object_unref (priv->session);
    priv->session = NULL;
  }
  
  while (priv->sources) {
    g_object_unref (priv->sources->data);
    priv->sources = g_list_delete_link (priv->sources, priv->sources);
  }
  
  G_OBJECT_CLASS (mojito_core_parent_class)->dispose (object);
}

static void
mojito_core_finalize (GObject *object)
{
  MojitoCorePrivate *priv = MOJITO_CORE (object)->priv;

  sqlite3_close (priv->db);
  
  G_OBJECT_CLASS (mojito_core_parent_class)->finalize (object);
}

static void
mojito_core_class_init (MojitoCoreClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (MojitoCorePrivate));

  object_class->dispose = mojito_core_dispose;
  object_class->finalize = mojito_core_finalize;
}

static const char sql_get_sources[] = "SELECT rowid, type, url FROM sources;";

static void
populate_sources (MojitoCore *core)
{
  MojitoCorePrivate *priv = core->priv;
  MojitoSourceClass *source_class;

  source_class = g_type_class_ref (MOJITO_TYPE_SOURCE_BLOG);
  
  priv->sources = g_list_concat
    (priv->sources, mojito_source_initialize (source_class, core));
<commit_msg>Load sources from a list of GTypes<commit_after>#include <sqlite3.h>
#include <libsoup/soup.h>
#include "mojito-core.h"
#include "mojito-utils.h"
#include "generic.h"

#include "mojito-source-blog.h"

G_DEFINE_TYPE (MojitoCore, mojito_core, G_TYPE_OBJECT)

#define GET_PRIVATE(o) \
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOJITO_TYPE_CORE, MojitoCorePrivate))

struct _MojitoCorePrivate {
  GList *sources;
  sqlite3 *db;
  SoupSession *session;
};

static void
mojito_core_dispose (GObject *object)
{
  MojitoCorePrivate *priv = MOJITO_CORE (object)->priv;

  if (priv->session) {
    g_object_unref (priv->session);
    priv->session = NULL;
  }
  
  while (priv->sources) {
    g_object_unref (priv->sources->data);
    priv->sources = g_list_delete_link (priv->sources, priv->sources);
  }
  
  G_OBJECT_CLASS (mojito_core_parent_class)->dispose (object);
}

static void
mojito_core_finalize (GObject *object)
{
  MojitoCorePrivate *priv = MOJITO_CORE (object)->priv;

  sqlite3_close (priv->db);
  
  G_OBJECT_CLASS (mojito_core_parent_class)->finalize (object);
}

static void
mojito_core_class_init (MojitoCoreClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (MojitoCorePrivate));

  object_class->dispose = mojito_core_dispose;
  object_class->finalize = mojito_core_finalize;
}

static const char sql_get_sources[] = "SELECT rowid, type, url FROM sources;";

static void
populate_sources (MojitoCore *core)
{
  GType types[] = { MOJITO_TYPE_SOURCE_BLOG };
  MojitoCorePrivate *priv = core->priv;
  MojitoSourceClass *source_class;
  int i;
  
  for (i = 0; i < G_N_ELEMENTS (types); i++) {
    source_class = g_type_class_ref (types[i]);

    priv->sources = g_list_concat
      (priv->sources, mojito_source_initialize (source_class, core));    
  }
  
{'fraction_non_alphanumeric': 0.11893272778881635, 'fraction_numerical': 0.0019869429463525404, 'mean_word_length': 5.226148409893993, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2826630', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1351, 'n_words': 250}