Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update protoplug
  • Loading branch information
falkTX committed Aug 24, 2017
1 parent b2d5cd5 commit 40ca182
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ports/protoplug/Source/BinaryData.h
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions ports/protoplug/Source/JucePluginCharacteristics.h
Expand Up @@ -29,6 +29,8 @@
#define JucePlugin_LV2URI "http://www.osar.fr/protoplug#gen"
#endif

#define JucePlugin_IsMidiEffect 0

#define JucePlugin_WantsLV2State 1
#define JucePlugin_WantsLV2TimePos 1
#define JucePlugin_WantsLV2Presets 0
Expand Down
25 changes: 24 additions & 1 deletion ports/protoplug/Source/LuaLink.cpp
Expand Up @@ -3,6 +3,7 @@
#include "PluginEditor.h"
#include "ProtoplugDir.h"
#include <map>
#include <cstdarg>

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

// adapted from Lua 5.1 lbaselib.c
static int LuaWriteLine (protolua::lua_State *L) {
LuaLink *luli = globalStates[L];
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;
}

Expand Down Expand Up @@ -51,6 +67,7 @@ void LuaLink::initProtoplugDir() {
}

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)
log = log.substring(log.length()-3000);
Time t = Time::getCurrentTime();
Expand Down Expand Up @@ -262,7 +279,11 @@ int LuaLink::startVarargOverride(const char *fname, va_list _args)
ls->pushstring(va_arg(_args, char*));
break;
default:
#if DEBUG
juce_breakDebugger;
#else
break;
#endif
}
}
return numArgs;
Expand Down Expand Up @@ -388,6 +409,8 @@ void LuaLink::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages,
buffer.clear (channel, 0, buffer.getNumSamples());
}
}
#else
ignoreUnused(res);
#endif
}

