Browse Source

Rename INTERNAL to PRIVATE. Add PRIVATE to several functions/symbols that plugins should never call/use.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
b22f88b8aa
31 changed files with 102 additions and 100 deletions
  1. +1
    -1
      include/app/Browser.hpp
  2. +1
    -1
      include/app/MenuBar.hpp
  3. +4
    -4
      include/app/ModuleWidget.hpp
  4. +2
    -2
      include/app/RackScrollWidget.hpp
  5. +2
    -2
      include/app/RackWidget.hpp
  6. +2
    -2
      include/app/Scene.hpp
  7. +1
    -1
      include/app/TipWindow.hpp
  8. +4
    -4
      include/asset.hpp
  9. +2
    -2
      include/audio.hpp
  10. +7
    -7
      include/common.hpp
  11. +2
    -2
      include/componentlibrary.hpp
  12. +2
    -2
      include/discord.hpp
  13. +1
    -1
      include/engine/Cable.hpp
  14. +9
    -9
      include/engine/Engine.hpp
  15. +6
    -6
      include/engine/Module.hpp
  16. +2
    -2
      include/gamepad.hpp
  17. +3
    -3
      include/history.hpp
  18. +1
    -1
      include/keyboard.hpp
  19. +9
    -9
      include/library.hpp
  20. +4
    -3
      include/logger.hpp
  21. +2
    -2
      include/midi.hpp
  22. +2
    -2
      include/network.hpp
  23. +3
    -3
      include/patch.hpp
  24. +2
    -2
      include/plugin.hpp
  25. +9
    -8
      include/rack.hpp
  26. +1
    -1
      include/rtaudio.hpp
  27. +1
    -1
      include/rtmidi.hpp
  28. +5
    -5
      include/settings.hpp
  29. +1
    -1
      include/system.hpp
  30. +2
    -2
      include/ui/common.hpp
  31. +9
    -9
      include/window/Window.hpp

+ 1
- 1
include/app/Browser.hpp View File

