mirror of
https://github.com/shadergz/cosmic-station.git
synced 2025-02-17 03:57:28 +00:00
Establishing a bridge between app preferences and native code
This commit is contained in:
parent
1b3a7252c2
commit
67070375e1
@ -38,13 +38,21 @@ set(ADDONS_DIR ${CMAKE_SOURCE_DIR}/cpp/addons)
|
||||
set(ZENITH_MISC_DIR ${CMAKE_SOURCE_DIR}/cpp)
|
||||
|
||||
target_include_directories(zenith PRIVATE ${ZENITH_MISC_DIR} ${ZENITH_DIR})
|
||||
|
||||
target_sources(zenith PRIVATE
|
||||
${ZENITH_DIR}/app.cpp
|
||||
${ZENITH_DIR}/readable_log.cpp
|
||||
${ZENITH_DIR}/paper_log.cpp
|
||||
|
||||
${ZENITH_DIR}/eeiv/ee_engine.cpp
|
||||
|
||||
${ZENITH_DIR}/os/mach_state.cpp
|
||||
${ZENITH_DIR}/os/host_memory.cpp
|
||||
|
||||
${ZENITH_DIR}/java/device_res.cpp
|
||||
|
||||
${ZENITH_MISC_DIR}/driver_chk.cpp
|
||||
${ZENITH_MISC_DIR}/jvm.cpp)
|
||||
|
||||
target_sources(addons PRIVATE
|
||||
${ADDONS_DIR}/compile_this.cpp)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <readable_log.h>
|
||||
#include <paper_log.h>
|
||||
|
||||
namespace zenith {
|
||||
class CoreApplication {
|
||||
|
@ -1,15 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <paper_assert.h>
|
||||
namespace zenith {
|
||||
|
||||
struct ZenFile {
|
||||
static constexpr auto invalidFileDescriptor{-1};
|
||||
using FileStat = struct stat;
|
||||
public:
|
||||
[[maybe_unused]] FileStat lastStates;
|
||||
ZenFile() :
|
||||
basicFd(-1) {}
|
||||
|
||||
~ZenFile() {
|
||||
if (basicFd != invalidFileDescriptor)
|
||||
close(basicFd);
|
||||
}
|
||||
FileStat lastStates;
|
||||
int basicFd;
|
||||
|
||||
void operator=(int fileNativeFd) {
|
||||
if (fileNativeFd == invalidFileDescriptor) {
|
||||
std::runtime_error("");
|
||||
}
|
||||
basicFd = fileNativeFd;
|
||||
fstat(basicFd, &lastStates);
|
||||
|
||||
PaperRtAssertPersistent(lastStates.st_mode & S_IFMT, S_IFREG, "");
|
||||
}
|
||||
auto operator*()-> int {
|
||||
return basicFd;
|
||||
}
|
||||
|
3
app/src/main/cpp/zenith/eeiv/ee_engine.cpp
Normal file
3
app/src/main/cpp/zenith/eeiv/ee_engine.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include <eeiv/ee_engine.h>
|
||||
|
||||
|
9
app/src/main/cpp/zenith/eeiv/ee_engine.h
Normal file
9
app/src/main/cpp/zenith/eeiv/ee_engine.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace eeiv {
|
||||
class [[maybe_unused]] EECoreCpu {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
16
app/src/main/cpp/zenith/java/wr_classes.h
Normal file
16
app/src/main/cpp/zenith/java/wr_classes.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace zenith::java {
|
||||
|
||||
using JNIEnumerator = uint;
|
||||
|
||||
class JNIString {
|
||||
public:
|
||||
JNIString() : managedStr() {}
|
||||
|
||||
std::string managedStr;
|
||||
};
|
||||
|
||||
}
|
2
app/src/main/cpp/zenith/os/host_memory.cpp
Normal file
2
app/src/main/cpp/zenith/os/host_memory.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include <os/osmem.h>
|
||||
|
@ -1,7 +1,12 @@
|
||||
#include <os/mach_state.h>
|
||||
|
||||
namespace zenith::os {
|
||||
void OSMachState::syncSettings() {
|
||||
std::array<const std::string, 1> statesIds{
|
||||
std::string("externalDirectory"),
|
||||
};
|
||||
|
||||
void OSMachState::syncSettings() {
|
||||
externalDirectory.fetchValue();
|
||||
cpuExecutor.fetchValue();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <java/wr_classes.h>
|
||||
|
||||
namespace zenith::os {
|
||||
class OSMachState {
|
||||
public:
|
||||
OSMachState() = default;
|
||||
void syncSettings();
|
||||
enum StateId {
|
||||
extDirectory,
|
||||
coreTechnique
|
||||
|
||||
};
|
||||
extern std::array<const std::string, 1> statesIds;
|
||||
|
||||
template <typename T>
|
||||
struct OSVariable{
|
||||
public:
|
||||
[[maybe_unused]] OSVariable<T>(std::string stateName) :
|
||||
deviceVar(),
|
||||
name(stateName) {}
|
||||
void operator=(const T&& variable) {
|
||||
deviceVar = variable;
|
||||
}
|
||||
[[maybe_unused]] void fetchValue() {
|
||||
}
|
||||
[[maybe_unused]] T deviceVar;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class OSMachState {
|
||||
public:
|
||||
OSMachState() :
|
||||
externalDirectory(statesIds[StateId::extDirectory]),
|
||||
cpuExecutor(statesIds[StateId::coreTechnique]) {}
|
||||
void syncSettings();
|
||||
// Directory with write permissions selected by the user
|
||||
OSVariable<java::JNIString> externalDirectory;
|
||||
OSVariable<java::JNIEnumerator> cpuExecutor;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
3
app/src/main/cpp/zenith/os/osmem.h
Normal file
3
app/src/main/cpp/zenith/os/osmem.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
|
7
app/src/main/cpp/zenith/paper_assert.h
Normal file
7
app/src/main/cpp/zenith/paper_assert.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#define PaperRtAssertPersistent(leftOp, rightOp, assertMessage)\
|
||||
[[unlikely]] if ((leftOp) != (rightOp))\
|
||||
assert((leftOp) == (rightOp))
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include <readable_log.h>
|
||||
#include <paper_log.h>
|
||||
|
||||
namespace zenith {
|
||||
[[maybe_unused]] std::shared_ptr<PalePaper> userLog;
|
Loading…
x
Reference in New Issue
Block a user