core/tags/genre: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
6c3d708576
commit
2755e8a09b
|
@ -1,9 +1,7 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/string.h>
|
||||
}
|
||||
#include <core/tags/genre.h>
|
||||
|
||||
|
||||
|
@ -11,7 +9,7 @@ static struct database genre_db;
|
|||
|
||||
static struct genre *__genre_alloc(gchar *name)
|
||||
{
|
||||
struct genre *genre = new struct genre;
|
||||
struct genre *genre = g_malloc(sizeof(struct genre));
|
||||
|
||||
dbe_init(&genre->ge_dbe, genre);
|
||||
genre->ge_name = name;
|
||||
|
@ -28,7 +26,7 @@ static struct db_entry *genre_alloc(const gchar *name)
|
|||
static void genre_free(struct db_entry *dbe)
|
||||
{
|
||||
g_free(GENRE(dbe)->ge_lower);
|
||||
delete GENRE(dbe);
|
||||
g_free(GENRE(dbe));
|
||||
}
|
||||
|
||||
static gchar *genre_key(struct db_entry *dbe)
|
|
@ -4,8 +4,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>
|
||||
#include <core/tags/track.h>
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*
|
||||
* The Genre tag is used to store the name of genres
|
||||
* added to the tag database.
|
||||
*
|
||||
* When writing a Genre tag to disk, nol ywrite out the
|
||||
* genre_name field:
|
||||
*
|
||||
* ... Video Game Music
|
||||
* ... Game Music
|
||||
*/
|
||||
#ifndef OCARINA_CORE_TAGS_GENRE_H
|
||||
#define OCARINA_CORE_TAGS_GENRE_H
|
||||
|
||||
extern "C" {
|
||||
#include <core/database.h>
|
||||
}
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* The Genre tag is used to store the name of genres added
|
||||
* to the tag database.
|
||||
*/
|
||||
struct genre {
|
||||
gchar *ge_name; /* This genre's name. */
|
||||
gchar *ge_lower; /* This genre's name (lowercased). */
|
||||
|
|
|
@ -9,8 +9,8 @@ extern "C" {
|
|||
#include <core/date.h>
|
||||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
}
|
||||
#include <core/tags/genre.h>
|
||||
}
|
||||
#include <core/tags/library.h>
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ def TagTest(name, source):
|
|||
|
||||
res = [ TagTest("album", "album.c") ]
|
||||
res += [ TagTest("artist", "artist.c") ]
|
||||
res += [ TagTest("genre", "genre.cpp") ]
|
||||
res += [ TagTest("genre", "genre.c") ]
|
||||
res += [ TagTest("library", "library.cpp") ]
|
||||
|
||||
env.UsePackage("taglib_c")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tags/genre.h>
|
||||
#include "../test.h"
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_verify_empty(struct genre *genre)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ static void test_genre()
|
|||
const struct db_ops *genre_ops = test_genre_ops();
|
||||
struct genre *genre;
|
||||
unsigned int i;
|
||||
file f;
|
||||
struct file f;
|
||||
|
||||
genre = GENRE(genre_ops->dbe_alloc("Video Game Music"));
|
||||
test_verify_vg(genre);
|
||||
|
@ -82,9 +82,9 @@ static void test_genere_db()
|
|||
|
||||
test_verify_vg(genre);
|
||||
|
||||
test_equal(genre_find("Video Game Music"), genre);
|
||||
test_equal(genre_get(0), genre);
|
||||
test_equal(genre_get(1), (struct genre *)NULL);
|
||||
test_equal((void *)genre_find("Video Game Music"), (void *)genre);
|
||||
test_equal((void *)genre_get(0), (void *)genre);
|
||||
test_equal((void *)genre_get(1), (void *)NULL);
|
||||
|
||||
db_init(&genre_db, "genre.db", false, genre_ops);
|
||||
db_load(&genre_db);
|
Loading…
Reference in New Issue