@@ -7,7 +7,7 @@ namespace rack {
namespace app {


widget::Widget* browserCreate();
PRIVATE widget::Widget* browserCreate();


} // namespace app


+ 1
- 1
include/app/MenuBar.hpp View File

@@ -7,7 +7,7 @@ namespace rack {
namespace app {


widget::Widget* createMenuBar();
PRIVATE widget::Widget* createMenuBar();


} // namespace app


+ 4
- 4
include/app/ModuleWidget.hpp View File

@@ -116,10 +116,10 @@ struct ModuleWidget : widget::OpaqueWidget {
void removeAction();
void createContextMenu();

INTERNAL math::Vec& dragOffset();
INTERNAL bool& dragEnabled();
INTERNAL math::Vec& oldPos();
INTERNAL engine::Module* releaseModule();
PRIVATE math::Vec& dragOffset();
PRIVATE bool& dragEnabled();
PRIVATE math::Vec& oldPos();
PRIVATE engine::Module* releaseModule();
};




+ 2
- 2
include/app/RackScrollWidget.hpp View File

@@ -16,8 +16,8 @@ struct RackScrollWidget : ui::ScrollWidget {
widget::ZoomWidget* zoomWidget;
RackWidget* rackWidget;

RackScrollWidget();
~RackScrollWidget();
PRIVATE RackScrollWidget();
PRIVATE ~RackScrollWidget();

void reset();
/** Gets the top-left scroll offset in grid coordinates.


+ 2
- 2
include/app/RackWidget.hpp View File

@@ -26,8 +26,8 @@ struct RackWidget : widget::OpaqueWidget {
ParamWidget* touchedParam = NULL;
int nextCableColorId = 0;

RackWidget();
~RackWidget();
PRIVATE RackWidget();
PRIVATE ~RackWidget();

void step() override;
void draw(const DrawArgs& args) override;


+ 2
- 2
include/app/Scene.hpp View File

@@ -23,8 +23,8 @@ struct Scene : widget::OpaqueWidget {
/** The last mouse position in the Scene */
math::Vec mousePos;

Scene();
~Scene();
PRIVATE Scene();
PRIVATE ~Scene();
math::Vec getMousePos();
void step() override;
void draw(const DrawArgs& args) override;


+ 1
- 1
include/app/TipWindow.hpp View File

@@ -7,7 +7,7 @@ namespace rack {
namespace app {


widget::Widget* tipWindowCreate();
PRIVATE widget::Widget* tipWindowCreate();


} // namespace app


+ 4
- 4
include/asset.hpp View File

@@ -19,7 +19,7 @@ struct Module;
namespace asset {


void init();
PRIVATE void init();

/** Returns the path of a system asset. Read-only files. */
std::string system(std::string filename = "");
@@ -37,10 +37,10 @@ std::string plugin(plugin::Plugin* plugin, std::string filename = "");


// Set these before calling init() to override the default paths
extern std::string systemDir;
extern std::string userDir;
PRIVATE extern std::string systemDir;
PRIVATE extern std::string userDir;
// Only defined on Mac
extern std::string bundlePath;
PRIVATE extern std::string bundlePath;


} // namespace asset


+ 2
- 2
include/audio.hpp View File

@@ -194,8 +194,8 @@ struct Port {
};


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
/** Registers a new audio driver. Takes pointer ownership.
Driver ID is stored in patches and must be unique. -1 is reserved.
*/


+ 7
- 7
include/common.hpp View File

@@ -15,8 +15,6 @@
#include <string>
#include <stdexcept>

#include <logger.hpp>


/** Attribute for deprecated functions and symbols.
E.g.
@@ -30,12 +28,10 @@ E.g.
#endif

/** Attribute for private functions and symbols not intended to be used by plugins.
When #including rack.hpp, using an INTERNAL function prints a compile-time warning and will not link.
When #including rack.hpp, attempting to call PRIVATE functions or access variables will result in a compile-time error.
*/
#if defined ARCH_WIN
#define INTERNAL
#else
#define INTERNAL __attribute__((visibility("hidden")))
#ifndef PRIVATE
#define PRIVATE
#endif


@@ -271,3 +267,7 @@ extern const std::string API_URL;


} // namespace rack


// Logger depends on common.hpp, but it is handy to include it along with common.hpp.
#include <logger.hpp>

+ 2
- 2
include/componentlibrary.hpp View File

@@ -31,10 +31,10 @@ using namespace window;
static const NVGcolor SCHEME_BLACK_TRANSPARENT = nvgRGBA(0x00, 0x00, 0x00, 0x00);
static const NVGcolor SCHEME_BLACK = nvgRGB(0x00, 0x00, 0x00);
static const NVGcolor SCHEME_WHITE = nvgRGB(0xff, 0xff, 0xff);
static const NVGcolor SCHEME_RED = nvgRGB(0xed, 0x2c, 0x24);
static const NVGcolor SCHEME_RED = nvgRGB(0xff, 0x00, 0x48);
static const NVGcolor SCHEME_ORANGE = nvgRGB(0xf2, 0xb1, 0x20);
static const NVGcolor SCHEME_YELLOW = nvgRGB(0xf9, 0xdf, 0x1c);
static const NVGcolor SCHEME_GREEN = nvgRGB(0x90, 0xc7, 0x3e);
static const NVGcolor SCHEME_GREEN = nvgRGB(0x00, 0xe6, 0x72);
static const NVGcolor SCHEME_CYAN = nvgRGB(0x22, 0xe6, 0xef);
static const NVGcolor SCHEME_BLUE = nvgRGB(0x29, 0xb2, 0xef);
static const NVGcolor SCHEME_PURPLE = nvgRGB(0xd5, 0x2b, 0xed);


+ 2
- 2
include/discord.hpp View File

@@ -7,8 +7,8 @@ namespace rack {
namespace discord {


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();


} // namespace discord


+ 1
- 1
include/engine/Cable.hpp View File

@@ -20,7 +20,7 @@ struct Cable {

json_t* toJson();
void fromJson(json_t* rootJ);
INTERNAL static void jsonStripIds(json_t* rootJ);
PRIVATE static void jsonStripIds(json_t* rootJ);
};




+ 9
- 9
include/engine/Engine.hpp View File

@@ -23,14 +23,14 @@ struct Engine {
struct Internal;
Internal* internal;

Engine();
~Engine();
PRIVATE Engine();
PRIVATE ~Engine();

/** Removes all modules and cables.
Write-locks.
*/
void clear();
INTERNAL void clear_NoLock();
PRIVATE void clear_NoLock();
/** Advances the engine by `frames` frames.
Only call this method from the master module.
Read-locks. Also locks so only one stepBlock() can be called simultaneously or recursively.
@@ -42,7 +42,7 @@ struct Engine {
Write-locks.
*/
void setMasterModule(Module* module);
INTERNAL void setMasterModule_NoLock(Module* module);
PRIVATE void setMasterModule_NoLock(Module* module);
Module* getMasterModule();

/** Returns the sample rate used by the engine for stepping each module.
@@ -51,7 +51,7 @@ struct Engine {
/** Sets the sample rate to step the modules.
Write-locks.
*/
INTERNAL void setSampleRate(float sampleRate);
PRIVATE void setSampleRate(float sampleRate);
/** Sets the sample rate if the sample rate in the settings is "Auto".
Write-locks.
*/
@@ -116,7 +116,7 @@ struct Engine {
Write-locks.
*/
void removeModule(Module* module);
INTERNAL void removeModule_NoLock(Module* module);
PRIVATE void removeModule_NoLock(Module* module);
/** Checks whether a Module is in the rack.
Read-locks.
*/
@@ -173,7 +173,7 @@ struct Engine {
Write-locks.
*/
void removeCable(Cable* cable);
INTERNAL void removeCable_NoLock(Cable* cable);
PRIVATE void removeCable_NoLock(Cable* cable);
/** Checks whether a Cable is in the rack.
Read-locks.
*/
@@ -203,7 +203,7 @@ struct Engine {
Write-locks.
*/
void removeParamHandle(ParamHandle* paramHandle);
INTERNAL void removeParamHandle_NoLock(ParamHandle* paramHandle);
PRIVATE void removeParamHandle_NoLock(ParamHandle* paramHandle);
/** Returns the unique ParamHandle for the given paramId
Read-locks.
*/
@@ -229,7 +229,7 @@ struct Engine {

/** If no master module is set, the fallback Engine thread will step blocks, using the CPU clock for timing.
*/
void startFallbackThread();
PRIVATE void startFallbackThread();
};




+ 6
- 6
include/engine/Module.hpp View File

@@ -440,12 +440,12 @@ struct Module {
virtual void onSampleRateChange() {}

bool isBypassed();
INTERNAL void setBypassed(bool bypassed);
INTERNAL const float* meterBuffer();
INTERNAL int meterLength();
INTERNAL int meterIndex();
INTERNAL void doProcess(const ProcessArgs& args);
INTERNAL static void jsonStripIds(json_t* rootJ);
PRIVATE void setBypassed(bool bypassed);
PRIVATE const float* meterBuffer();
PRIVATE int meterLength();
PRIVATE int meterIndex();
PRIVATE void doProcess(const ProcessArgs& args);
PRIVATE static void jsonStripIds(json_t* rootJ);
};




+ 2
- 2
include/gamepad.hpp View File

@@ -7,8 +7,8 @@ namespace rack {
namespace gamepad {


void init();
void step();
PRIVATE void init();
PRIVATE void step();


} // namespace gamepad


+ 3
- 3
include/history.hpp View File

@@ -166,9 +166,9 @@ struct State {
/** Action index of saved patch state. */
int savedIndex;

State();
~State();
void clear();
PRIVATE State();
PRIVATE ~State();
PRIVATE void clear();
void push(Action* action);
void undo();
void redo();


+ 1
- 1
include/keyboard.hpp View File

@@ -8,7 +8,7 @@ namespace rack {
namespace keyboard {


void init();
PRIVATE void init();
void press(int key);
void release(int key);
/** pos is in the unit box. */


+ 9
- 9
include/library.hpp View File

@@ -17,19 +17,19 @@ struct UpdateInfo {
};


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();

void checkAppUpdate();
PRIVATE void checkAppUpdate();
bool isAppUpdateAvailable();

bool isLoggedIn();
void logIn(std::string email, std::string password);
void logOut();
void checkUpdates();
bool hasUpdates();
void syncUpdate(std::string slug);
void syncUpdates();
PRIVATE void logIn(std::string email, std::string password);
PRIVATE void logOut();
PRIVATE void checkUpdates();
PRIVATE bool hasUpdates();
PRIVATE void syncUpdate(std::string slug);
PRIVATE void syncUpdates();


extern std::string appVersion;


+ 4
- 3
include/logger.hpp View File

@@ -1,4 +1,5 @@
#pragma once
#include <common.hpp>


/** Example usage:
@@ -30,8 +31,8 @@ enum Level {
FATAL_LEVEL
};

void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
/** Do not use this function directly. Use the macros above.
Thread-safe, meaning messages cannot overlap each other in the log.
*/
@@ -39,7 +40,7 @@ __attribute__((format(printf, 5, 6)))
void log(Level level, const char* filename, int line, const char* func, const char* format, ...);
/** Returns whether the last log file failed to end properly, due to a possible crash.
*/
bool wasTruncated();
PRIVATE bool wasTruncated();


} // namespace logger


+ 2
- 2
include/midi.hpp View File

@@ -288,8 +288,8 @@ struct Output : Port {
};


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
/** Registers a new MIDI driver. Takes pointer ownership. */
void addDriver(int driverId, Driver* driver);
std::vector<int> getDriverIds();


+ 2
- 2
include/network.hpp View File

@@ -20,8 +20,8 @@ enum Method {
METHOD_DELETE,
};

void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
/** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc)
Caller must json_decref() if return value is non-NULL.
*/


+ 3
- 3
include/patch.hpp View File

@@ -25,9 +25,9 @@ struct Manager {
/** Append to this while loading/saving a patch to display messages to the user after success. */
std::string warningLog;

Manager();
~Manager();
void launch(std::string pathArg);
PRIVATE Manager();
PRIVATE ~Manager();
PRIVATE void launch(std::string pathArg);
/** Clears the patch. */
void clear();
/** Saves the patch and nothing else. */


+ 2
- 2
include/plugin.hpp View File

@@ -11,8 +11,8 @@ namespace rack {
namespace plugin {


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
/** Finds a loaded Plugin by slug. */
Plugin* getPlugin(const std::string& pluginSlug);
/** Finds a loaded Model by plugin and model slug. */


+ 9
- 8
include/rack.hpp View File

@@ -6,6 +6,15 @@ The following headers are the "public" API of Rack.
Directly including Rack headers other than rack.hpp in your plugin is unsupported/unstable, since filenames and locations of symbols may change in any Rack version.
*/

#ifdef PRIVATE
#error "Plugins must only include rack.hpp. Including other Rack headers is unsupported."
#endif

/** Functions and symbols with the PRIVATE attribute should not be called/used by plugins.
*/
#define PRIVATE __attribute__((error("Using internal Rack function or symbol")))


#include <common.hpp>
#include <math.hpp>
#include <string.hpp>
@@ -113,14 +122,6 @@ Directly including Rack headers other than rack.hpp in your plugin is unsupporte
#include <simd/functions.hpp>


#undef INTERNAL
#if defined ARCH_WIN
#define INTERNAL __attribute__((error("Using internal Rack function or symbol")))
#else
#define INTERNAL __attribute__((visibility("hidden"))) __attribute__((error("Using internal Rack function or symbol")))
#endif


namespace rack {




+ 1
- 1
include/rtaudio.hpp View File

@@ -5,7 +5,7 @@
namespace rack {


void rtaudioInit();
PRIVATE void rtaudioInit();


} // namespace rack

+ 1
- 1
include/rtmidi.hpp View File

@@ -5,7 +5,7 @@
namespace rack {


void rtmidiInit();
PRIVATE void rtmidiInit();


} // namespace rack

+ 5
- 5
include/settings.hpp View File

@@ -101,11 +101,11 @@ extern std::map<std::string, std::set<std::string>> moduleWhitelist;

bool isModuleWhitelisted(const std::string& pluginSlug, const std::string& moduleSlug);

void init();
json_t* toJson();
void fromJson(json_t* rootJ);
void save(std::string path = "");
void load(std::string path = "");
PRIVATE void init();
PRIVATE json_t* toJson();
PRIVATE void fromJson(json_t* rootJ);
PRIVATE void save(std::string path = "");
PRIVATE void load(std::string path = "");


} // namespace settings


+ 1
- 1
include/system.hpp View File

@@ -189,7 +189,7 @@ The launched process will continue running if the current process is closed.
*/
void runProcessDetached(const std::string& path);

void init();
PRIVATE void init();


} // namespace system


+ 2
- 2
include/ui/common.hpp View File

@@ -21,8 +21,8 @@ namespace rack {
namespace ui {


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();
void setTheme(NVGcolor bg, NVGcolor fg);




+ 9
- 9
include/window/Window.hpp View File

@@ -65,19 +65,19 @@ struct Window {
float windowRatio = 1.f;
std::shared_ptr<Font> uiFont;

Window();
~Window();
PRIVATE Window();
PRIVATE ~Window();
math::Vec getSize();
void setSize(math::Vec size);
void run();
void step();
PRIVATE void run();
PRIVATE void step();
void activateContext();
/** Takes a screenshot of the screen and saves it to a PNG file. */
void screenshot(const std::string& screenshotPath);
PRIVATE void screenshot(const std::string& screenshotPath);
/** Saves a PNG image of all modules to `screenshotsDir/<plugin slug>/<module slug>.png`.
Skips screenshot if the file already exists.
*/
void screenshotModules(const std::string& screenshotsDir, float zoom = 1.f);
PRIVATE void screenshotModules(const std::string& screenshotsDir, float zoom = 1.f);
/** Request Window to be closed after rendering the current frame. */
void close();
void cursorLock();
@@ -100,12 +100,12 @@ struct Window {
return Svg::load(filename);
}

INTERNAL bool& fbDirtyOnSubpixelChange();
PRIVATE bool& fbDirtyOnSubpixelChange();
};


void init();
void destroy();
PRIVATE void init();
PRIVATE void destroy();


} // namespace window


Loading…
Cancel
Save