Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.5KB

  1. // Copyright 2021 Jean Pierre Cimalando
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // SPDX-License-Identifier: Apache-2.0
  16. //
  17. #pragma once
  18. #include "ysfx.h"
  19. #include <string>
  20. typedef void *NSEEL_VMCTX;
  21. class WDL_FastString;
  22. //------------------------------------------------------------------------------
  23. void ysfx_api_init_eel();
  24. //------------------------------------------------------------------------------
  25. void ysfx_eel_string_initvm(NSEEL_VMCTX vm);
  26. //------------------------------------------------------------------------------
  27. class eel_string_context_state;
  28. eel_string_context_state *ysfx_eel_string_context_new();
  29. void ysfx_eel_string_context_free(eel_string_context_state *state);
  30. void ysfx_eel_string_context_update_named_vars(eel_string_context_state *state, NSEEL_VMCTX vm);
  31. YSFX_DEFINE_AUTO_PTR(eel_string_context_state_u, eel_string_context_state, ysfx_eel_string_context_free);
  32. //------------------------------------------------------------------------------
  33. enum { ysfx_string_max_length = 1 << 16 };
  34. bool ysfx_string_access(ysfx_t *fx, ysfx_real id, bool for_write, void (*access)(void *, WDL_FastString &), void *userdata);
  35. bool ysfx_string_get(ysfx_t *fx, ysfx_real id, std::string &txt);
  36. bool ysfx_string_set(ysfx_t *fx, ysfx_real id, const std::string &txt);
  37. void ysfx_string_lock(ysfx_t *fx);
  38. void ysfx_string_unlock(ysfx_t *fx);
  39. const char *ysfx_string_access_unlocked(ysfx_t *fx, ysfx_real id, WDL_FastString **fs, bool for_write);
  40. struct ysfx_string_scoped_lock {
  41. ysfx_string_scoped_lock(ysfx_t *fx) : m_fx(fx) { ysfx_string_lock(fx); }
  42. ~ysfx_string_scoped_lock() { ysfx_string_unlock(m_fx); }
  43. private:
  44. ysfx_t *m_fx = nullptr;
  45. };
  46. #define EEL_STRING_GET_CONTEXT_POINTER(opaque) (((ysfx_t *)(opaque))->string_ctx.get())
  47. #define EEL_STRING_GET_FOR_INDEX(x, wr) (ysfx_string_access_unlocked((ysfx_t *)(opaque), x, wr, false))
  48. #define EEL_STRING_GET_FOR_WRITE(x, wr) (ysfx_string_access_unlocked((ysfx_t *)(opaque), x, wr, true))
  49. #define EEL_STRING_MUTEXLOCK_SCOPE ysfx_string_scoped_lock lock{(ysfx_t *)(opaque)};