Just refactored tools to C++

This commit is contained in:
2023-02-06 22:16:47 -08:00
parent dda126d338
commit c70c4fe6c4
29 changed files with 779 additions and 767 deletions

View File

@ -3,6 +3,9 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Include shared libs
add_subdirectory(dawnshared)
# Include tools
add_subdirectory(dawntools)

View File

@ -13,6 +13,7 @@ target_link_libraries(${DAWN_TARGET_NAME}
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -6,36 +6,9 @@
*/
#pragma once
#include "dawnsharedlibs.hpp"
// Static Libs
extern "C" {
// Standard Libs
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <malloc.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
typedef bool bool_t;
typedef float float_t;
}
#include <vector>
#include <iostream>
#include <thread>
#include <map>
#include <array>
#include <stb_truetype.h>
#include <memory>
#include <algorithm>
#include <sstream>
// #include <iterator>
// #include <algorithm>
// #include <string>
// #include <sstream>
#include <glm/glm.hpp>
#include <glm/vec3.hpp>

View File

@ -0,0 +1,13 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Includes
set(
DAWN_SHARED_INCLUDES
${CMAKE_CURRENT_LIST_DIR}
CACHE INTERNAL
${DAWN_CACHE_TARGET}
)

View File

@ -0,0 +1,31 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
// Static Libs
extern "C" {
// Standard Libs
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <malloc.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
typedef bool bool_t;
typedef float float_t;
}
#include <vector>
#include <iostream>
#include <thread>
#include <map>
#include <array>
#include <memory>
#include <algorithm>
#include <sstream>

View File

@ -9,10 +9,11 @@ add_executable(audiogen)
target_sources(audiogen
PRIVATE
main.cpp
../../utils/file.c
../../utils/file.cpp
)
target_include_directories(audiogen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -3,10 +3,8 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
extern "C" {
#include "../../utils/common.h"
#include "../../utils/file.h"
}
#include "../../utils/common.hpp"
#include "../../utils/file.hpp"
#include "AudioFile.h"
int main(int argc, char *argv[]) {

View File

@ -9,11 +9,12 @@ add_executable(texturegen)
target_sources(texturegen
PRIVATE
main.cpp
../../utils/file.c
../../utils/image.c
../../utils/file.cpp
../../utils/image.cpp
)
target_include_directories(texturegen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -5,11 +5,9 @@
* https://opensource.org/licenses/MIT
*/
extern "C" {
#include "../../utils/common.h"
#include "../../utils/file.h"
#include "../../utils/image.h"
}
#include "../../utils/common.hpp"
#include "../../utils/file.hpp"
#include "../../utils/image.hpp"
int main(int argc, char *argv[]) {
FILE *file;

View File

@ -9,11 +9,12 @@ add_executable(tilesetgen)
target_sources(tilesetgen
PRIVATE
main.cpp
../../utils/file.c
../../utils/image.c
../../utils/file.cpp
../../utils/image.cpp
)
target_include_directories(tilesetgen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -5,11 +5,9 @@
* https://opensource.org/licenses/MIT
*/
extern "C" {
#include "../../utils/common.h"
#include "../../utils/file.h"
#include "../../utils/image.h"
}
#include "../../utils/common.hpp"
#include "../../utils/file.hpp"
#include "../../utils/image.hpp"
int main(int argc, char *argv[]) {
char *in;

View File

@ -9,11 +9,12 @@ add_executable(truetypegen)
target_sources(truetypegen
PRIVATE
main.cpp
../../utils/file.c
../../utils/image.c
../../utils/file.cpp
../../utils/image.cpp
)
target_include_directories(truetypegen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -5,15 +5,13 @@
* https://opensource.org/licenses/MIT
*/
extern "C" {
#include "../../utils/common.h"
#include "../../utils/file.h"
#include "../../utils/image.h"
#include "../../utils/common.hpp"
#include "../../utils/file.hpp"
#include "../../utils/image.hpp"
#ifndef STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#include <stb_truetype.h>
#endif
}
#define TRUETYPE_FIRST_CHAR 32
#define TRUETYPE_NUM_CHARS 96

View File

@ -9,11 +9,12 @@ add_executable(uigen)
target_sources(uigen
PRIVATE
main.cpp
../../utils/file.c
../../utils/xml.c
../../utils/file.cpp
../../utils/xml.cpp
)
target_include_directories(uigen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -5,11 +5,8 @@
* https://opensource.org/licenses/MIT
*/
extern "C" {
#include "../../utils/xml.h"
#include "../../utils/file.h"
#include <memory.h>
}
#include "../../utils/xml.hpp"
#include "../../utils/file.hpp"
#include <iostream>
#include <vector>

View File

@ -9,12 +9,13 @@ add_executable(languagegen)
target_sources(languagegen
PRIVATE
main.cpp
../../utils/file.c
../../utils/csv.c
../../utils/xml.c
../../utils/file.cpp
../../utils/csv.cpp
../../utils/xml.cpp
)
target_include_directories(languagegen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -5,14 +5,10 @@
* https://opensource.org/licenses/MIT
*/
extern "C" {
#include "../../utils/common.h"
#include "../../utils/file.h"
#include "../../utils/csv.h"
#include "../../utils/xml.h"
#include <memory.h>
}
#include "../../utils/common.hpp"
#include "../../utils/file.hpp"
#include "../../utils/csv.hpp"
#include "../../utils/xml.hpp"
#include <iostream>
#include <map>
#include <vector>

View File

@ -6,6 +6,8 @@
*/
#pragma once
#include "dawnsharedlibs.hpp"
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

View File

@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
*/
#include "csv.h"
#include "csv.hpp"
char * csvGetCell(csv_t *csv, int32_t row, int32_t cell) {
return csv->rows[(row * CSV_COLUMN_COUNT_MAX) + cell];
@ -18,9 +18,9 @@ void csvParse(char *string, csv_t *csv) {
int32_t rowCellCount;
length = strlen(string);
csv->buffer = malloc(sizeof(char) * (length+1) * CSV_COLUMN_COUNT_MAX * CSV_ROW_COUNT_MAX);
csv->cellCounts = malloc(sizeof(int32_t) * CSV_ROW_COUNT_MAX);
csv->rows = malloc(sizeof(char*) * CSV_ROW_COUNT_MAX * CSV_COLUMN_COUNT_MAX);
csv->buffer = (char *)malloc(sizeof(char) * (length+1) * CSV_COLUMN_COUNT_MAX * CSV_ROW_COUNT_MAX);
csv->cellCounts = (int32_t *)malloc(sizeof(int32_t) * CSV_ROW_COUNT_MAX);
csv->rows = (char**)malloc(sizeof(char*) * CSV_ROW_COUNT_MAX * CSV_COLUMN_COUNT_MAX);
i = 0;
j = 0;

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include "common.h"
#include "common.hpp"
#include "string.h"
#define CSV_ROW_COUNT_MAX 128

View File

@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
*/
#include "file.h"
#include "file.hpp"
void fileNormalizeSlashes(char *string) {
char c;

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include "common.h"
#include "common.hpp"
#define FILE_CHILD_TYPE_DIR 0x00
#define FILE_CHILD_TYPE_FILE 0x01

View File

@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
*/
#include "image.h"
#include "image.hpp"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION

View File

@ -6,8 +6,8 @@
*/
#pragma once
#include "common.h"
#include "file.h"
#include "common.hpp"
#include "file.hpp"
#include <stb_image.h>
#include <stb_image_resize.h>

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include "common.h"
#include "common.hpp"
static inline void stringRemoveAll(char *string, char remove) {
size_t len = strlen(string);

View File

@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
*/
#include "xml.h"
#include "xml.hpp"
int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
char c;
@ -13,13 +13,13 @@ int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
uint8_t doing = XML_DOING_NOTHING;
uint8_t doingBeforeComment;
bool insideTag = false;
char* buffer = malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
char* buffer = (char *)malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
int32_t bufferLength = 0;
xml->value = NULL;
xml->attributeCount = 0;
xml->children = malloc(sizeof(xml_t) * XML_CHILD_COUNT_MAX);
xml->children = (xml_t *)malloc(sizeof(xml_t) * XML_CHILD_COUNT_MAX);
xml->childrenCount = 0;
while(c = data[i++]) {
@ -54,7 +54,7 @@ int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
if(xmlIsWhitespace(c) || c == '>' || c == '/') {
buffer[bufferLength] = '\0';
xml->node = buffer;
buffer = malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
buffer = (char *)malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
bufferLength = 0;
if(c == '/') {
level--;
@ -88,7 +88,7 @@ int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
buffer[bufferLength] = '\0';
xml->attributeNames[xml->attributeCount++] = buffer;
xml->attributeDatas[xml->attributeCount] = NULL;
buffer = malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
buffer = (char *)malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
bufferLength = 0;
}
continue;
@ -116,7 +116,7 @@ int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
doing = XML_LOOKING_FOR_ATTRIBUTE;
buffer[bufferLength] = '\0';
xml->attributeDatas[xml->attributeCount - 1] = buffer;
buffer = malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
buffer = (char *)malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
bufferLength = 0;
continue;
}
@ -132,7 +132,7 @@ int32_t xmlLoadChild(xml_t *xml, char *data, int32_t i) {
buffer[bufferLength] = '\0';
bufferLength = 0;
xml->value = buffer;
buffer = malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
buffer = (char *)malloc(sizeof(char) * XML_TEXT_BUFFER_MAX);
continue;
}

View File

@ -6,8 +6,8 @@
*/
#pragma once
#include "common.h"
#include "file.h"
#include "common.hpp"
#include "file.hpp"
#define XML_DOING_NOTHING 0x00
#define XML_PARSING_TAG_NAME 0x01

View File

@ -9,11 +9,12 @@ add_executable(vnscenegen)
target_sources(vnscenegen
PRIVATE
main.cpp
../../utils/file.c
../../utils/xml.c
../../utils/file.cpp
../../utils/xml.cpp
)
target_include_directories(vnscenegen
PUBLIC
${DAWN_SHARED_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}/../../
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -3,11 +3,8 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
extern "C" {
#include "../../utils/file.h"
#include "../../utils/xml.h"
#include <memory.h>
}
#include "../../utils/file.hpp"
#include "../../utils/xml.hpp"
#include <iostream>
#include <vector>