Skip to content

Commit a85e03c

Browse files
authored
Merge pull request #341 from libretro/dev
v0.29.1
2 parents 14e0a09 + 47a48a3 commit a85e03c

19 files changed

+100
-96
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
/package.json
88
/.bsv
99
/*.mkv
10+
*.d

.gitmodules

-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
url = https://github.com/ChaiScript/ChaiScript.git
1414
ignore = dirty
1515
branch = develop
16-
[submodule "vendor/filesystem"]
17-
path = vendor/filesystem
18-
url = https://github.com/wjakob/filesystem.git
19-
ignore = dirty
20-
branch = master
2116
[submodule "vendor/SDL_tty"]
2217
path = vendor/SDL_tty
2318
url = https://github.com/Grumbel/SDL_tty.git

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 0.29.1 - 2018-11-05
8+
### Chores
9+
- Moved String Methods to [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras)
10+
- Replaced use of `filesystem/path.h` with internal functions
11+
- Updated ChaiScript/ChaiScript_Extras
12+
- Updated libretro/libretro-common
13+
- Updated effolkronium/random
14+
715
## 0.29.0 - 2018-10-13
816
### Fixes
917
- Fixed `/libretro/saves` mounting

Makefile.common

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ SOURCES_C := $(CORE_DIR)/vendor/semver/semver.c
1717
# random
1818
FLAGS += -I$(CORE_DIR)/vendor/random/include
1919

20-
# filesystem
21-
FLAGS += -I$(CORE_DIR)/vendor/filesystem
22-
2320
# libretro-common
2421
FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include
2522
# Only compile libretro-common when not STATIC_LINKING
@@ -49,7 +46,7 @@ ifneq ($(STATIC_LINKING), 1)
4946
)
5047
# Ensure the sinc_resampler_neon is available for ARM NEON devices.
5148
OBJECTS += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.o
52-
49+
5350
# MD5
5451
FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include
5552
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/utils/md5.c
@@ -190,6 +187,7 @@ ifeq ($(HAVE_CHAISCRIPT),)
190187
FLAGS += -I$(CORE_DIR)/vendor/ChaiScript_Extras/include
191188
FLAGS += -D__HAVE_CHAISCRIPT__
192189
FLAGS += -DCHAISCRIPT_NO_THREADS -DCHAISCRIPT_NO_THREADS_WARNING -DCHAISCRIPT_NO_DYNLOAD
190+
FLAGS += -DCHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
193191
endif
194192

195193
# SDL

Makefile.libretro

+16-12
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,23 @@ else ifeq ($(platform), switch)
277277

278278
# Nintendo Switch (libnx)
279279
else ifeq ($(platform), libnx)
280-
include $(DEVKITPRO)/libnx/switch_rules
281-
EXT=a
282-
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
283-
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL
284-
CFLAGS := $(DEFINES) -g \
285-
-O2 \
280+
export DEPSDIR := $(CURDIR)/
281+
include $(DEVKITPRO)/libnx/switch_rules
282+
EXT=a
283+
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
284+
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL
285+
CFLAGS := $(DEFINES) -g \
286+
-O2 \
286287
-fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
287-
CFLAGS += $(INCDIRS)
288-
CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX
289-
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
290-
CFLAGS += -std=gnu11
291-
PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft
292-
STATIC_LINKING = 1
288+
CFLAGS += $(INCDIRS)
289+
CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX
290+
# Replaced -fno-rtti -fno-exceptions with -fexceptions, using C++14
291+
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fexceptions -std=c++14
292+
CFLAGS += -std=gnu11
293+
PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft
294+
STATIC_LINKING = 1
295+
#PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1
296+
#PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_
293297

294298
# ARM
295299
else ifneq (,$(findstring armv,$(platform)))

docs/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
2323
# This could be handy for archiving the generated documentation or
2424
# if some version control system is used.
2525

26-
PROJECT_NUMBER = "0.29.0"
26+
PROJECT_NUMBER = "0.29.1"
2727

2828
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
2929
# base path where the generated documentation will be put.

src/ChaiLove.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
#define CHAILOVE_VERSION_MAJOR 0
5050
#define CHAILOVE_VERSION_MINOR 29
51-
#define CHAILOVE_VERSION_PATCH 0
52-
#define CHAILOVE_VERSION_STRING "0.29.0"
51+
#define CHAILOVE_VERSION_PATCH 1
52+
#define CHAILOVE_VERSION_STRING "0.29.1"
5353

5454
#include "SDL.h"
5555
#include "libretro.h"

src/love/Types/FileSystem/FileData.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <stdio.h>
66
#include <stdlib.h>
7-
#include "filesystem/path.h"
87

98
#include "../../../ChaiLove.h"
109

@@ -38,9 +37,8 @@ std::string FileData::getString() {
3837
}
3938

4039
std::string FileData::getExtension() {
41-
::filesystem::path p(m_filepath.c_str());
42-
std::string extension(p.extension());
43-
return extension;
40+
ChaiLove* app = ChaiLove::getInstance();
41+
return app->filesystem.getFileExtension(m_filepath);
4442
}
4543

4644
} // namespace FileSystem

src/love/audio.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "Types/Audio/SoundData.h"
44
#include "../ChaiLove.h"
55
#include "sound.h"
6-
#include "physfs.h"
76
#include "audio/conversion/float_to_s16.h"
87

98
using love::Types::Audio::SoundData;

src/love/filesystem.cpp

+34-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "physfs.h"
66
#include "filesystem.h"
77
#include "physfsrwops.h"
8-
#include "filesystem/path.h"
98
#include "../ChaiLove.h"
109
#include "Types/FileSystem/FileInfo.h"
1110

@@ -32,17 +31,15 @@ bool filesystem::init(const std::string& file, const void* data) {
3231
}
3332

3433
// Find the parent and extension of the given file.
35-
::filesystem::path p(file.c_str());
36-
std::string extension(p.extension());
34+
std::string extension(getFileExtension(file));
3735

3836
// Allow loading from an Archive.
3937
if (extension == "chaigame" || extension == "chailove" || extension == "zip") {
4038
return mount(file.c_str(), "/", false);
4139
}
4240

4341
// If we are just running the core, load the base path.
44-
::filesystem::path parent(p.parent_path());
45-
std::string parentPath(parent.str());
42+
std::string parentPath(getParentDirectory(file));
4643
if (parentPath.empty()) {
4744
return mount(".", "/", false);
4845
}
@@ -51,6 +48,36 @@ bool filesystem::init(const std::string& file, const void* data) {
5148
return mount(parentPath.c_str(), "/", false);
5249
}
5350

51+
std::string filesystem::getParentDirectory(const std::string& filepath) {
52+
size_t last = filepath.find_last_of("/\\");
53+
if (last != std::string::npos) {
54+
return filepath.substr(0, last);
55+
}
56+
return "";
57+
}
58+
59+
std::string filesystem::getFileExtension(const std::string& filepath) {
60+
size_t i = filepath.rfind('.', filepath.length());
61+
if (i != std::string::npos) {
62+
return filepath.substr(i + 1, filepath.length() - i);
63+
}
64+
return "";
65+
}
66+
67+
std::string filesystem::getBasename(const std::string& filepath) {
68+
char sep = '/';
69+
if (filepath.find('\\') != std::string::npos) {
70+
sep = '\\';
71+
}
72+
73+
size_t i = filepath.rfind(sep, filepath.length());
74+
if (i != std::string::npos) {
75+
return filepath.substr(i + 1, filepath.length() - i);
76+
}
77+
78+
return filepath;
79+
}
80+
5481
void filesystem::mountlibretro() {
5582
// Mount some of the libretro directories.
5683
const char *system_dir = NULL;
@@ -60,8 +87,8 @@ void filesystem::mountlibretro() {
6087

6188
if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_LIBRETRO_PATH, &core_dir) && core_dir) {
6289
// Make sure to get the directory of the core.
63-
::filesystem::path p(core_dir);
64-
mount(p.parent_path().str(), "/libretro/core", false);
90+
std::string parentPath(getParentDirectory(core_dir));
91+
mount(parentPath, "/libretro/core", false);
6592
}
6693
if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir) && system_dir) {
6794
mount(system_dir, "/libretro/system", false);

src/love/filesystem.h

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ class filesystem {
7878
*/
7979
int getSize(const std::string& file);
8080

