Skip to content

Commit 40ca182

Browse files
author
falkTX
committed
Update protoplug
1 parent b2d5cd5 commit 40ca182

File tree

8 files changed

+51
-14
lines changed

8 files changed

+51
-14
lines changed

ports/protoplug/Source/BinaryData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
*/
66

7-
#ifndef BINARYDATA_H_17170897_INCLUDED
8-
#define BINARYDATA_H_17170897_INCLUDED
7+
#ifndef BINARYDATA_H_15459638_INCLUDED
8+
#define BINARYDATA_H_15459638_INCLUDED
99

1010
namespace BinaryData
1111
{

ports/protoplug/Source/JucePluginCharacteristics.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#define JucePlugin_LV2URI "http://www.osar.fr/protoplug#gen"
3030
#endif
3131

32+
#define JucePlugin_IsMidiEffect 0
33+
3234
#define JucePlugin_WantsLV2State 1
3335
#define JucePlugin_WantsLV2TimePos 1
3436
#define JucePlugin_WantsLV2Presets 0

ports/protoplug/Source/LuaLink.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "PluginEditor.h"
44
#include "ProtoplugDir.h"
55
#include <map>
6+
#include <cstdarg>
67

78
// exports for scripts
89
extern "C" {
@@ -12,10 +13,25 @@ extern "C" {
1213
// could be avoided by namespacing every callback into a userdata (eg. theme api)
1314
std::map<protolua::lua_State*, LuaLink*> globalStates;
1415

16+
// adapted from Lua 5.1 lbaselib.c
1517
static int LuaWriteLine (protolua::lua_State *L) {
1618
LuaLink *luli = globalStates[L];
1719
if (!luli) return 0;
18-
luli->addToLog(luli->ls->tolstring(1, 0));
20+
String logLine;
21+
int n = luli->ls->gettop(); // number of arguments
22+
int i;
23+
luli->ls->getglobal("tostring");
24+
for (i=1; i<=n; i++) {
25+
const char *s;
26+
luli->ls->pushvalue(-1); // function to be called
27+
luli->ls->pushvalue(i); // value to print
28+
luli->ls->pcall(1, 1, 0);
29+
s = luli->ls->tostring(-1); // get result
30+
if (i>1) logLine += "\t";
31+
logLine += (s == NULL) ? "<cannot convert to string>" : s;
32+
luli->ls->pop(1); // pop result
33+
}
34+
luli->addToLog(logLine);
1935
return 0;
2036
}
2137

@@ -51,6 +67,7 @@ void LuaLink::initProtoplugDir() {
5167
}
5268

5369
void LuaLink::addToLog(String buf, bool isInput /*= false*/) {
70+
buf = buf.replace("\t", " "); // TODO this does not line up like real tabs, obviously...
5471
if (log.length()>4000)
5572
log = log.substring(log.length()-3000);
5673
Time t = Time::getCurrentTime();
@@ -262,7 +279,11 @@ int LuaLink::startVarargOverride(const char *fname, va_list _args)
262279
ls->pushstring(va_arg(_args, char*));
263280
break;
264281
default:
282+
#if DEBUG
265283
juce_breakDebugger;
284+
#else
285+
break;
286+
#endif
266287
}
267288
}
268289
return numArgs;
@@ -388,6 +409,8 @@ void LuaLink::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages,
388409
buffer.clear (channel, 0, buffer.getNumSamples());
389410
}
390411
}
412+
#else
413+
ignoreUnused(res);
391414
#endif
392415
}
393416

