From 5309ea5931b6bbfdb8a7f77030254d261ac06134 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 11 Nov 2015 09:15:25 -0500 Subject: [PATCH] core/tags/album: Convert file to C Signed-off-by: Anna Schumaker --- core/tags/{album.cpp => album.c} | 8 +++----- core/tags/tags.cpp | 2 ++ include/core/tags/album.h | 26 +++++++++++--------------- include/core/tags/track.h | 2 +- tests/core/tags/Sconscript | 4 ++-- tests/core/tags/{album.cpp => album.c} | 12 ++++++------ 6 files changed, 25 insertions(+), 29 deletions(-) rename core/tags/{album.cpp => album.c} (96%) rename tests/core/tags/{album.cpp => album.c} (91%) diff --git a/core/tags/album.cpp b/core/tags/album.c similarity index 96% rename from core/tags/album.cpp rename to core/tags/album.c index 8bb70d03..79f9732c 100644 --- a/core/tags/album.cpp +++ b/core/tags/album.c @@ -1,9 +1,7 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. */ -extern "C" { #include -} #include @@ -16,7 +14,7 @@ static gchar *__album_key(const gchar *name, unsigned int year) static struct album *__album_alloc(gchar *name, unsigned int year) { - struct album *album = new struct album; + struct album *album = g_malloc(sizeof(struct album)); dbe_init(&album->al_dbe, album); album->al_year = year; @@ -41,7 +39,7 @@ static void album_free(struct db_entry *dbe) { g_free(ALBUM(dbe)->al_name); g_free(ALBUM(dbe)->al_lower); - delete ALBUM(dbe); + g_free(ALBUM(dbe)); } static gchar *album_key(struct db_entry *dbe) diff --git a/core/tags/tags.cpp b/core/tags/tags.cpp index c93874bf..3180d989 100644 --- a/core/tags/tags.cpp +++ b/core/tags/tags.cpp @@ -1,7 +1,9 @@ /** * Copyright 2014 (c) Anna Schumaker. */ +extern "C" { #include +} #include #include #include diff --git a/include/core/tags/album.h b/include/core/tags/album.h index c92177cf..cda74146 100644 --- a/include/core/tags/album.h +++ b/include/core/tags/album.h @@ -1,25 +1,21 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. + * + * The album tag is used to store the name and year of albums + * added to the tag database. + * + * When writing an album tag to disk, write out the album_year field + * followed by the album_name on the same line: + * + * ... 1998 Hyrule Symphony + * ... 2006 Twilight Princess + * ... 2011 Skyward Sword */ #ifndef OCARINA_CORE_TAGS_ALBUM_H #define OCARINA_CORE_TAGS_ALBUM_H -extern "C" { #include -} -#include -/** - * The Album tag is used to store the name and year of albums - * added to the tag database. - * - * When writing an Album tag to disk, write out the _year field and - * then call GenericTag to write anything else. - * - * ... << year1 << GenericTag::write() - * ... << year2 << GenericTag::write() - * ... << year3 << GenericTag::write() - */ struct album { unsigned int al_year; /* This album's year. */ gchar *al_name; /* This album's name. */ diff --git a/include/core/tags/track.h b/include/core/tags/track.h index 86b40bca..3c89ce42 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -7,9 +7,9 @@ extern "C" { #include #include +#include } #include -#include #include #include diff --git a/tests/core/tags/Sconscript b/tests/core/tags/Sconscript index ae3d39e2..5b7d370a 100644 --- a/tests/core/tags/Sconscript +++ b/tests/core/tags/Sconscript @@ -11,8 +11,8 @@ def TagTest(name, source): Alias("tests/core/tags", run) return run -res = [ TagTest("artist", "artist.cpp") ] -res += [ TagTest("album", "album.cpp") ] +res = [ TagTest("album", "album.c") ] +res += [ TagTest("artist", "artist.cpp") ] res += [ TagTest("genre", "genre.cpp") ] res += [ TagTest("library", "library.cpp") ] diff --git a/tests/core/tags/album.cpp b/tests/core/tags/album.c similarity index 91% rename from tests/core/tags/album.cpp rename to tests/core/tags/album.c index 488ae3cb..66f1cd18 100644 --- a/tests/core/tags/album.cpp +++ b/tests/core/tags/album.c @@ -1,8 +1,8 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. */ #include -#include "../test.h" +#include static void test_verify_empty(struct album *album) { @@ -26,7 +26,7 @@ static void test_album() { const struct db_ops *album_ops = test_album_ops(); struct album *album; - file f; + struct file f; album = ALBUM(album_ops->dbe_alloc("1998/Hyrule Symphony")); test_verify_hyrule(album); @@ -76,9 +76,9 @@ static void test_album_db() test_verify_hyrule(album); - test_equal(album_find("Hyrule Symphony", 1998), album); - test_equal(album_get(0), album); - test_equal(album_get(1), (struct album *)NULL); + test_equal((void *)album_find("Hyrule Symphony", 1998), (void *)album); + test_equal((void *)album_get(0), (void *)album); + test_equal((void *)album_get(1), (void *)NULL); db_init(&album_db, "album.db", false, album_ops); db_load(&album_db);