@@ -4,8 +4,8 @@ | |||||
*/ | */ | ||||
#ifndef BINARYDATA_H_17170897_INCLUDED | |||||
#define BINARYDATA_H_17170897_INCLUDED | |||||
#ifndef BINARYDATA_H_15459638_INCLUDED | |||||
#define BINARYDATA_H_15459638_INCLUDED | |||||
namespace BinaryData | namespace BinaryData | ||||
{ | { | ||||
@@ -29,6 +29,8 @@ | |||||
#define JucePlugin_LV2URI "http://www.osar.fr/protoplug#gen" | #define JucePlugin_LV2URI "http://www.osar.fr/protoplug#gen" | ||||
#endif | #endif | ||||
#define JucePlugin_IsMidiEffect 0 | |||||
#define JucePlugin_WantsLV2State 1 | #define JucePlugin_WantsLV2State 1 | ||||
#define JucePlugin_WantsLV2TimePos 1 | #define JucePlugin_WantsLV2TimePos 1 | ||||
#define JucePlugin_WantsLV2Presets 0 | #define JucePlugin_WantsLV2Presets 0 | ||||
@@ -3,6 +3,7 @@ | |||||
#include "PluginEditor.h" | #include "PluginEditor.h" | ||||
#include "ProtoplugDir.h" | #include "ProtoplugDir.h" | ||||
#include <map> | #include <map> | ||||
#include <cstdarg> | |||||
// exports for scripts | // exports for scripts | ||||
extern "C" { | extern "C" { | ||||
@@ -12,10 +13,25 @@ extern "C" { | |||||
// could be avoided by namespacing every callback into a userdata (eg. theme api) | // could be avoided by namespacing every callback into a userdata (eg. theme api) | ||||
std::map<protolua::lua_State*, LuaLink*> globalStates; | std::map<protolua::lua_State*, LuaLink*> globalStates; | ||||
// adapted from Lua 5.1 lbaselib.c | |||||
static int LuaWriteLine (protolua::lua_State *L) { | static int LuaWriteLine (protolua::lua_State *L) { | ||||
LuaLink *luli = globalStates[L]; | LuaLink *luli = globalStates[L]; | ||||
if (!luli) return 0; | if (!luli) return 0; | ||||
luli->addToLog(luli->ls->tolstring(1, 0)); | |||||
String logLine; | |||||
int n = luli->ls->gettop(); // number of arguments | |||||
int i; | |||||
luli->ls->getglobal("tostring"); | |||||
for (i=1; i<=n; i++) { | |||||
const char *s; | |||||
luli->ls->pushvalue(-1); // function to be called | |||||
luli->ls->pushvalue(i); // value to print | |||||
luli->ls->pcall(1, 1, 0); | |||||
s = luli->ls->tostring(-1); // get result | |||||
if (i>1) logLine += "\t"; | |||||
logLine += (s == NULL) ? "<cannot convert to string>" : s; | |||||
luli->ls->pop(1); // pop result | |||||
} | |||||
luli->addToLog(logLine); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -51,6 +67,7 @@ void LuaLink::initProtoplugDir() { | |||||
} | } | ||||
void LuaLink::addToLog(String buf, bool isInput /*= false*/) { | void LuaLink::addToLog(String buf, bool isInput /*= false*/) { | ||||
buf = buf.replace("\t", " "); // TODO this does not line up like real tabs, obviously... | |||||
if (log.length()>4000) | if (log.length()>4000) | ||||
log = log.substring(log.length()-3000); | log = log.substring(log.length()-3000); | ||||
Time t = Time::getCurrentTime(); | Time t = Time::getCurrentTime(); | ||||
@@ -262,7 +279,11 @@ int LuaLink::startVarargOverride(const char *fname, va_list _args) | |||||
ls->pushstring(va_arg(_args, char*)); | ls->pushstring(va_arg(_args, char*)); | ||||
break; | break; | ||||
default: | default: | ||||
#if DEBUG | |||||
juce_breakDebugger; | juce_breakDebugger; | ||||
#else | |||||
break; | |||||
#endif | |||||
} | } | ||||
} | } | ||||
return numArgs; | return numArgs; | ||||
@@ -388,6 +409,8 @@ void LuaLink::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages, | |||||
buffer.clear (channel, 0, buffer.getNumSamples()); | buffer.clear (channel, 0, buffer.getNumSamples()); | ||||
} | } | ||||
} | } | ||||
#else | |||||
ignoreUnused(res); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -17,6 +17,7 @@ ptr_lua_gettop LuaState::lua_gettop = 0; | |||||
ptr_lua_settop LuaState::lua_settop = 0; | ptr_lua_settop LuaState::lua_settop = 0; | ||||
ptr_lua_pcall LuaState::lua_pcall = 0; | ptr_lua_pcall LuaState::lua_pcall = 0; | ||||
ptr_lua_getfield LuaState::lua_getfield = 0; | ptr_lua_getfield LuaState::lua_getfield = 0; | ||||
ptr_lua_pushvalue LuaState::lua_pushvalue = 0; | |||||
ptr_lua_pushlightuserdata LuaState::lua_pushlightuserdata = 0; | ptr_lua_pushlightuserdata LuaState::lua_pushlightuserdata = 0; | ||||
ptr_lua_pushstring LuaState::lua_pushstring = 0; | ptr_lua_pushstring LuaState::lua_pushstring = 0; | ||||
ptr_lua_pushnumber LuaState::lua_pushnumber = 0; | ptr_lua_pushnumber LuaState::lua_pushnumber = 0; | ||||
@@ -61,6 +62,7 @@ LuaState::LuaState(File defaultDir) | |||||
lua_settop = ptr_lua_settop (dll->getFunction("lua_settop")); | lua_settop = ptr_lua_settop (dll->getFunction("lua_settop")); | ||||
lua_pcall = ptr_lua_pcall (dll->getFunction("lua_pcall")); | lua_pcall = ptr_lua_pcall (dll->getFunction("lua_pcall")); | ||||
lua_getfield = ptr_lua_getfield (dll->getFunction("lua_getfield")); | lua_getfield = ptr_lua_getfield (dll->getFunction("lua_getfield")); | ||||
lua_pushvalue = ptr_lua_pushvalue (dll->getFunction("lua_pushvalue")); | |||||
lua_pushlightuserdata = ptr_lua_pushlightuserdata (dll->getFunction("lua_pushlightuserdata")); | lua_pushlightuserdata = ptr_lua_pushlightuserdata (dll->getFunction("lua_pushlightuserdata")); | ||||
lua_pushstring = ptr_lua_pushstring (dll->getFunction("lua_pushstring")); | lua_pushstring = ptr_lua_pushstring (dll->getFunction("lua_pushstring")); | ||||
lua_pushnumber = ptr_lua_pushnumber (dll->getFunction("lua_pushnumber")); | lua_pushnumber = ptr_lua_pushnumber (dll->getFunction("lua_pushnumber")); | ||||
@@ -75,7 +77,7 @@ LuaState::LuaState(File defaultDir) | |||||
luajit_setmode = ptr_luajit_setmode (dll->getFunction("luaJIT_setmode")); | luajit_setmode = ptr_luajit_setmode (dll->getFunction("luaJIT_setmode")); | ||||
#endif | #endif | ||||
} | } | ||||
void *kk[23] = { | |||||
void *kk[24] = { | |||||
// cast required for some compilers | // cast required for some compilers | ||||
(void*)luaL_newstate, | (void*)luaL_newstate, | ||||
(void*)luaL_openlibs, | (void*)luaL_openlibs, | ||||
@@ -90,6 +92,7 @@ LuaState::LuaState(File defaultDir) | |||||
(void*)lua_settop, | (void*)lua_settop, | ||||
(void*)lua_pcall, | (void*)lua_pcall, | ||||
(void*)lua_getfield, | (void*)lua_getfield, | ||||
(void*)lua_pushvalue, | |||||
(void*)lua_pushlightuserdata, | (void*)lua_pushlightuserdata, | ||||
(void*)lua_pushstring, | (void*)lua_pushstring, | ||||
(void*)lua_pushnumber, | (void*)lua_pushnumber, | ||||
@@ -100,7 +103,7 @@ LuaState::LuaState(File defaultDir) | |||||
(void*)lua_isnumber, | (void*)lua_isnumber, | ||||
(void*)lua_typename, | (void*)lua_typename, | ||||
(void*)lua_newuserdata}; | (void*)lua_newuserdata}; | ||||
for (int i=0; i<23; i++) | |||||
for (int i=0; i<24; i++) | |||||
if (kk[i]==0) { | if (kk[i]==0) { | ||||
failed = 1; | failed = 1; | ||||
errmsg = "Error: Could not load " + libName + | errmsg = "Error: Could not load " + libName + | ||||
@@ -161,6 +164,9 @@ int LuaState::pcall(int nargs, int nresults, int errfunc) | |||||
void LuaState::getfield(int idx, const char *k) | void LuaState::getfield(int idx, const char *k) | ||||
{ (*lua_getfield)(l, idx, k);} | { (*lua_getfield)(l, idx, k);} | ||||
void LuaState::pushvalue(int idx) | |||||
{ (*lua_pushvalue)(l, idx);} | |||||
void LuaState::pushlightuserdata(void *p) | void LuaState::pushlightuserdata(void *p) | ||||
{ (*lua_pushlightuserdata)(l, p);} | { (*lua_pushlightuserdata)(l, p);} | ||||
@@ -37,6 +37,7 @@ typedef int (*ptr_lua_gettop) (lua_State *L); | |||||
typedef void (*ptr_lua_settop) (lua_State *L, int idx); | typedef void (*ptr_lua_settop) (lua_State *L, int idx); | ||||
typedef int (*ptr_lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); | typedef int (*ptr_lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); | ||||
typedef void (*ptr_lua_getfield) (lua_State *L, int idx, const char *k); | typedef void (*ptr_lua_getfield) (lua_State *L, int idx, const char *k); | ||||
typedef void (*ptr_lua_pushvalue) (lua_State *L, int idx); | |||||
typedef void (*ptr_lua_pushlightuserdata)(lua_State *L, void *p); | typedef void (*ptr_lua_pushlightuserdata)(lua_State *L, void *p); | ||||
typedef void (*ptr_lua_pushstring) (lua_State *L, const char *s); | typedef void (*ptr_lua_pushstring) (lua_State *L, const char *s); | ||||
typedef void (*ptr_lua_pushnumber) (lua_State *L, lua_Number n); | typedef void (*ptr_lua_pushnumber) (lua_State *L, lua_Number n); | ||||
@@ -73,6 +74,7 @@ public: | |||||
void settop(int idx); | void settop(int idx); | ||||
int pcall(int nargs, int nresults, int errfunc); | int pcall(int nargs, int nresults, int errfunc); | ||||
void getfield(int idx, const char *k); | void getfield(int idx, const char *k); | ||||
void pushvalue(int idx); | |||||
void pushlightuserdata(void *p); | void pushlightuserdata(void *p); | ||||
void pushstring(const char *s); | void pushstring(const char *s); | ||||
void pushnumber(lua_Number n); | void pushnumber(lua_Number n); | ||||
@@ -124,6 +126,7 @@ public: | |||||
static ptr_lua_settop lua_settop; | static ptr_lua_settop lua_settop; | ||||
static ptr_lua_pcall lua_pcall; | static ptr_lua_pcall lua_pcall; | ||||
static ptr_lua_getfield lua_getfield; | static ptr_lua_getfield lua_getfield; | ||||
static ptr_lua_pushvalue lua_pushvalue; | |||||
static ptr_lua_pushlightuserdata lua_pushlightuserdata; | static ptr_lua_pushlightuserdata lua_pushlightuserdata; | ||||
static ptr_lua_pushstring lua_pushstring; | static ptr_lua_pushstring lua_pushstring; | ||||
static ptr_lua_pushnumber lua_pushnumber; | static ptr_lua_pushnumber lua_pushnumber; | ||||
@@ -180,7 +180,7 @@ PROTO_API void Graphics_drawRoundedRectangle2(pGraphics self, exRectangle_fl | |||||
PROTO_API void Graphics_setPixel(pGraphics self, int x, int y) | PROTO_API void Graphics_setPixel(pGraphics self, int x, int y) | ||||
{ self.g->setPixel(x, y); } | |||||
{ self.g->fillRect(x, y, 1, 1); } | |||||
PROTO_API void Graphics_fillEllipse(pGraphics self, float x, float y, float width, float height) | PROTO_API void Graphics_fillEllipse(pGraphics self, float x, float y, float width, float height) | ||||
@@ -16,7 +16,8 @@ | |||||
PROTO_API exLagrangeInterpolator LagrangeInterpolator_create() | PROTO_API exLagrangeInterpolator LagrangeInterpolator_create() | ||||
{ | { | ||||
LagrangeInterpolator li; | LagrangeInterpolator li; | ||||
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)(&li)); // look away children | |||||
LagrangeInterpolator* liptr = &li; | |||||
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)liptr); // look away children | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -68,6 +68,8 @@ public: | |||||
FT_Error result; | FT_Error result; | ||||
result = FT_Init_FreeType (&m_ft); | result = FT_Init_FreeType (&m_ft); | ||||
ignoreUnused(result); | |||||
} | } | ||||
~FreeTypeLibrary () | ~FreeTypeLibrary () | ||||
@@ -136,19 +138,19 @@ private: | |||||
}; | }; | ||||
#endif | #endif | ||||
protected: | |||||
FT_Face m_face; | |||||
int m_loadFlags; | |||||
private: | private: | ||||
FreeTypeLibrary::Ptr m_ft; | FreeTypeLibrary::Ptr m_ft; | ||||
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines | |||||
float m_minHintedHeight; | float m_minHintedHeight; | ||||
float m_maxHintedHeight; | float m_maxHintedHeight; | ||||
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines | |||||
float m_scale; | float m_scale; | ||||
float m_kerningScale; | float m_kerningScale; | ||||
int m_kerningMode; | int m_kerningMode; | ||||
protected: | |||||
FT_Face m_face; | |||||
int m_loadFlags; | |||||
public: | public: | ||||
FreeTypeFace (float minHintedHeight, | FreeTypeFace (float minHintedHeight, | ||||
float maxHintedHeight, | float maxHintedHeight, | ||||
@@ -630,7 +632,7 @@ private: | |||||
return 0; | return 0; | ||||
} | } | ||||
ImagePixelData* clone() | |||||
Ptr clone() | |||||
{ | { | ||||
ImagePixelData* dup = new GlyphImage (width, height, m_lineStride, m_imageData); | ImagePixelData* dup = new GlyphImage (width, height, m_lineStride, m_imageData); | ||||
//dup->userData = userData; /* unfortunate */ | //dup->userData = userData; /* unfortunate */ | ||||
@@ -895,7 +897,7 @@ public: | |||||
Typeface::Ptr createTypefaceForFont (const Font& font) | Typeface::Ptr createTypefaceForFont (const Font& font) | ||||
{ | { | ||||
Typeface::Ptr typeFace = 0; | |||||
Typeface::Ptr typeFace = nullptr; | |||||
for (int i=0; i<m_faces.size(); i++) | for (int i=0; i<m_faces.size(); i++) | ||||
{ | { | ||||