81+
std::string getFileExtension(const std::string& filepath);
82+
std::string getBasename(const std::string& filepath);
83+
std::string getParentDirectory(const std::string& filepath);
84+
8185
/**
8286
* Removes a file or empty directory.
8387
*

src/love/script.cpp

+13-54
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "script.h"
22
#include "../ChaiLove.h"
3-
#include <filesystem/path.h>
43
#include <algorithm>
54

65
#ifdef __HAVE_CHAISCRIPT__
76
#include "chaiscript/extras/math.hpp"
7+
#include "chaiscript/extras/string_methods.hpp"
88
using namespace chaiscript;
99
#endif
1010

@@ -35,7 +35,7 @@ bool script::loadModule(const std::string& moduleName) {
3535
// See if we are to append .chai.
3636
filename = filename + ".chai";
3737
if (!app->filesystem.exists(filename)) {
38-
std::cout << "[ChaiLove] [script] Module " << moduleName << " not found." << std::endl;
38+
std::cout << "[ChaiLove] [script] Module " << filename << " not found." << std::endl;
3939
return false;
4040
}
4141
}
@@ -45,7 +45,7 @@ bool script::loadModule(const std::string& moduleName) {
4545

4646
// Make sure it was not empty.
4747
if (contents.empty()) {
48-
std::cout << "[ChaiLove] [script] Module " << moduleName << " was loaded, but empty." << std::endl;
48+
std::cout << "[ChaiLove] [script] Module " << filename << " was loaded, but empty." << std::endl;
4949
return false;
5050
}
5151

@@ -85,60 +85,16 @@ std::string script::evalString(const std::string& code, const std::string& filen
8585

8686
script::script(const std::string& file) {
8787
#ifdef __HAVE_CHAISCRIPT__
88+
ChaiLove* app = ChaiLove::getInstance();
8889

8990
// ChaiScript Standard Library Additions
9091
// This adds some basic type definitions to ChaiScript.
9192
chai.add(bootstrap::standard_library::vector_type<std::vector<int>>("VectorInt"));
9293
chai.add(bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
9394
chai.add(bootstrap::standard_library::map_type<std::map<std::string, bool>>("StringBoolMap"));
9495

95-
// Global Helpers
96-
// string::replace(std::string search, std::string replace)
97-
chai.add(fun([](const std::string& subject, const std::string& search, const std::string& replace) {
98-
std::string newSubject(subject);
99-
size_t pos = 0;
100-
while ((pos = newSubject.find(search, pos)) != std::string::npos) {
101-
newSubject.replace(pos, search.length(), replace);
102-
pos += replace.length();
103-
}
104-
return newSubject;
105-
}), "replace");
106-
107-
// string::replace(char search, char replace)
108-
chai.add(fun([](const std::string& subject, char search, char replace) {
109-
std::string newSubject(subject);
110-
std::replace(newSubject.begin(), newSubject.end(), search, replace);
111-
return newSubject;
112-
}), "replace");
113-
114-
// string::trim()
115-
chai.add(fun([](const std::string& subject) {
116-
std::string result(subject);
117-
std::string chars = "\t\n\v\f\r ";
118-
result.erase(0, result.find_first_not_of(chars));
119-
result.erase(0, result.find_last_not_of(chars));
120-
return result;
121-
}), "trim");
122-
123-
// string::split()
124-
chai.add(fun([](const std::string& subject, const std::string& token) {
125-
std::string str(subject);
126-
std::vector<std::string> result;
127-
while (str.size()) {
128-
int index = str.find(token);
129-
if (index != std::string::npos) {
130-
result.push_back(str.substr(0, index));
131-
str = str.substr(index + token.size());
132-
if (str.size() == 0) {
133-
result.push_back(str);
134-
}
135-
} else {
136-
result.push_back(str);
137-
str = "";
138-
}
139-
}
140-
return result;
141-
}), "split");
96+
auto stringmethods = chaiscript::extras::string_methods::bootstrap();
97+
chai.add(stringmethods);
14298

14399
// List
144100
auto listModule = std::make_shared<chaiscript::Module>();
@@ -355,6 +311,9 @@ script::script(const std::string& file) {
355311
chai.add(fun<std::vector<std::string>, filesystem, const std::string&, const std::string&>(&filesystem::lines), "lines");
356312
chai.add(fun(&filesystem::load), "load");
357313
chai.add(fun(&script::loadModuleRequire, this), "require");
314+
chai.add(fun(&filesystem::getFileExtension), "getFileExtension");
315+
chai.add(fun(&filesystem::getBasename), "getBasename");
316+
chai.add(fun(&filesystem::getParentDirectory), "getParentDirectory");
358317

359318
// System
360319
chai.add(fun(&system::getOS), "getOS");
@@ -432,18 +391,18 @@ script::script(const std::string& file) {
432391
// Load the desired main.chai file.
433392
if (file.empty()) {
434393
// When no content is provided, display a No Game demo.
435-
eval(ChaiLove::getInstance()->demo(), "demo.chai");
394+
eval(app->demo(), "demo.chai");
436395
mainLoaded = true;
437396
} else {
438397
// Load the main.chai file.
439-
::filesystem::path p(file.c_str());
440-
std::string extension(p.extension());
441398
loadModuleRequire("conf");
399+
400+
std::string extension(app->filesystem.getFileExtension(file));
442401
if (extension == "chailove" || extension == "chaigame") {
443402
mainLoaded = loadModuleRequire("main");
444403
} else {
445404
// Otherwise, load the actual file.
446-
std::string filename(p.filename());
405+
std::string filename(app->filesystem.getBasename(file));
447406
mainLoaded = loadModuleRequire(filename);
448407
}
449408
}

test/unittests/filesystem.chai

+12
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,15 @@ requiretestFileLoaded = false
102102
requireReturn = require("assets.requiretest")
103103
assert(requireReturn, " double call")
104104
assert_not(requiretestFileLoaded, " not loaded twice")
105+
106+
// getFileExtension()
107+
assert_equal(love.filesystem.getFileExtension("/opt/var/something.txt"), "txt", "love.filesystem.getFileExtension()")
108+
assert_equal(love.filesystem.getFileExtension("/opt/var/something.tar.gz"), "gz", "love.filesystem.getFileExtension()")
109+
110+
// getBasename
111+
assert_equal(love.filesystem.getBasename("/opt/var/something.txt"), "something.txt", "love.filesystem.getBasename()")
112+
assert_equal(love.filesystem.getBasename("something.txt"), "something.txt", "love.filesystem.getBasename()")
113+
114+
// getParentDirectory
115+
assert_equal(love.filesystem.getParentDirectory("/opt/var/something.txt"), "/opt/var", "love.filesystem.getParentDirectory()")
116+
assert_equal(love.filesystem.getParentDirectory("something.txt"), "", "love.filesystem.getParentDirectory()")

vendor/cppcodec

vendor/filesystem

-1
This file was deleted.

vendor/random

0 commit comments

Comments
 (0)