core/tags/artist: Convert file to C

This commit is contained in:
Anna Schumaker 2015-11-11 10:49:23 -05:00
parent c07d1e9024
commit 6d9c89392e
6 changed files with 23 additions and 23 deletions

View File

@ -1,9 +1,7 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/string.h>
}
#include <core/tags/artist.h>
@ -11,7 +9,7 @@ static struct database artist_db;
static struct artist *__artist_alloc(gchar *name)
{
struct artist *artist = new struct artist;
struct artist *artist = g_malloc(sizeof(struct artist));
dbe_init(&artist->ar_dbe, artist);
artist->ar_name = name;
@ -21,7 +19,7 @@ static struct artist *__artist_alloc(gchar *name)
}
static db_entry *artist_alloc(const gchar *name)
static struct db_entry *artist_alloc(const gchar *name)
{
return &__artist_alloc(g_strdup(name))->ar_dbe;
}
@ -29,7 +27,7 @@ static db_entry *artist_alloc(const gchar *name)
static void artist_free(struct db_entry *dbe)
{
g_free(ARTIST(dbe)->ar_lower);
delete ARTIST(dbe);
g_free(ARTIST(dbe));
}
static gchar *artist_key(struct db_entry *dbe)

View File

@ -3,8 +3,8 @@
*/
extern "C" {
#include <core/tags/album.h>
}
#include <core/tags/artist.h>
}
#include <core/tags/genre.h>
#include <core/tags/library.h>
#include <core/tags/tags.h>

View File

@ -1,18 +1,20 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*
* The Artist tag is used to store the name of artists
* added to the tag database.
*
* When writing an Artist tag to disk, only write out the
* artist_name field:
*
* ... Koji Kondo
* ... Hajime Wakai
*/
#ifndef OCARINA_CORE_TAGS_ARTIST_H
#define OCARINA_CORE_TAGS_ARTIST_H
extern "C" {
#include <core/database.h>
}
#include <string>
/**
* The Artist tag is used to store the name of artists added
* to the tag database.
*/
struct artist {
gchar *ar_name; /* This artist's name. */
gchar *ar_lower; /* This artist's name (lowercased). */

View File

@ -8,8 +8,8 @@ extern "C" {
#include <core/database.h>
#include <core/date.h>
#include <core/tags/album.h>
}
#include <core/tags/artist.h>
}
#include <core/tags/genre.h>
#include <core/tags/library.h>

View File

@ -12,7 +12,7 @@ def TagTest(name, source):
return run
res = [ TagTest("album", "album.c") ]
res += [ TagTest("artist", "artist.cpp") ]
res += [ TagTest("artist", "artist.c") ]
res += [ TagTest("genre", "genre.cpp") ]
res += [ TagTest("library", "library.cpp") ]

View File

@ -1,8 +1,8 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/tags/artist.h>
#include "../test.h"
#include <tests/test.h>
static void test_verify_empty(struct artist *artist)
{
@ -25,7 +25,7 @@ static void test_artist()
const struct db_ops *artist_ops = test_artist_ops();
struct artist *artist;
unsigned int i;
file f;
struct file f;
artist = ARTIST(artist_ops->dbe_alloc("Koji Kondo"));
test_verify_koji(artist);
@ -82,9 +82,9 @@ static void test_artist_db()
test_verify_koji(artist);
test_equal(artist_find("Koji Kondo"), artist);
test_equal(artist_get(0), artist);
test_equal(artist_get(1), (struct artist *)NULL);
test_equal((void *)artist_find("Koji Kondo"), (void *)artist);
test_equal((void *)artist_get(0), (void *)artist);
test_equal((void *)artist_get(1), (void *)NULL);
db_init(&artist_db, "artist.db", false, artist_ops);
db_load(&artist_db);