Skip to content

Commit

Permalink
move imq from a static library to a shared library (#38)
Browse files Browse the repository at this point in the history
* move imq from a static library to a shared library

* enable -fPIC on linux

* pic

* bug in GCC 5 workaround, see nothings/stb#280

* update travis to use antlr shared library
  • Loading branch information
Sam Bloomberg committed Jan 26, 2017
1 parent ba71834 commit 47e7e10
Show file tree
Hide file tree
Showing 21 changed files with 142 additions and 121 deletions.
2 changes: 1 addition & 1 deletion include/imq/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace imq
}
}

inline bool checkTypesEqual(const QValue& a, const QValue& b)
IMQ_API inline bool checkTypesEqual(const QValue& a, const QValue& b)
{
if (a.getType() != b.getType())
return false;
Expand Down
10 changes: 5 additions & 5 deletions include/imq/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace imq
{
class VMachine;

class Context : public GCObject
class IMQ_API Context : public GCObject
{
public:
Context(VMachine* vm);
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace imq

// A simple form of context. This stores values in an unordered_map and allows both read and write access.
// This type of context is generally used as the root context.
class SimpleContext : public Context
class IMQ_API SimpleContext : public Context
{
public:
SimpleContext(VMachine* vm);
Expand Down Expand Up @@ -80,7 +80,7 @@ namespace imq
QValue returnValue;
};

class RootContext : public Context
class IMQ_API RootContext : public Context
{
public:
RootContext(VMachine* vm);
Expand Down Expand Up @@ -118,7 +118,7 @@ namespace imq
};

// A context that has a parent and passes undefined get/deletes to it.
class SubContext : public Context
class IMQ_API SubContext : public Context
{
public:
SubContext(VMachine* vm, Context* parent);
Expand Down Expand Up @@ -154,7 +154,7 @@ namespace imq
QValue returnValue;
};

class RestrictedSubContext : public SubContext
class IMQ_API RestrictedSubContext : public SubContext
{
public:
RestrictedSubContext(VMachine* vm, Context* parent);
Expand Down
2 changes: 1 addition & 1 deletion include/imq/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "utility.h"

#define IMQ_ERROR_DEF(errName, fmt, ...) \
inline Result errName(__VA_ARGS__) \
inline IMQ_API Result errName(__VA_ARGS__) \
{ \
std::stringstream __ss; \
__ss << fmt; \
Expand Down
48 changes: 24 additions & 24 deletions include/imq/expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace imq
{
class ConstantExpr : public VExpression
class IMQ_API ConstantExpr : public VExpression
{
public:
ConstantExpr(const QValue& value, const VLocation& loc);
Expand All @@ -21,7 +21,7 @@ namespace imq
QValue value;
};

class ColorExpr : public VExpression
class IMQ_API ColorExpr : public VExpression
{
public:
ColorExpr(VExpression* rExpr, VExpression* gExpr, VExpression* bExpr, VExpression* aExpr, const VLocation& loc);
Expand All @@ -37,7 +37,7 @@ namespace imq
VExpression* aExpr;
};

class ListExpr : public VExpression
class IMQ_API ListExpr : public VExpression
{
public:
ListExpr(const std::vector<VExpression*> values, const VLocation& loc);
Expand All @@ -50,7 +50,7 @@ namespace imq
std::vector<VExpression*> values;
};

class TableExpr : public VExpression
class IMQ_API TableExpr : public VExpression
{
public:
TableExpr(const std::vector<std::tuple<VExpression*, VExpression*>> values, const VLocation& loc);
Expand All @@ -63,7 +63,7 @@ namespace imq
std::vector<std::tuple<VExpression*, VExpression*>> values;
};

class RetrieveVariableExpr : public VExpression
class IMQ_API RetrieveVariableExpr : public VExpression
{
public:
RetrieveVariableExpr(const String& variable, const VLocation& loc);
Expand All @@ -76,7 +76,7 @@ namespace imq
String variable;
};

class RetrieveFieldExpr : public VExpression
class IMQ_API RetrieveFieldExpr : public VExpression
{
public:
RetrieveFieldExpr(VExpression* objExpr, const String& field, const VLocation& loc);
Expand All @@ -90,7 +90,7 @@ namespace imq
String field;
};

class RetrieveIndexExpr : public VExpression
class IMQ_API RetrieveIndexExpr : public VExpression
{
public:
RetrieveIndexExpr(VExpression* objExpr, VExpression* indexExpr, const VLocation& loc);
Expand All @@ -104,7 +104,7 @@ namespace imq
VExpression* indexExpr;
};

class CallFunctionExpr : public VExpression
class IMQ_API CallFunctionExpr : public VExpression
{
public:
CallFunctionExpr(VExpression* funcExpr, int32_t argC, VExpression** args, const VLocation& loc);
Expand All @@ -119,7 +119,7 @@ namespace imq
VExpression** args;
};

class SetVariableStm : public VStatement
class IMQ_API SetVariableStm : public VStatement
{
public:
SetVariableStm(const String& variable, VExpression* valueExpr, const VLocation& loc);
Expand All @@ -133,7 +133,7 @@ namespace imq
VExpression* valueExpr;
};

class SetFieldStm : public VStatement
class IMQ_API SetFieldStm : public VStatement
{
public:
SetFieldStm(VExpression* objExpr, const String& field, VExpression* valueExpr, const VLocation& loc);
Expand All @@ -148,7 +148,7 @@ namespace imq
VExpression* valueExpr;
};

class SetIndexStm : public VStatement
class IMQ_API SetIndexStm : public VStatement
{
public:
SetIndexStm(VExpression* objExpr, VExpression* indexExpr, VExpression* valueExpr, const VLocation& loc);
Expand All @@ -163,7 +163,7 @@ namespace imq
VExpression* valueExpr;
};

class DeleteVariableStm : public VStatement
class IMQ_API DeleteVariableStm : public VStatement
{
public:
DeleteVariableStm(const String& variable, const VLocation& loc);
Expand All @@ -176,7 +176,7 @@ namespace imq
String variable;
};

class SelectStm : public VStatement
class IMQ_API SelectStm : public VStatement
{
public:
SelectStm(VExpression* destExpr, VExpression* srcExpr, VExpression* calcExpr, VExpression* whereExpr, VExpression* elseExpr, int32_t coordCount, VExpression** coordsExpr, const VLocation& loc);
Expand All @@ -196,7 +196,7 @@ namespace imq
int32_t coordCount;
};

class DefineInputStm : public VStatement
class IMQ_API DefineInputStm : public VStatement
{
public:
DefineInputStm(const String& name, VExpression* valueExpr, const VLocation& loc);
Expand All @@ -210,7 +210,7 @@ namespace imq
VExpression* valueExpr;
};

class DefineOutputStm : public VStatement
class IMQ_API DefineOutputStm : public VStatement
{
public:
DefineOutputStm(const String& name, VExpression* valueExpr, const VLocation& loc);
Expand All @@ -224,7 +224,7 @@ namespace imq
VExpression* valueExpr;
};

class BranchStm : public VStatement
class IMQ_API BranchStm : public VStatement
{
public:
BranchStm(VExpression* checkExpr, VStatement* trueStm, VStatement* falseStm, const VLocation& loc);
Expand All @@ -239,7 +239,7 @@ namespace imq
VStatement* falseStm;
};

class ForLoopStm : public VStatement
class IMQ_API ForLoopStm : public VStatement
{
public:
ForLoopStm(VStatement* initStm, VExpression* checkExpr, VStatement* incrStm, VStatement* execStm, const VLocation& loc);
Expand All @@ -255,7 +255,7 @@ namespace imq
VStatement* execStm;
};

class WhileLoopStm : public VStatement
class IMQ_API WhileLoopStm : public VStatement
{
public:
WhileLoopStm(VExpression* checkExpr, VStatement* execStm, const VLocation& loc);
Expand All @@ -269,7 +269,7 @@ namespace imq
VStatement* execStm;
};

class InfiniteLoopStm : public VStatement
class IMQ_API InfiniteLoopStm : public VStatement
{
public:
InfiniteLoopStm(VStatement* execStm, const VLocation& loc);
Expand All @@ -282,7 +282,7 @@ namespace imq
VStatement* execStm;
};

class ForEachStm : public VStatement
class IMQ_API ForEachStm : public VStatement
{
public:
ForEachStm(const String& varName, VExpression* iterExpr, VStatement* execStm, const VLocation& loc);
Expand All @@ -297,7 +297,7 @@ namespace imq
VStatement* execStm;
};

class BreakStm : public VStatement
class IMQ_API BreakStm : public VStatement
{
public:
BreakStm(const VLocation& loc);
Expand All @@ -307,7 +307,7 @@ namespace imq
virtual Result execute(Context* context) override;
};

class ReturnStm : public VStatement
class IMQ_API ReturnStm : public VStatement
{
public:
ReturnStm(VExpression* valueExpr, const VLocation& loc);
Expand All @@ -320,7 +320,7 @@ namespace imq
VExpression* valueExpr;
};

class NoOpStm : public VStatement
class IMQ_API NoOpStm : public VStatement
{
public:
NoOpStm(const VLocation& loc);
Expand All @@ -330,7 +330,7 @@ namespace imq
virtual Result execute(Context* context) override;
};

class TernaryExpr : public VExpression
class IMQ_API TernaryExpr : public VExpression
{
public:
TernaryExpr(VExpression* checkExpr, VExpression* trueExpr, VExpression* falseExpr, const VLocation& loc);
Expand Down
10 changes: 5 additions & 5 deletions include/imq/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

namespace imq
{
class GCTraceable
class IMQ_API GCTraceable
{
public:
virtual ~GCTraceable();
virtual void GC_mark() = 0;
};

class GCObject : public GCTraceable
class IMQ_API GCObject : public GCTraceable
{
public:
virtual ~GCObject();
Expand All @@ -43,7 +43,7 @@ namespace imq
bool GC_bMarked = false;
};

enum class GCCollectionMode
enum class IMQ_API GCCollectionMode
{
// Disable barrier functionality altogether and always run collections.
NoBarriers,
Expand All @@ -66,7 +66,7 @@ namespace imq
If too many collection cycles happen in a short period of time, the collection barrier is raised to a new value. On the other hand, if the barrier isn't reached within a certain number of
collect() calls, the barrier is lowered.
*/
class GarbageCollector
class IMQ_API GarbageCollector
{
public:
GarbageCollector();
Expand Down Expand Up @@ -106,7 +106,7 @@ namespace imq
size_t bbufNext = 0;
};

class ScopedRoot
class IMQ_API ScopedRoot
{
public:
ScopedRoot(GarbageCollector* gc, GCTraceable* root);
Expand Down
6 changes: 3 additions & 3 deletions include/imq/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace imq
{
class VMachine;

class QColor : public QObject
class IMQ_API QColor : public QObject
{
IMQ_DECLARE_TYPE(QColor);

Expand Down Expand Up @@ -69,7 +69,7 @@ namespace imq
float alpha;
};

class QImage : public QObject
class IMQ_API QImage : public QObject
{
IMQ_DECLARE_TYPE(QImage);

Expand Down Expand Up @@ -121,7 +121,7 @@ namespace imq
float* data = nullptr;
};

class QImageSelection : public QSelection
class IMQ_API QImageSelection : public QSelection
{
public:
QImageSelection(Context* parent, QImage* source, QImage* dest);
Expand Down
15 changes: 8 additions & 7 deletions include/imq/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "result.h"

#define IMQ_LIB(loadName) imq::Result loadName(imq::VMachine* vm)
#define IMQ_LIB_STD(loadName) IMQ_API imq::Result loadName(imq::VMachine* vm)
#define IMQ_LIB_FUNC(name, func) \
{ \
Result res = vm->getRootContext()->setValue(name, QValue::Function(vm, func)); \
Expand All @@ -24,11 +25,11 @@

namespace imq
{
IMQ_LIB(register_stdlib);
IMQ_LIB(register_system);
IMQ_LIB(register_image);
IMQ_LIB(register_io);
IMQ_LIB(register_math);
IMQ_LIB(register_conversion);
IMQ_LIB(register_gc);
IMQ_LIB_STD(register_stdlib);
IMQ_LIB_STD(register_system);
IMQ_LIB_STD(register_image);
IMQ_LIB_STD(register_io);
IMQ_LIB_STD(register_math);
IMQ_LIB_STD(register_conversion);
IMQ_LIB_STD(register_gc);
}
Loading

0 comments on commit 47e7e10

Please sign in to comment.