Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign Engine and APIs for C++17 #14

Open
20 of 30 tasks
mogemimi opened this issue Jan 25, 2018 · 4 comments
Open
20 of 30 tasks

Redesign Engine and APIs for C++17 #14

mogemimi opened this issue Jan 25, 2018 · 4 comments

Comments

@mogemimi
Copy link
Owner

mogemimi commented Jan 25, 2018

Hello, mates!
I have the following plans for Pomdog in 2018:

Plans

  • To migrate C++14 -> C++17, I will remove support for such old compilers and IDEs:
    • Visual Studio < 2017
    • Xcode < 9.2
    • LLVM Clang < 5.0
  • Migrating a new build system from GYP
  • Removing all tools written by Python 2.x from our toolchains
  • Using Catch2 as a test framework
  • Update the version of clang-format and .clang-format
  • Upgrading third-party libraries, docker containers and CI settings.

New API Style

  • Use C++17, not C++14
  • Replacing Pomdog::Optional<T>, Pomdog::Any and Pomdog::PathHelper with the C++17 standard libraries.
  • Do not use Exceptions in favor of the std::tuple, std::tie and std::optional for error handling.
  • More documentations and examples.

Done/TODOs

@mogemimi mogemimi changed the title Redesign Engines and APIs for C++17 Redesign Engine and APIs for C++17 Jan 25, 2018
@barsoosayque
Copy link
Contributor

I noticed that Pomdog::FileSystem has system-depend implementation, and since there is std::filesystem, this part can also be refactored in favor of c++17 std:

  • Pomdog::FS::CreateDirectory -> std::fs::create_directory
  • Pomdog::FS::CreateDirectories -> std::fs::create_directories
  • Pomdog::FS::Exist -> std::fs::exists
  • Pomdog::FS::IsDirectory -> std::fs::is_directory
  • Pomdog::FS::GetTempDirectoryPath -> std::fs::temp_directory_path
  • Pomdog::FS::GetCurrentWorkingDirectory -> std::fs::current_path

(note: FS is reduced form of FileSystem and fs is reduced form of filesystem)

Although, I'm not sure about other methods in there (GetLocalAppDataDirectoryPath, GetAppDataDirectoryPath and GetResourceDirectoryPath). Since I am using Linux, I am not aware of AppData directories in either Mac or Windows, so I can't guess there.

@mogemimi
Copy link
Owner Author

Hello @barsoosayque,

this part can also be refactored in favor of c++17 std

I agree with you. These APIs will be replaced with <file_system> and will be deprecated. 👍
Currently, Mac (Xcode 9) does not support <file_system> and <experimental/file_system> yet, so I'll upgrade the build requirements of Pomdog for the C++17 libraries when Xcode 10 stable will be released.

GetResourceDirectoryPath() represents a asset directory which includes the Content directory. When you build the application, the Content directory is copied into it from your source directory. It is usually the same as where the executable file is located.

GetLocalAppDataDirectoryPath() and GetAppDataDirectoryPath() are equal to /home/<Username>/.<application-name>/, like ~/.thunderbird or ~/.minecraft on Linux, but these are not been implemented yet, please see FileSystemLinux.cpp#L70-L80.

In addition, these are platform-specific APIs which is causing confusion, so I'd like to change them as follows:

// current version
std::string GetLocalAppDataDirectoryPath();
std::string GetAppDataDirectoryPath();

// next version (TBD)
std::optional<std::string> Win32::GetLocalAppDataDirectoryPath();
std::optional<std::string> Win32::GetAppDataDirectoryPath();
std::optional<std::string> Mac::GetApplicationSupportDirectoryPath();
std::optional<std::string> Linux::GetHomeDirectoryPath();
std::string GetContentDirectoryPath();
std::string GetPersistentDataDirectoryPath();

@barsoosayque
Copy link
Contributor

... are equal to /home/<Username>/.<application-name>/, like ~/.thunderbird or ~/.minecraft on Linux.

It is now desirable to store game data (or any other program specific data, but not the configs) in $HOME/.local/share/<application-name>/ according to the XDG Specification.

Regarding next filesystem API, I guess it will be more convenient to return std::filesystem::path and then do path.c_str() or path.string().

@mogemimi
Copy link
Owner Author

... $HOME/.local/share// according to the XDG Specification.

Thank you for the link. That seems like the right path! I'll read the spec and try it.

it will be more convenient to return std::filesystem::path

I totally agree with this direction. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants