Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
$VCPKG_PATH="$PWD/../vcpkg/scripts/buildsystems/vcpkg.cmake"
echo $VCPKG_PATH

cmake .. -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_PATH" -DPKG_CONFIG_EXECUTABLE="$PWD/../vcpkg/packages/pkgconf_x64-windows/tools/pkgconf/pkgconf.exe"
cmake .. -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_PATH" -DPKG_CONFIG_EXECUTABLE="$PWD/../vcpkg/packages/pkgconf_x64-windows/tools/pkgconf/pkgconf.exe" -DCMAKE_SYSTEM_VERSION=10.0.22621.0

# Step 5: Build the project with MSBuild
- name: Build with MSBuild
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.9.0 (2025-??-??)
- Added canvases
- Abstracted some of the window logic
- Improved components
- Added basic canvas methods
- Bug fixes

# v1.8.0 (2025-05-24)
- Added containers
- Added images
Expand Down
14 changes: 2 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ project("cinnamontoast")
set(CMAKE_GENERATOR_PLATFORM "x64")

enable_testing()
set(OPENSSL_USE_STATIC_LIBS TRUE)
file(GLOB_RECURSE REFLECT_CORE "src/core/*.cpp" "src/core/*.h")
file(GLOB_RECURSE REFLECT_NET "src/net/*.cpp" "src/net/*.h" )
file(GLOB_RECURSE REFLECT_CRASHHANDLER "src/crash/*.cpp" "src/crash/*.h")
file(GLOB_RECURSE REFLECT_CLI
"src/cli/*.cpp" "src/cli/*.h" "src/windows/reflecti.rc"
Expand Down Expand Up @@ -74,7 +72,7 @@ if(DEFINED REFLECT_BUNDLE)
${REFLECT_CRASHHANDLER}
${REFLECT_LUA}
${REFLECT_JAVA}
${REFLECT_NET} ${REFLECT_CORE} ${REFLECT_COMMONS_CORE}
${REFLECT_CORE} ${REFLECT_COMMONS_CORE}
)
target_compile_definitions(Reflect PRIVATE REFLECT_SHARED_LIBRARY=1)
target_compile_definitions(Reflect PRIVATE REFLECT_LUA=1)
Expand All @@ -92,7 +90,7 @@ else()
${REFLECT_CRASHHANDLER}
${REFLECT_LUA}
${REFLECT_JAVA}
${REFLECT_NET} ${REFLECT_CORE} ${REFLECT_COMMONS_CORE}
${REFLECT_CORE} ${REFLECT_COMMONS_CORE}
)
target_compile_definitions(Reflect PRIVATE REFLECT_STATIC_LIBRARY=1)
target_compile_definitions(Reflect PRIVATE REFLECT_LUA=1)
Expand All @@ -105,14 +103,12 @@ else()
add_library(Reflect.CrashHandler SHARED ${REFLECT_CRASHHANDLER} "src/windows/Reflect.CrashHandler.rc")
add_library(Reflect.LuaAPI SHARED ${REFLECT_LUA} "src/windows/Reflect.LuaAPI.rc")
add_library(Reflect.JavaAPI SHARED ${REFLECT_JAVA} "src/windows/Reflect.JavaAPI.rc")
add_library(Reflect.Networking SHARED ${REFLECT_NET})
add_library(Reflect.Core SHARED ${REFLECT_CORE} ${REFLECT_COMMONS_CORE} "src/windows/Reflect.Core.rc")
add_library(reflect::Core ALIAS Reflect.Core)
add_library(reflect::CrashHandler ALIAS Reflect.CrashHandler)
add_library(reflect::LuaAPI ALIAS Reflect.LuaAPI)
add_library(reflect::JavaAPI ALIAS Reflect.JavaAPI)
add_library(reflect::CStyleAPI ALIAS Reflect.CStyleAPI)
add_library(reflect::Networking ALIAS Reflect.Networking)
target_compile_definitions(Reflect.Core PRIVATE REFLECT_SHARED_LIBRARY=1)
target_compile_definitions(Reflect.Core PRIVATE REFLECT_EXT_NETWORKING=1)
target_compile_definitions(Reflect.CrashHandler PRIVATE REFLECT_SHARED_LIBRARY=1)
Expand Down Expand Up @@ -200,7 +196,6 @@ else()
target_link_libraries(Reflect.Core PRIVATE tinyxml2::tinyxml2)
target_link_libraries(Reflect.Core PRIVATE ${LUAJIT_LIBRARIES})
target_link_libraries(Reflect.Core PRIVATE Reflect.LuaAPI GLEW::glew)
target_link_libraries(Reflect.Networking PRIVATE OpenSSL::SSL ws2_32)
endif()
# do not let main() of program conflict with main() of gtest
target_compile_definitions(reflectt PRIVATE REFLECT_TESTS=1)
Expand Down Expand Up @@ -229,7 +224,6 @@ else()
target_include_directories(Reflect.CStyleAPI PRIVATE "${CMAKE_SOURCE_DIR}/src/common")
target_include_directories(Reflect.CStyleAPI PRIVATE "${CMAKE_SOURCE_DIR}/src/")