ports/protoplug/Source/LuaState.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ptr_lua_gettop LuaState::lua_gettop = 0;
1717
ptr_lua_settop LuaState::lua_settop = 0;
1818
ptr_lua_pcall LuaState::lua_pcall = 0;
1919
ptr_lua_getfield LuaState::lua_getfield = 0;
20+
ptr_lua_pushvalue LuaState::lua_pushvalue = 0;
2021
ptr_lua_pushlightuserdata LuaState::lua_pushlightuserdata = 0;
2122
ptr_lua_pushstring LuaState::lua_pushstring = 0;
2223
ptr_lua_pushnumber LuaState::lua_pushnumber = 0;
@@ -61,6 +62,7 @@ LuaState::LuaState(File defaultDir)
6162
lua_settop = ptr_lua_settop (dll->getFunction("lua_settop"));
6263
lua_pcall = ptr_lua_pcall (dll->getFunction("lua_pcall"));
6364
lua_getfield = ptr_lua_getfield (dll->getFunction("lua_getfield"));
65+
lua_pushvalue = ptr_lua_pushvalue (dll->getFunction("lua_pushvalue"));
6466
lua_pushlightuserdata = ptr_lua_pushlightuserdata (dll->getFunction("lua_pushlightuserdata"));
6567
lua_pushstring = ptr_lua_pushstring (dll->getFunction("lua_pushstring"));
6668
lua_pushnumber = ptr_lua_pushnumber (dll->getFunction("lua_pushnumber"));
@@ -75,7 +77,7 @@ LuaState::LuaState(File defaultDir)
7577
luajit_setmode = ptr_luajit_setmode (dll->getFunction("luaJIT_setmode"));
7678
#endif
7779
}
78-
void *kk[23] = {
80+
void *kk[24] = {
7981
// cast required for some compilers
8082
(void*)luaL_newstate,
8183
(void*)luaL_openlibs,
@@ -90,6 +92,7 @@ LuaState::LuaState(File defaultDir)
9092
(void*)lua_settop,
9193
(void*)lua_pcall,
9294
(void*)lua_getfield,
95+
(void*)lua_pushvalue,
9396
(void*)lua_pushlightuserdata,
9497
(void*)lua_pushstring,
9598
(void*)lua_pushnumber,
@@ -100,7 +103,7 @@ LuaState::LuaState(File defaultDir)
100103
(void*)lua_isnumber,
101104
(void*)lua_typename,
102105
(void*)lua_newuserdata};
103-
for (int i=0; i<23; i++)
106+
for (int i=0; i<24; i++)
104107
if (kk[i]==0) {
105108
failed = 1;
106109
errmsg = "Error: Could not load " + libName +
@@ -161,6 +164,9 @@ int LuaState::pcall(int nargs, int nresults, int errfunc)
161164
void LuaState::getfield(int idx, const char *k)
162165
{ (*lua_getfield)(l, idx, k);}
163166

167+
void LuaState::pushvalue(int idx)
168+
{ (*lua_pushvalue)(l, idx);}
169+
164170
void LuaState::pushlightuserdata(void *p)
165171
{ (*lua_pushlightuserdata)(l, p);}
166172

ports/protoplug/Source/LuaState.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef int (*ptr_lua_gettop) (lua_State *L);
3737
typedef void (*ptr_lua_settop) (lua_State *L, int idx);
3838
typedef int (*ptr_lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
3939
typedef void (*ptr_lua_getfield) (lua_State *L, int idx, const char *k);
40+
typedef void (*ptr_lua_pushvalue) (lua_State *L, int idx);
4041
typedef void (*ptr_lua_pushlightuserdata)(lua_State *L, void *p);
4142
typedef void (*ptr_lua_pushstring) (lua_State *L, const char *s);
4243
typedef void (*ptr_lua_pushnumber) (lua_State *L, lua_Number n);
@@ -73,6 +74,7 @@ class LuaState
7374
void settop(int idx);
7475
int pcall(int nargs, int nresults, int errfunc);
7576
void getfield(int idx, const char *k);
77+
void pushvalue(int idx);
7678
void pushlightuserdata(void *p);
7779
void pushstring(const char *s);
7880
void pushnumber(lua_Number n);
@@ -124,6 +126,7 @@ class LuaState
124126
static ptr_lua_settop lua_settop;
125127
static ptr_lua_pcall lua_pcall;
126128
static ptr_lua_getfield lua_getfield;
129+
static ptr_lua_pushvalue lua_pushvalue;
127130
static ptr_lua_pushlightuserdata lua_pushlightuserdata;
128131
static ptr_lua_pushstring lua_pushstring;
129132
static ptr_lua_pushnumber lua_pushnumber;

ports/protoplug/Source/exports/pGraphics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ PROTO_API void Graphics_drawRoundedRectangle2(pGraphics self, exRectangle_fl
180180

181181

182182
PROTO_API void Graphics_setPixel(pGraphics self, int x, int y)
183-
{ self.g->setPixel(x, y); }
183+
{ self.g->fillRect(x, y, 1, 1); }
184184

185185

186186
PROTO_API void Graphics_fillEllipse(pGraphics self, float x, float y, float width, float height)

ports/protoplug/Source/exports/pLagrangeInterpolator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
PROTO_API exLagrangeInterpolator LagrangeInterpolator_create()
1717
{
1818
LagrangeInterpolator li;
19-
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)(&li)); // look away children
19+
LagrangeInterpolator* liptr = &li;
20+
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)liptr); // look away children
2021
return ret;
2122
}
2223

ports/protoplug/Source/vflib/vf_FreeTypeFaces.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class FreeTypeLibrary : public ReferenceCountedObject
6868
FT_Error result;
6969

7070
result = FT_Init_FreeType (&m_ft);
71+
72+
ignoreUnused(result);
7173
}
7274

7375
~FreeTypeLibrary ()
@@ -136,19 +138,19 @@ class FreeTypeFace : public CustomTypeface
136138
};
137139
#endif
138140

141+
protected:
142+
FT_Face m_face;
143+
int m_loadFlags;
144+
139145
private:
140146
FreeTypeLibrary::Ptr m_ft;
141-
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines
142147
float m_minHintedHeight;
143148
float m_maxHintedHeight;
149+
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines
144150
float m_scale;
145151
float m_kerningScale;
146152
int m_kerningMode;
147153

148-
protected:
149-
FT_Face m_face;
150-
int m_loadFlags;
151-
152154
public:
153155
FreeTypeFace (float minHintedHeight,
154156
float maxHintedHeight,
@@ -630,7 +632,7 @@ class FreeTypeFace : public CustomTypeface
630632
return 0;
631633
}
632634

633-
ImagePixelData* clone()
635+
Ptr clone()
634636
{
635637
ImagePixelData* dup = new GlyphImage (width, height, m_lineStride, m_imageData);
636638
//dup->userData = userData; /* unfortunate */
@@ -895,7 +897,7 @@ class FreeTypeFacesImplementation : public DeletedAtShutdown
895897

896898
Typeface::Ptr createTypefaceForFont (const Font& font)
897899
{
898-
Typeface::Ptr typeFace = 0;
900+
Typeface::Ptr typeFace = nullptr;
899901

900902
for (int i=0; i<m_faces.size(); i++)
901903
{

0 commit comments

Comments
 (0)