Expand Down
10 changes: 8 additions & 2 deletions ports/protoplug/Source/LuaState.cpp
Expand Up @@ -17,6 +17,7 @@ ptr_lua_gettop LuaState::lua_gettop = 0;
ptr_lua_settop LuaState::lua_settop = 0;
ptr_lua_pcall LuaState::lua_pcall = 0;
ptr_lua_getfield LuaState::lua_getfield = 0;
ptr_lua_pushvalue LuaState::lua_pushvalue = 0;
ptr_lua_pushlightuserdata LuaState::lua_pushlightuserdata = 0;
ptr_lua_pushstring LuaState::lua_pushstring = 0;
ptr_lua_pushnumber LuaState::lua_pushnumber = 0;
Expand Down Expand Up @@ -61,6 +62,7 @@ LuaState::LuaState(File defaultDir)
lua_settop = ptr_lua_settop (dll->getFunction("lua_settop"));
lua_pcall = ptr_lua_pcall (dll->getFunction("lua_pcall"));
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_pushstring = ptr_lua_pushstring (dll->getFunction("lua_pushstring"));
lua_pushnumber = ptr_lua_pushnumber (dll->getFunction("lua_pushnumber"));
Expand All @@ -75,7 +77,7 @@ LuaState::LuaState(File defaultDir)
luajit_setmode = ptr_luajit_setmode (dll->getFunction("luaJIT_setmode"));
#endif
}
void *kk[23] = {
void *kk[24] = {
// cast required for some compilers
(void*)luaL_newstate,
(void*)luaL_openlibs,
Expand All @@ -90,6 +92,7 @@ LuaState::LuaState(File defaultDir)
(void*)lua_settop,
(void*)lua_pcall,
(void*)lua_getfield,
(void*)lua_pushvalue,
(void*)lua_pushlightuserdata,
(void*)lua_pushstring,
(void*)lua_pushnumber,
Expand All @@ -100,7 +103,7 @@ LuaState::LuaState(File defaultDir)
(void*)lua_isnumber,
(void*)lua_typename,
(void*)lua_newuserdata};
for (int i=0; i<23; i++)
for (int i=0; i<24; i++)
if (kk[i]==0) {
failed = 1;
errmsg = "Error: Could not load " + libName +
Expand Down Expand Up @@ -161,6 +164,9 @@ int LuaState::pcall(int nargs, int nresults, int errfunc)
void LuaState::getfield(int idx, const char *k)
{ (*lua_getfield)(l, idx, k);}

void LuaState::pushvalue(int idx)
{ (*lua_pushvalue)(l, idx);}

void LuaState::pushlightuserdata(void *p)
{ (*lua_pushlightuserdata)(l, p);}

Expand Down
3 changes: 3 additions & 0 deletions ports/protoplug/Source/LuaState.h
Expand Up @@ -37,6 +37,7 @@ typedef int (*ptr_lua_gettop) (lua_State *L);
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 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_pushstring) (lua_State *L, const char *s);
typedef void (*ptr_lua_pushnumber) (lua_State *L, lua_Number n);
Expand Down Expand Up @@ -73,6 +74,7 @@ class LuaState
void settop(int idx);
int pcall(int nargs, int nresults, int errfunc);
void getfield(int idx, const char *k);
void pushvalue(int idx);
void pushlightuserdata(void *p);
void pushstring(const char *s);
void pushnumber(lua_Number n);
Expand Down Expand Up @@ -124,6 +126,7 @@ class LuaState
static ptr_lua_settop lua_settop;
static ptr_lua_pcall lua_pcall;
static ptr_lua_getfield lua_getfield;
static ptr_lua_pushvalue lua_pushvalue;
static ptr_lua_pushlightuserdata lua_pushlightuserdata;
static ptr_lua_pushstring lua_pushstring;
static ptr_lua_pushnumber lua_pushnumber;
Expand Down
2 changes: 1 addition & 1 deletion ports/protoplug/Source/exports/pGraphics.h
Expand Up @@ -180,7 +180,7 @@ PROTO_API void Graphics_drawRoundedRectangle2(pGraphics self, exRectangle_fl


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)
Expand Down
3 changes: 2 additions & 1 deletion ports/protoplug/Source/exports/pLagrangeInterpolator.h
Expand Up @@ -16,7 +16,8 @@
PROTO_API exLagrangeInterpolator LagrangeInterpolator_create()
{
LagrangeInterpolator li;
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)(&li)); // look away children
LagrangeInterpolator* liptr = &li;
exLagrangeInterpolator ret(*(exLagrangeInterpolator*)liptr); // look away children
return ret;
}

Expand Down
16 changes: 9 additions & 7 deletions ports/protoplug/Source/vflib/vf_FreeTypeFaces.cpp
Expand Up @@ -68,6 +68,8 @@ class FreeTypeLibrary : public ReferenceCountedObject
FT_Error result;

result = FT_Init_FreeType (&m_ft);

ignoreUnused(result);
}

~FreeTypeLibrary ()
Expand Down Expand Up @@ -136,19 +138,19 @@ class FreeTypeFace : public CustomTypeface
};
#endif

protected:
FT_Face m_face;
int m_loadFlags;

private:
FreeTypeLibrary::Ptr m_ft;
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines
float m_minHintedHeight;
float m_maxHintedHeight;
bool m_useFreeTypeRendering; // true to use FreeType to render the outlines
float m_scale;
float m_kerningScale;
int m_kerningMode;

protected:
FT_Face m_face;
int m_loadFlags;

public:
FreeTypeFace (float minHintedHeight,
float maxHintedHeight,
Expand Down Expand Up @@ -630,7 +632,7 @@ class FreeTypeFace : public CustomTypeface
return 0;
}

ImagePixelData* clone()
Ptr clone()
{
ImagePixelData* dup = new GlyphImage (width, height, m_lineStride, m_imageData);
//dup->userData = userData; /* unfortunate */
Expand Down Expand Up @@ -895,7 +897,7 @@ class FreeTypeFacesImplementation : public DeletedAtShutdown

Typeface::Ptr createTypefaceForFont (const Font& font)
{
Typeface::Ptr typeFace = 0;
Typeface::Ptr typeFace = nullptr;

for (int i=0; i<m_faces.size(); i++)
{
Expand Down

0 comments on commit 40ca182

Please sign in to comment.