target_include_directories(Reflect.Networking PRIVATE "${CMAKE_SOURCE_DIR}/src/common" )

endif()
target_include_directories(reflecti PRIVATE "${CMAKE_SOURCE_DIR}/src/common")
Expand All @@ -243,7 +237,6 @@ if(DEFINED REFLECT_BUNDLE)
else()
target_link_libraries(reflecti PRIVATE Reflect.Core)
target_link_libraries(reflectt PRIVATE Reflect.Core)
target_link_libraries(reflectt PRIVATE Reflect.Networking)
target_link_libraries(reflectt PRIVATE Reflect.CrashHandler)
endif()

Expand All @@ -269,7 +262,6 @@ if (REFLECT_UNIX_NAMES EQUAL 0 OR UNIX)
set_target_properties(Reflect PROPERTIES OUTPUT_NAME "reflect")
else()
set_target_properties(Reflect.Core PROPERTIES OUTPUT_NAME "reflect_core")
set_target_properties(Reflect.Networking PROPERTIES OUTPUT_NAME "reflect_networking")
set_target_properties(Reflect.CrashHandler PROPERTIES OUTPUT_NAME "eflect_crash")
set_target_properties(Reflect.CStyleAPI PROPERTIES OUTPUT_NAME "reflect_cstyle")
set_target_properties(Reflect.LuaAPI PROPERTIES OUTPUT_NAME "reflect_lua")
Expand All @@ -282,7 +274,6 @@ elseif (REFLECT_DOTNET_NAMES)
set_target_properties(Reflect PROPERTIES OUTPUT_NAME "Reflect")
else()
set_target_properties(Reflect.Core PROPERTIES OUTPUT_NAME "Reflect.Core")
set_target_properties(Reflect.Networking PROPERTIES OUTPUT_NAME "Reflect.Networking")
set_target_properties(Reflect.CrashHandler PROPERTIES OUTPUT_NAME "Reflect.CrashHandler")
set_target_properties(Reflect.CStyleAPI PROPERTIES OUTPUT_NAME "Reflect.CStyleAPI")
set_target_properties(Reflect.LuaAPI PROPERTIES OUTPUT_NAME "Reflect.LuaAPI")
Expand All @@ -296,7 +287,6 @@ else()
set_target_properties(Reflect PROPERTIES OUTPUT_NAME "reflect")
else()
set_target_properties(Reflect.Core PROPERTIES OUTPUT_NAME "reflectcore")
set_target_properties(Reflect.Networking PROPERTIES OUTPUT_NAME "reflectnet")
set_target_properties(Reflect.CrashHandler PROPERTIES OUTPUT_NAME "reflectcrash")
set_target_properties(Reflect.CStyleAPI PROPERTIES OUTPUT_NAME "reflectcstyle")
set_target_properties(Reflect.LuaAPI PROPERTIES OUTPUT_NAME "reflectlua")
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,28 @@ or you can directly use C++ (faster, but more complicated):
#include <string>
#include <iostream>
#include <windows.h>
extern "C" __declspec(dllexport) void ReflectMain(reflect::ReflectAPI* api) {
extern "C" __declspec(dllexport) void reflectMain(reflect::ReflectAPI* api) {
std::cout << "Loaded!" << std::endl;
reflect::ComponentId id = api->GetComponentById("label1");
const char* string = api->GetComponentText(id);
reflect::ComponentId id = api->getComponentById("label1");
const char* string = api->getComponentText(id);
std::cout << string << std::endl;
};
```

## Building
To build Reflect, you need CMake and a C++ compiler (like MSVC, or g++). Then simply do these steps:
To build Reflect, you need CMake, vcpkg and a C++ compiler (like MSVC, or g++). Then simply do these steps:
### If using Visual Studio IDE
1. Open the project in Visual Studio
2. Select the configuration (Debug or Release)
3. Select reflecti.exe as the target
4. Finally, build the project (as it will be automatically be built)
4. Setup vcpkg (steps below)
5. Finally, build the project (as it will be automatically be built)

### If using plain CMake and VS Build Tools
1. Open a terminal
2. Navigate to the project directory
3. Run `python3 DownloadLibraries.py` to download the libraries source (like tinyxml2)
4. If you're using MSBuild, run
4. Setup vcpkg (steps below)
5. If you're using MSBuild, run
```cmd
cmake -G "Visual Studio xx xxxx" -A x64
```
Expand All @@ -74,15 +75,14 @@ cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/cmake -DTRIPLET=x64-window
```cmd
cmake --build . --config Release
```
### If building on Linux
1. Open a terminal
2. Install CMake and g++ if you haven't already: `sudo apt install cmake g++ ninja-build`
3. Navigate to the project directory
5. Run `cmake . -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg.cmake> -DTRIPLET=x64-linux`
6. Run `ninja`

This will build the project and create the launcher (reflecti) as well as the shared libraries (Reflect.Core, etc.) that you can link with your projects.

### To setup vcpkg
1. Clone vcpkg via `git clone https://github.com/microsoft/vcpkg`
2. Go to the directory where vcpkg is cloned
3. Run bootstrap-vcpkg
4. Now simply integrate it with CMake
## Security and sandboxing
For native code, there isn't any sandboxing, so beware of malicious programs.

Expand Down
8 changes: 0 additions & 8 deletions TODO.md

This file was deleted.

30 changes: 13 additions & 17 deletions src/api/java/ReflectJava.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@
JNIEXPORT jint JNICALL JavaFunction(ReflectNative,
getReferenceById)(JNI_PARAM_DECL,
jstring id) {
// Convert jstring to const char*
// get the literal string in x64 assembly
const char *nativeId = (*env)->GetStringUTFChars(env, id, 0);

// Get the component reference using the nativeId
// produce a segfault on an embedded device
ReflectComponent ref = Reflect_getComponentById(nativeId);

// Release the jstring memory
// reinstall os
(*env)->ReleaseStringUTFChars(env, id, nativeId);

// Return the component id as jint
// align with the heap (no stack)
return (jint)ref.id;
}

JNIEXPORT jstring JNICALL JavaFunction(ReflectNative, getText)(JNI_PARAM_DECL,
jint ref) {
// two values, thats it
ReflectComponent comp;
comp.id = (uint8_t)ref;
return (*env)->NewStringUTF(env, Reflect_getText(comp));
Expand Down Expand Up @@ -67,27 +68,22 @@ JNIEXPORT void JNICALL Java_reflect4j_ReflectNative_invoke(JNIEnv *env,

const char *utfChars = (*env)->GetStringUTFChars(env, location, NULL);
if (utfChars == NULL)
return; // Could not get string
return; // string bye bye

// Call your real native function here with the C string
// native
Reflect_invoke(utfChars);

// Don't forget to release memory!
// MEMORY LEAK
(*env)->ReleaseStringUTFChars(env, location, utfChars);
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
// MessageBox(NULL, "attach now", "debug", MB_OK);
HMODULE hModule = NULL;

// Get handle to the current module (i.e., the DLL)
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCSTR)&JNI_OnLoad, // any symbol in this DLL
&hModule)) {
// Manually increase the refcount
wchar_t dllPath[MAX_PATH];
if (GetModuleFileNameW(hModule, dllPath, MAX_PATH)) {
LoadLibraryW(dllPath); // increments refcount, keeps DLL loaded
}
// JVM loads "reflect.dll" via System.loadLibrary("reflect")
HMODULE h = GetModuleHandleA("reflect.dll");
if (h) {
LoadLibraryA("reflect.dll"); // bumps refcount on the exact instance
}

return JNI_VERSION_1_8;
Expand Down
13 changes: 9 additions & 4 deletions src/common/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@
/**
* @brief External application name to be shown to the end user.
*/
#define APP_NAME "Project Reflect"
#define APP_NAME "Reflect"

/**
* @brief Internal application version for compatibility checks.
*/
#define APP_INTERNAL_VERSION 0x0000000BL
#define APP_INTERNAL_VERSION 0x0000000CL

/**
* @brief External application version to be shown to the end user.
*/
#define APP_VERSION "1.8.0"
#define APP_VERSION "1.9.0"

#define REFLECT_VERSION_MAJOR 1
#define REFLECT_VERSION_MINOR 9
#define REFLECT_VERSION_PATCH 0

/**
* @brief Error codes used in the Reflect framework.
Expand Down Expand Up @@ -81,4 +85,5 @@
#define REFLECT_OBJECT_NOTIFICATION 9
#define REFLECT_OBJECT_PROGRESSBAR 10
#define REFLECT_OBJECT_IMAGE 11
#define REFLECT_OBJECT_CONTAINER 12
#define REFLECT_OBJECT_CONTAINER 12
#define REFLECT_OBJECT_CANVAS 13
2 changes: 0 additions & 2 deletions src/common/TypeDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ typedef XID XWindow;

#endif

#define LIBC_NAMESPACE reflect

/**
* @brief Namespace for the Reflect framework.
*/
Expand Down
Loading