From 6fe21673c2b9e27ccdbcc2ecd29ede9df85c1ba9 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 6 Sep 2026 13:46:29 +0200 Subject: [PATCH] refactor(api)!: drop the inert globals GlobalParams stored two paths nothing read. The renderer's css and js became part of the library and detection became our own, and both accessors were kept only so a caller that pointed us somewhere kept working. v7 is where that ends. Gone with it: the java, python and objc mirrors, OdrAndroid and its no-op init, ODRGlobalParams.bootstrapFromFrameworkBundle, and the ODR_WITH_LIBMAGIC / ODR_BUNDLE_ASSETS cmake options with the conan options that set them - the latter two did nothing but print a deprecation. The android instrumented test loses its init case and is renamed for what it still checks: that the AAR works with no setup at all. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_016hxDa2rev11eLUEJZJ5nmz --- CHANGELOG.md | 4 ++ CMakeLists.txt | 19 ------- android/AGENTS.md | 8 +-- android/README.md | 6 +-- .../{OdrAndroidTest.kt => AarContractTest.kt} | 11 +--- .../opendocument/core/android/OdrAndroid.kt | 23 --------- apple/CMakeLists.txt | 2 - apple/include/OdrCoreObjC/ODRGlobalParams.h | 35 ------------- apple/include/OdrCoreObjC/OdrCoreObjC.h | 1 - apple/src/ODRGlobalParams.mm | 51 ------------------- conanfile.py | 9 ---- docs/design/README.md | 18 ++----- jni/CMakeLists.txt | 1 - jni/README.md | 4 +- .../app/opendocument/core/GlobalParams.java | 27 ---------- jni/src/jni_core.cpp | 35 ------------- python/README.md | 11 ++-- python/src/bind_core.cpp | 14 ----- python/tests/test_meta.py | 4 -- src/odr/global_params.cpp | 31 ----------- src/odr/global_params.hpp | 32 ------------ test/public_headers_cpp20.cpp | 1 - 22 files changed, 19 insertions(+), 328 deletions(-) rename android/src/androidTest/java/app/opendocument/core/{OdrAndroidTest.kt => AarContractTest.kt} (76%) delete mode 100644 android/src/main/java/app/opendocument/core/android/OdrAndroid.kt delete mode 100644 apple/include/OdrCoreObjC/ODRGlobalParams.h delete mode 100644 apple/src/ODRGlobalParams.mm delete mode 100644 jni/java/app/opendocument/core/GlobalParams.java delete mode 100644 src/odr/global_params.cpp delete mode 100644 src/odr/global_params.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6a4d2de..81a9ba139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ The release run heads these entries with the version and opens a fresh ## Unreleased +- **Breaking**: `GlobalParams` is gone, with its java, python and objc mirrors, + `OdrAndroid.init`, and the `ODR_WITH_LIBMAGIC` / `ODR_BUNDLE_ASSETS` cmake + options. All of it was inert; delete the calls, nothing replaces them. + - **Breaking**: building `odr` from source now needs a **C++23** compiler. Using it does not — the public headers still compile as C++20, and the package forces no standard on a consumer. diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d9fb9759..13a519722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,12 +16,6 @@ option(ODR_TEST_FETCH_DATA "Fetch the test data pinned in test/data.cmake" OFF) option(ODR_CLI "enable command line interface" ON) option(ODR_WITH_HTTP_SERVER "Build the HTTP server (requires cpp-httplib)" ON) option(ODR_CLANG_TIDY "Run clang-tidy static analysis" OFF) -# Removed, and accepted only so a consumer still passing it keeps configuring. -# `odr::mimetype` is our own detection now: it reads inside zip and cfb -# containers, which libmagic cannot, and it costs neither a dependency nor the -# 8 MB `magic.mgc` database every consumer had to ship and point us at. -option(ODR_WITH_LIBMAGIC "Removed, does nothing (deprecated)" OFF) -option(ODR_BUNDLE_ASSETS "Removed, does nothing (deprecated)" OFF) option(ODR_PYTHON "Build Python bindings" OFF) option(ODR_JNI "Build JNI bindings" OFF) option(ODR_APPLE "Build Objective-C bindings as a framework" OFF) @@ -100,7 +94,6 @@ set(ODR_SOURCE_FILES "src/odr/exceptions.cpp" "src/odr/file.cpp" "src/odr/filesystem.cpp" - "src/odr/global_params.cpp" "src/odr/html.cpp" "src/odr/logger.cpp" "src/odr/odr.cpp" @@ -346,18 +339,6 @@ if (ODR_WITH_HTTP_SERVER) ODR_WITH_HTTP_SERVER ) endif () -if (ODR_WITH_LIBMAGIC) - message(DEPRECATION - "ODR_WITH_LIBMAGIC no longer does anything: libmagic is gone and " - "`odr::mimetype` is our own detection. Drop the option; " - "`GlobalParams::libmagic_database_path` is inert too.") -endif () -if (ODR_BUNDLE_ASSETS) - message(DEPRECATION - "ODR_BUNDLE_ASSETS no longer does anything: the css and js are " - "part of the library and there is nothing left to ship. Drop the " - "option; `GlobalParams::odr_core_data_path` is inert too.") -endif () configure_file("src/odr/internal/project_info.cpp.in" "src/odr/internal/project_info.cpp") diff --git a/android/AGENTS.md b/android/AGENTS.md index b622ffabc..c33d1b307 100644 --- a/android/AGENTS.md +++ b/android/AGENTS.md @@ -11,7 +11,6 @@ first — the java API and its android constraints live there. User facing docs: |------|------| | `build.gradle.kts` | The library module: sources from `../jni/java`, prebuilt native libs, lint, publishing. Single project — `rootProject.name` *is* the artifactId. | | `build_native.py` | conan + cmake per ABI → `native/prebuilt/jniLibs`. Invoked by the `buildNative` gradle task and directly by CI. | -| `src/main/java/.../android/OdrAndroid.kt` | The only android specific production code, and a deprecated no-op: it used to extract the renderer's assets, which are part of the library now. | | `src/androidTest/` | Instrumented suite, JUnit 4 + androidx.test, inputs from `../jni/testfixtures`. | | `consumer-rules.pro` | Keeps `app.opendocument.core.**` — JNI resolves it by name, R8 cannot see that. | @@ -41,9 +40,10 @@ calls it. - **What this module writes is kotlin; what it borrows is java.** `../jni/java` and `../jni/testfixtures` are compiled by CMake's `add_jar` for the maven jar and the host junit suite, which have no kotlin toolchain, so they stay java — - the kotlin here is only `OdrAndroid` and `src/androidTest`. Anything crossing - back to a java caller keeps its java shape: `@JvmStatic` so `OdrAndroid.init` - stays a static call, `@Throws` so the `IOException` stays checked. + the kotlin here is only `src/androidTest` — the module ships no production + code of its own. Anything added that crosses back to a java caller keeps its + java shape: `@JvmStatic` for a static call, `@Throws` for a checked + exception. - **Formatting is ktfmt** (kotlinlang style) via spotless, the same version OpenDocument.droid runs. `./gradlew spotlessApply`; CI checks it in `.github/workflows/format.yml`, which needs neither the NDK nor conan. diff --git a/android/README.md b/android/README.md index a0912552f..c33f332a7 100644 --- a/android/README.md +++ b/android/README.md @@ -5,7 +5,7 @@ library for every ABI, and the runtime data the renderer needs, in one artifact. ``` odr-core-android.aar -├── classes.jar app.opendocument.core (../jni/java) + OdrAndroid +├── classes.jar app.opendocument.core (../jni/java) ├── jni//libodr_jni.so the bindings with the core linked in ├── jni//libc++_shared.so the c++ runtime they were built against └── proguard.txt keeps the classes JNI resolves by name @@ -39,9 +39,7 @@ val html = service.bringOffline(outputDir.path) ``` Nothing needs initialising: the renderer's css and js are part of the native -library. `OdrAndroid.init(context)` is a deprecated no-op — it used to unpack -the assets that carried them — and stays callable, checked `IOException` and -all, so apps written against the older AAR keep compiling. +library, and the AAR carries no assets to unpack. Serving the rendered HTML through `HttpServer` needs two things from the app, neither of which a library may decide on its own: `android.permission.INTERNET`, diff --git a/android/src/androidTest/java/app/opendocument/core/OdrAndroidTest.kt b/android/src/androidTest/java/app/opendocument/core/AarContractTest.kt similarity index 76% rename from android/src/androidTest/java/app/opendocument/core/OdrAndroidTest.kt rename to android/src/androidTest/java/app/opendocument/core/AarContractTest.kt index ae848472f..39809964a 100644 --- a/android/src/androidTest/java/app/opendocument/core/OdrAndroidTest.kt +++ b/android/src/androidTest/java/app/opendocument/core/AarContractTest.kt @@ -1,7 +1,6 @@ package app.opendocument.core import androidx.test.ext.junit.runners.AndroidJUnit4 -import app.opendocument.core.android.OdrAndroid import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull @@ -10,7 +9,7 @@ import org.junit.runner.RunWith /** The AAR's own contract: the native library loads and works without any setup. */ @RunWith(AndroidJUnit4::class) -class OdrAndroidTest { +class AarContractTest { @Test fun nativeLibraryLoads() { // reaching the native side at all means the .so, its ABI and libc++_shared @@ -20,14 +19,6 @@ class OdrAndroidTest { assertNotNull(Odr.commitHash()) } - @Test - @Suppress("DEPRECATION") - fun initIsANoOp() { - // it is still called by apps built against the versions that needed it - OdrAndroid.init(TestSupport.context()) - OdrAndroid.init(TestSupport.context()) - } - @Test fun detectsTypeInsideTheContainer() { val directory = TestSupport.tempDir("magic") diff --git a/android/src/main/java/app/opendocument/core/android/OdrAndroid.kt b/android/src/main/java/app/opendocument/core/android/OdrAndroid.kt deleted file mode 100644 index be66be0a1..000000000 --- a/android/src/main/java/app/opendocument/core/android/OdrAndroid.kt +++ /dev/null @@ -1,23 +0,0 @@ -package app.opendocument.core.android - -import android.content.Context -import java.io.IOException - -/** - * Android entry point of the library. - * - * Nothing needs setting up any more: the renderer's CSS/JS are part of the native library, so the - * assets this used to extract are gone. [init] stays as a no-op so existing callers keep working. - */ -object OdrAndroid { - /** - * Does nothing. - * - * @param context unused - */ - @Deprecated("The library needs no setup; this does nothing.") - @JvmStatic - @Synchronized - @Throws(IOException::class) - fun init(context: Context) {} -} diff --git a/apple/CMakeLists.txt b/apple/CMakeLists.txt index 52d531529..285bd92ce 100644 --- a/apple/CMakeLists.txt +++ b/apple/CMakeLists.txt @@ -40,7 +40,6 @@ set(ODR_APPLE_PUBLIC_HEADERS "include/OdrCoreObjC/OdrCoreObjC.h" "include/OdrCoreObjC/ODRDocumentElement.h" "include/OdrCoreObjC/ODRError.h" - "include/OdrCoreObjC/ODRGlobalParams.h" "include/OdrCoreObjC/ODRDocument.h" "include/OdrCoreObjC/ODRFile.h" "include/OdrCoreObjC/ODRFilesystem.h" @@ -54,7 +53,6 @@ set(ODR_APPLE_PUBLIC_HEADERS add_library(odr_apple SHARED "src/ODRInternal.mm" - "src/ODRGlobalParams.mm" "src/ODRDocument.mm" "src/ODRDocumentElement.mm" "src/ODRFile.mm" diff --git a/apple/include/OdrCoreObjC/ODRGlobalParams.h b/apple/include/OdrCoreObjC/ODRGlobalParams.h deleted file mode 100644 index e640ca7a0..000000000 --- a/apple/include/OdrCoreObjC/ODRGlobalParams.h +++ /dev/null @@ -1,35 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -/// Runtime paths odrcore no longer needs. -/// -/// Nothing here has any effect: the renderer's css and js are part of the -/// library, and detection needs no database. Both properties still store and -/// return what is set, so a caller that configures them keeps working. -NS_SWIFT_NAME(GlobalParams) -@interface ODRGlobalParams : NSObject - -/// Where the css and js of the HTML renderer used to be read from. -/// -/// Deprecated and inert: they are written into the generated HTML now. -@property(class, nonatomic, copy) NSString *odrCoreDataPath; -/// The libmagic database (`magic.mgc`). -/// -/// Deprecated and inert: libmagic is gone and nothing reads this. It still -/// returns whatever is set, so a caller that sets it keeps working — detection -/// is odrcore's own now and needs no database. -@property(class, nonatomic, copy) NSString *libmagicDatabasePath; - -/// Points `odrCoreDataPath` at this framework's bundle. -/// -/// Deprecated and inert: the framework carries no resources any more. Kept so -/// a caller that set the path up itself keeps compiling. -+ (void)bootstrapFromFrameworkBundle; - -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/apple/include/OdrCoreObjC/OdrCoreObjC.h b/apple/include/OdrCoreObjC/OdrCoreObjC.h index 3147457cf..f238375ca 100644 --- a/apple/include/OdrCoreObjC/OdrCoreObjC.h +++ b/apple/include/OdrCoreObjC/OdrCoreObjC.h @@ -7,7 +7,6 @@ #import #import #import -#import #import #import #import diff --git a/apple/src/ODRGlobalParams.mm b/apple/src/ODRGlobalParams.mm deleted file mode 100644 index e33afbdef..000000000 --- a/apple/src/ODRGlobalParams.mm +++ /dev/null @@ -1,51 +0,0 @@ -#import - -#import "ODRInternal.h" - -#include - -@implementation ODRGlobalParams - -+ (NSString *)odrCoreDataPath { - return odr::apple::guarded_value( - [&] { - return odr::apple::to_nsstring(odr::GlobalParams::odr_core_data_path()); - }, - @""); -} - -+ (void)setOdrCoreDataPath:(NSString *)odrCoreDataPath { - odr::apple::guarded_void([&] { - odr::GlobalParams::set_odr_core_data_path( - odr::apple::to_string(odrCoreDataPath)); - }); -} - -+ (NSString *)libmagicDatabasePath { - return odr::apple::guarded_value( - [&] { - return odr::apple::to_nsstring( - odr::GlobalParams::libmagic_database_path()); - }, - @""); -} - -+ (void)setLibmagicDatabasePath:(NSString *)libmagicDatabasePath { - odr::apple::guarded_void([&] { - odr::GlobalParams::set_libmagic_database_path( - odr::apple::to_string(libmagicDatabasePath)); - }); -} - -+ (void)bootstrapFromFrameworkBundle { - NSBundle *const bundle = [NSBundle bundleForClass:self]; - - // Flat at the bundle root on iOS, `Versions/A/Resources` on macOS — never - // assume the layout, ask NSBundle. - NSString *const resources = bundle.resourcePath; - if (resources != nil) { - ODRGlobalParams.odrCoreDataPath = resources; - } -} - -@end diff --git a/conanfile.py b/conanfile.py index 5c8fd6ae1..2027399c5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -16,28 +16,22 @@ class OpenDocumentCoreConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], - # removed and inert, kept only so a consumer still passing it does not - # hard-fail on an unknown option; see CMakeLists.txt - "with_libmagic": [True, False], "with_http_server": [True, False], "with_cli": [True, False], "with_python": [True, False], "with_jni": [True, False], "with_apple": [True, False], "with_wasm": [True, False], - "bundle_assets": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_libmagic": False, "with_http_server": True, "with_cli": True, "with_python": False, "with_jni": False, "with_apple": False, "with_wasm": False, - "bundle_assets": False, # paired with PUGIXML_COMPACT in CMakeLists.txt: no prebuilt library # to mismatch against the node layout the define changes "pugixml/*:header_only": True, @@ -48,7 +42,6 @@ class OpenDocumentCoreConan(ConanFile): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - del self.options.with_libmagic def requirements(self): self.requires("pugixml/1.15") @@ -82,14 +75,12 @@ def generate(self): tc.variables["ODR_TEST"] = False # forwarded only so the CMake deprecation warning reaches a consumer # who still sets it; neither end does anything with it - tc.variables["ODR_WITH_LIBMAGIC"] = self.options.get_safe("with_libmagic", False) tc.variables["ODR_WITH_HTTP_SERVER"] = self.options.get_safe("with_http_server", False) tc.variables["ODR_CLI"] = self.options.get_safe("with_cli", True) tc.variables["ODR_PYTHON"] = self.options.get_safe("with_python", False) tc.variables["ODR_JNI"] = self.options.get_safe("with_jni", False) tc.variables["ODR_APPLE"] = self.options.get_safe("with_apple", False) tc.variables["ODR_WASM"] = self.options.get_safe("with_wasm", False) - tc.variables["ODR_BUNDLE_ASSETS"] = self.options.get_safe("bundle_assets", False) tc.generate() diff --git a/docs/design/README.md b/docs/design/README.md index 0c33a4c4b..09c5a1c9f 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -97,20 +97,10 @@ ### Open tasks -- drop the last inert traces of the shipped css/js once consumers have moved - off them: `GlobalParams::odr_core_data_path` and its java, python and objc - mirrors, plus `OdrAndroid.init`, - `ODRGlobalParams.bootstrapFromFrameworkBundle` and the `ODR_BUNDLE_ASSETS` / - conan `bundle_assets` option, all still accepted and all doing nothing. They - are about *finding* a data directory, which nothing does any more — unlike +- nothing looks for a data directory any more, and nothing accepts a path to + one: `GlobalParams` and the libmagic and asset build options are gone with + v7. What decides where the compiled-in css and js *land* is live and stays — `HtmlConfig::embed_shipped_resources`, `resource_path`, - `relative_resource_paths` and `HtmlResource::is_shipped`, which decide where - the compiled-in css and js land and are live again. -- drop the last inert traces of libmagic once consumers have moved off them: - `GlobalParams::libmagic_database_path` and its java, python and objc mirrors - still store and return a path nothing reads, and `ODR_WITH_LIBMAGIC` / - the conan `with_libmagic` option are still accepted so a build that sets one - keeps configuring. Removing them is the breaking change this deliberately - is not. + `relative_resource_paths`, `HtmlResource::is_shipped`. - collect additional pdf files via the translate cli and capture the ones that break - exercise editing across all formats (odp editing appears broken via an HTML issue) diff --git a/jni/CMakeLists.txt b/jni/CMakeLists.txt index f932c52cb..7f528d273 100644 --- a/jni/CMakeLists.txt +++ b/jni/CMakeLists.txt @@ -102,7 +102,6 @@ add_jar(odr_java "java/app/opendocument/core/LoggerBridge.java" "java/app/opendocument/core/SourceLocation.java" "java/app/opendocument/core/Frame.java" - "java/app/opendocument/core/GlobalParams.java" "java/app/opendocument/core/GraphicStyle.java" "java/app/opendocument/core/GuardedNativeResource.java" "java/app/opendocument/core/HorizontalAlign.java" diff --git a/jni/README.md b/jni/README.md index 0ec0c6092..451e62381 100644 --- a/jni/README.md +++ b/jni/README.md @@ -80,9 +80,7 @@ configure step rather than producing a package without the jar in it. ## Runtime data There is none. The renderer's CSS/JS are part of the library and detection needs -no database, so `GlobalParams.setOdrCoreDataPath(...)` and -`setLibmagicDatabasePath(...)` are deprecated leftovers that store a path -nothing reads. +no database, so there is nothing to point the library at. ## Notes diff --git a/jni/java/app/opendocument/core/GlobalParams.java b/jni/java/app/opendocument/core/GlobalParams.java deleted file mode 100644 index e8fb53dca..000000000 --- a/jni/java/app/opendocument/core/GlobalParams.java +++ /dev/null @@ -1,27 +0,0 @@ -package app.opendocument.core; - -/** Global resource paths of the library. Mirrors {@code odr::GlobalParams}. */ -public final class GlobalParams { - static { - NativeLibrary.load(); - } - - public static native String odrCoreDataPath(); - - /** - * @deprecated Inert: libmagic is gone and nothing reads this. It still returns whatever was set, - * so a caller that sets it keeps working — detection is our own now and needs no database. - */ - @Deprecated - public static native String libmagicDatabasePath(); - - public static native void setOdrCoreDataPath(String path); - - /** - * @deprecated See {@link #libmagicDatabasePath()}. - */ - @Deprecated - public static native void setLibmagicDatabasePath(String path); - - private GlobalParams() {} -} diff --git a/jni/src/jni_core.cpp b/jni/src/jni_core.cpp index 73daf0de6..08470776e 100644 --- a/jni/src/jni_core.cpp +++ b/jni/src/jni_core.cpp @@ -2,7 +2,6 @@ #include "odr_jni.hpp" #include -#include #include #include #include @@ -267,40 +266,6 @@ Java_app_opendocument_core_Odr_openWithPreferenceNative( }); } -// app.opendocument.core.GlobalParams - -extern "C" JNIEXPORT jstring JNICALL -Java_app_opendocument_core_GlobalParams_odrCoreDataPath(JNIEnv *env, jclass) { - return guarded(env, [&] { - return to_jstring(env, odr::GlobalParams::odr_core_data_path()); - }); -} - -extern "C" JNIEXPORT jstring JNICALL -Java_app_opendocument_core_GlobalParams_libmagicDatabasePath(JNIEnv *env, - jclass) { - return guarded(env, [&] { - return to_jstring(env, odr::GlobalParams::libmagic_database_path()); - }); -} - -extern "C" JNIEXPORT void JNICALL -Java_app_opendocument_core_GlobalParams_setOdrCoreDataPath(JNIEnv *env, jclass, - jstring path) { - guarded(env, [&] { - odr::GlobalParams::set_odr_core_data_path(to_string(env, path)); - }); -} - -extern "C" JNIEXPORT void JNICALL -Java_app_opendocument_core_GlobalParams_setLibmagicDatabasePath(JNIEnv *env, - jclass, - jstring path) { - guarded(env, [&] { - odr::GlobalParams::set_libmagic_database_path(to_string(env, path)); - }); -} - // app.opendocument.core.TablePosition extern "C" JNIEXPORT jint JNICALL diff --git a/python/README.md b/python/README.md index 057ab9b7e..366f7c59f 100644 --- a/python/README.md +++ b/python/README.md @@ -43,11 +43,6 @@ CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake" pip install . ## Runtime data There is none. The renderer's css and js are part of the library, so rendering -works out of the box; `odr_core_data_path()` and `set_odr_core_data_path(...)` -are deprecated leftovers that still store and return a path nothing reads. - -MIME detection needs no runtime data: `mimetype` runs the open strategy, so it -names what is *inside* a zip or a compound file. `libmagic_database_path()` and -`set_libmagic_database_path(...)` are deprecated leftovers of the libmagic -backend that used to answer this and could only say `application/zip` for an -`.odt`; they still store and return a path, but nothing reads it. +works out of the box, and MIME detection needs no database: `mimetype` runs the +open strategy, so it names what is *inside* a zip or a compound file rather +than answering `application/zip` for an `.odt`. diff --git a/python/src/bind_core.cpp b/python/src/bind_core.cpp index 1f4532248..b7eff768d 100644 --- a/python/src/bind_core.cpp +++ b/python/src/bind_core.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -22,19 +21,6 @@ void odr_python::bind_core(py::module_ &m) { m.def("identify", &odr::identify, "Identification string of the underlying odrcore library."); - py::class_(m, "GlobalParams", - "Global resource paths of the library.") - .def_static("odr_core_data_path", &odr::GlobalParams::odr_core_data_path) - // the two libmagic paths are deprecated and inert: libmagic is gone, so - // nothing reads back what they store - .def_static("libmagic_database_path", - &odr::GlobalParams::libmagic_database_path) - .def_static("set_odr_core_data_path", - &odr::GlobalParams::set_odr_core_data_path, py::arg("path")) - .def_static("set_libmagic_database_path", - &odr::GlobalParams::set_libmagic_database_path, - py::arg("path")); - // Mirrors odr::Exception, so `except odr.Error` catches the whole library. // `register_exception`, not `py::exception`: the latter has no translator. // Registered first so it is tried last - pybind11 reverses that order. diff --git a/python/tests/test_meta.py b/python/tests/test_meta.py index 8c0a71acf..6421481ed 100644 --- a/python/tests/test_meta.py +++ b/python/tests/test_meta.py @@ -124,10 +124,6 @@ def test_decoded_file_capabilities(odt_path): assert not capabilities.decrypt -def test_global_params(): - assert isinstance(pyodr.GlobalParams.odr_core_data_path(), str) - - def test_mimetype_names_what_is_inside_the_container(odt_path): # An ODF file is a ZIP, and the answer worth having is the one from inside # it. Detection opens the container to get there. diff --git a/src/odr/global_params.cpp b/src/odr/global_params.cpp deleted file mode 100644 index 4d64f4330..000000000 --- a/src/odr/global_params.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -namespace odr { - -GlobalParams &GlobalParams::instance() { - static GlobalParams instance; - - return instance; -} - -const std::string &GlobalParams::odr_core_data_path() { - return instance().m_odr_core_data_path; -} - -const std::string &GlobalParams::libmagic_database_path() { - return instance().m_libmagic_database_path; -} - -void GlobalParams::set_odr_core_data_path(const std::string &path) { - instance().m_odr_core_data_path = path; -} - -void GlobalParams::set_libmagic_database_path(const std::string &path) { - instance().m_libmagic_database_path = path; -} - -// Both paths start empty: nothing reads either of them, and there is no longer -// anything on disk to default them to. -GlobalParams::GlobalParams() = default; - -} // namespace odr diff --git a/src/odr/global_params.hpp b/src/odr/global_params.hpp deleted file mode 100644 index 358c55031..000000000 --- a/src/odr/global_params.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include - -namespace odr { - -class GlobalParams final { -public: - /// @deprecated Inert: the css and js are part of the library and nothing is - /// read from disk. It still stores and returns whatever is set, so a caller - /// that points it somewhere keeps working. - static const std::string &odr_core_data_path(); - /// @deprecated Inert: libmagic is gone and nothing reads this. It still - /// stores and returns whatever is set, so a caller that sets it keeps - /// working — detection is our own now, and looks at nothing outside the file. - static const std::string &libmagic_database_path(); - - /// @deprecated See @ref odr_core_data_path. - static void set_odr_core_data_path(const std::string &path); - /// @deprecated See @ref libmagic_database_path. - static void set_libmagic_database_path(const std::string &path); - -private: - static GlobalParams &instance(); - - GlobalParams(); - - std::string m_odr_core_data_path; - std::string m_libmagic_database_path; -}; - -} // namespace odr diff --git a/test/public_headers_cpp20.cpp b/test/public_headers_cpp20.cpp index d85c538cb..21b1b3b01 100644 --- a/test/public_headers_cpp20.cpp +++ b/test/public_headers_cpp20.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include