aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-12 22:36:09 +0800
committercrupest <crupest@outlook.com>2022-01-12 22:36:09 +0800
commitc409caa8873e25699fc10ae435e8d123685f28f3 (patch)
tree16a0c0696f0e6d4c6856db0b7864652e2779b2b8 /include/cru
parent7a42d92c10a4bc686244668dd0e3f903f30f2fae (diff)
downloadcru-c409caa8873e25699fc10ae435e8d123685f28f3.tar.gz
cru-c409caa8873e25699fc10ae435e8d123685f28f3.tar.bz2
cru-c409caa8873e25699fc10ae435e8d123685f28f3.zip
...
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/PropertyTree.hpp4
-rw-r--r--include/cru/parse/Base.hpp11
-rw-r--r--include/cru/parse/Grammar.hpp2
-rw-r--r--include/cru/parse/Nonterminal.hpp2
-rw-r--r--include/cru/parse/ParsingAlgorithm.hpp2
-rw-r--r--include/cru/parse/ParsingAlgorithmContext.hpp2
-rw-r--r--include/cru/parse/ParsingContext.hpp2
-rw-r--r--include/cru/parse/ParsingTreeNode.hpp2
-rw-r--r--include/cru/parse/Production.hpp2
-rw-r--r--include/cru/parse/RecursiveDescentAlgorithm.hpp2
-rw-r--r--include/cru/parse/RecursiveDescentAlgorithmContext.hpp2
-rw-r--r--include/cru/parse/Symbol.hpp4
-rw-r--r--include/cru/parse/Terminal.hpp2
-rw-r--r--include/cru/parse/TokenType.hpp4
-rw-r--r--include/cru/platform/graphics/Base.hpp11
-rw-r--r--include/cru/platform/graphics/Brush.hpp4
-rw-r--r--include/cru/platform/graphics/Factory.hpp2
-rw-r--r--include/cru/platform/graphics/Font.hpp2
-rw-r--r--include/cru/platform/graphics/Geometry.hpp4
-rw-r--r--include/cru/platform/graphics/NullPainter.hpp2
-rw-r--r--include/cru/platform/graphics/Painter.hpp2
-rw-r--r--include/cru/platform/graphics/Resource.hpp2
-rw-r--r--include/cru/platform/graphics/TextLayout.hpp2
-rw-r--r--include/cru/toml/Base.hpp11
-rw-r--r--include/cru/toml/TomlDocument.hpp6
-rw-r--r--include/cru/toml/TomlParser.hpp4
-rw-r--r--include/cru/win/gui/Window.hpp3
-rw-r--r--include/cru/xml/Base.hpp11
-rw-r--r--include/cru/xml/XmlNode.hpp12
-rw-r--r--include/cru/xml/XmlParser.hpp4
30 files changed, 89 insertions, 36 deletions
diff --git a/include/cru/common/PropertyTree.hpp b/include/cru/common/PropertyTree.hpp
index 01b50dac..613bcc47 100644
--- a/include/cru/common/PropertyTree.hpp
+++ b/include/cru/common/PropertyTree.hpp
@@ -8,7 +8,7 @@
namespace cru {
class PropertyTree;
-class PropertySubTreeRef {
+class CRU_BASE_API PropertySubTreeRef {
public:
static String CombineKey(StringView left, StringView right);
@@ -37,7 +37,7 @@ class PropertySubTreeRef {
String path_;
};
-class PropertyTree {
+class CRU_BASE_API PropertyTree {
public:
static String CombineKey(StringView left, StringView right);
diff --git a/include/cru/parse/Base.hpp b/include/cru/parse/Base.hpp
new file mode 100644
index 00000000..8f3a05e9
--- /dev/null
+++ b/include/cru/parse/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_PARSE_EXPORT_API
+#define CRU_PARSE_API __declspec(dllexport)
+#else
+#define CRU_PARSE_API __declspec(dllimport)
+#endif
+#else
+#define CRU_PARSE_API
+#endif
diff --git a/include/cru/parse/Grammar.hpp b/include/cru/parse/Grammar.hpp
index 606fcc33..8dc1833f 100644
--- a/include/cru/parse/Grammar.hpp
+++ b/include/cru/parse/Grammar.hpp
@@ -5,7 +5,7 @@
#include <vector>
namespace cru::parse {
-class Grammar : public Object {
+class CRU_PARSE_API Grammar : public Object {
public:
Grammar();
diff --git a/include/cru/parse/Nonterminal.hpp b/include/cru/parse/Nonterminal.hpp
index 1bc6f9ff..b01c7c8a 100644
--- a/include/cru/parse/Nonterminal.hpp
+++ b/include/cru/parse/Nonterminal.hpp
@@ -2,7 +2,7 @@
#include "Symbol.hpp"
namespace cru::parse {
-class Nonterminal : public Symbol {
+class CRU_PARSE_API Nonterminal : public Symbol {
public:
Nonterminal(Grammar* grammar, String name);
diff --git a/include/cru/parse/ParsingAlgorithm.hpp b/include/cru/parse/ParsingAlgorithm.hpp
index acca159e..8f38c0ab 100644
--- a/include/cru/parse/ParsingAlgorithm.hpp
+++ b/include/cru/parse/ParsingAlgorithm.hpp
@@ -7,7 +7,7 @@ class ParsingAlgorithmContext;
// Represents a parsing algorithm.
// It does not relate to any specific grammar.
// It is used to validate a grammar and create a parsing algorithm context.
-class ParsingAlgorithm {
+class CRU_PARSE_API ParsingAlgorithm {
public:
ParsingAlgorithm() = default;
diff --git a/include/cru/parse/ParsingAlgorithmContext.hpp b/include/cru/parse/ParsingAlgorithmContext.hpp
index f67ccbbc..b959462c 100644
--- a/include/cru/parse/ParsingAlgorithmContext.hpp
+++ b/include/cru/parse/ParsingAlgorithmContext.hpp
@@ -10,7 +10,7 @@ class ParsingAlgorithm;
// A parsing algorithm context contains all data a parsing algorithm needs to
// parse for a grammar. It does not relate to any input. For example, it can
// contain any state machine.
-class ParsingAlgorithmContext {
+class CRU_PARSE_API ParsingAlgorithmContext {
public:
ParsingAlgorithmContext(Grammar* grammar, const ParsingAlgorithm* algorithm);
diff --git a/include/cru/parse/ParsingContext.hpp b/include/cru/parse/ParsingContext.hpp
index ebb7115a..cfb850b9 100644
--- a/include/cru/parse/ParsingContext.hpp
+++ b/include/cru/parse/ParsingContext.hpp
@@ -5,7 +5,7 @@
namespace cru::parse {
// A parsing context contains all info that a program needs to know when parsing
// a input sequence of terminals.
-class ParsingContext {
+class CRU_PARSE_API ParsingContext {
public:
ParsingContext(const ParsingAlgorithmContext* parsing_algorithm_context,
std::vector<Terminal*> input);
diff --git a/include/cru/parse/ParsingTreeNode.hpp b/include/cru/parse/ParsingTreeNode.hpp
index d1c3d058..7119ca0b 100644
--- a/include/cru/parse/ParsingTreeNode.hpp
+++ b/include/cru/parse/ParsingTreeNode.hpp
@@ -4,7 +4,7 @@
#include <vector>
namespace cru::parse {
-class ParsingTreeNode {
+class CRU_PARSE_API ParsingTreeNode {
public:
ParsingTreeNode(Symbol* symbol, Production* production);
diff --git a/include/cru/parse/Production.hpp b/include/cru/parse/Production.hpp
index 8a1331b9..cb3c79c0 100644
--- a/include/cru/parse/Production.hpp
+++ b/include/cru/parse/Production.hpp
@@ -7,7 +7,7 @@
#include <vector>
namespace cru::parse {
-class Production : public Object {
+class CRU_PARSE_API Production : public Object {
public:
Production(Grammar* grammar, String name, Nonterminal* left,
std::vector<Symbol*> right);
diff --git a/include/cru/parse/RecursiveDescentAlgorithm.hpp b/include/cru/parse/RecursiveDescentAlgorithm.hpp
index c12a84f6..373724ea 100644
--- a/include/cru/parse/RecursiveDescentAlgorithm.hpp
+++ b/include/cru/parse/RecursiveDescentAlgorithm.hpp
@@ -3,7 +3,7 @@
#include "ParsingAlgorithm.hpp"
namespace cru::parse {
-class RecursiveDescentAlgorithm : public ParsingAlgorithm {
+class CRU_PARSE_API RecursiveDescentAlgorithm : public ParsingAlgorithm {
public:
RecursiveDescentAlgorithm() = default;
diff --git a/include/cru/parse/RecursiveDescentAlgorithmContext.hpp b/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
index 1b888da9..b29ee1a1 100644
--- a/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
+++ b/include/cru/parse/RecursiveDescentAlgorithmContext.hpp
@@ -6,7 +6,7 @@
#include "cru/parse/Terminal.hpp"
namespace cru::parse {
-class RecursiveDescentAlgorithmContext : public ParsingAlgorithmContext {
+class CRU_PARSE_API RecursiveDescentAlgorithmContext : public ParsingAlgorithmContext {
public:
RecursiveDescentAlgorithmContext(Grammar* grammar,
const RecursiveDescentAlgorithm* algorithm);
diff --git a/include/cru/parse/Symbol.hpp b/include/cru/parse/Symbol.hpp
index e22fb9bc..7404a5e7 100644
--- a/include/cru/parse/Symbol.hpp
+++ b/include/cru/parse/Symbol.hpp
@@ -1,11 +1,13 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/String.hpp"
namespace cru::parse {
class Grammar;
// Base class of Terminal and Nonterminal.
-class Symbol : public Object {
+class CRU_PARSE_API Symbol : public Object {
public:
explicit Symbol(Grammar* grammar, String name);
diff --git a/include/cru/parse/Terminal.hpp b/include/cru/parse/Terminal.hpp
index 8d4a31b6..4ff8f898 100644
--- a/include/cru/parse/Terminal.hpp
+++ b/include/cru/parse/Terminal.hpp
@@ -2,7 +2,7 @@
#include "Symbol.hpp"
namespace cru::parse {
-class Terminal : public Symbol {
+class CRU_PARSE_API Terminal : public Symbol {
public:
Terminal(Grammar* grammar, String name);
diff --git a/include/cru/parse/TokenType.hpp b/include/cru/parse/TokenType.hpp
index 54bdf712..49415d3b 100644
--- a/include/cru/parse/TokenType.hpp
+++ b/include/cru/parse/TokenType.hpp
@@ -1,9 +1,11 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/Base.hpp"
#include "cru/common/String.hpp"
namespace cru::parse {
-class TokenType : public Object {
+class CRU_PARSE_API TokenType : public Object {
public:
explicit TokenType(String name);
diff --git a/include/cru/platform/graphics/Base.hpp b/include/cru/platform/graphics/Base.hpp
index 26ae725a..3a18e39d 100644
--- a/include/cru/platform/graphics/Base.hpp
+++ b/include/cru/platform/graphics/Base.hpp
@@ -6,6 +6,17 @@
#include <memory>
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_PLATFORM_GRAPHICS_EXPORT_API
+#define CRU_PLATFORM_GRAPHICS_API __declspec(dllexport)
+#else
+#define CRU_PLATFORM_GRAPHICS_API __declspec(dllimport)
+#endif
+#else
+#define CRU_PLATFORM_GRAPHICS_API
+#endif
+
+
namespace cru::platform::graphics {
// forward declarations
struct IGraphicsFactory;
diff --git a/include/cru/platform/graphics/Brush.hpp b/include/cru/platform/graphics/Brush.hpp
index aa21f79d..772edd5c 100644
--- a/include/cru/platform/graphics/Brush.hpp
+++ b/include/cru/platform/graphics/Brush.hpp
@@ -2,9 +2,9 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IBrush : virtual IGraphicsResource {};
+struct CRU_PLATFORM_GRAPHICS_API IBrush : virtual IGraphicsResource {};
-struct ISolidColorBrush : virtual IBrush {
+struct CRU_PLATFORM_GRAPHICS_API ISolidColorBrush : virtual IBrush {
virtual Color GetColor() = 0;
virtual void SetColor(const Color& color) = 0;
};
diff --git a/include/cru/platform/graphics/Factory.hpp b/include/cru/platform/graphics/Factory.hpp
index b79e1c4f..f3802651 100644
--- a/include/cru/platform/graphics/Factory.hpp
+++ b/include/cru/platform/graphics/Factory.hpp
@@ -8,7 +8,7 @@
namespace cru::platform::graphics {
// Entry point of the graphics module.
-struct IGraphicsFactory : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IGraphicsFactory : virtual IPlatformResource {
virtual std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() = 0;
virtual std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() = 0;
diff --git a/include/cru/platform/graphics/Font.hpp b/include/cru/platform/graphics/Font.hpp
index e1a419eb..2d1bc9a6 100644
--- a/include/cru/platform/graphics/Font.hpp
+++ b/include/cru/platform/graphics/Font.hpp
@@ -2,7 +2,7 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IFont : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IFont : virtual IGraphicsResource {
virtual float GetFontSize() = 0;
};
} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/Geometry.hpp b/include/cru/platform/graphics/Geometry.hpp
index f01132fb..e83d1c51 100644
--- a/include/cru/platform/graphics/Geometry.hpp
+++ b/include/cru/platform/graphics/Geometry.hpp
@@ -2,13 +2,13 @@
#include "Resource.hpp"
namespace cru::platform::graphics {
-struct IGeometry : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IGeometry : virtual IGraphicsResource {
virtual bool FillContains(const Point& point) = 0;
};
// After called Build, calling every method will throw a
-struct IGeometryBuilder : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API IGeometryBuilder : virtual IGraphicsResource {
virtual void BeginFigure(const Point& point) = 0;
virtual void LineTo(const Point& point) = 0;
virtual void QuadraticBezierTo(const Point& control_point,
diff --git a/include/cru/platform/graphics/NullPainter.hpp b/include/cru/platform/graphics/NullPainter.hpp
index 7889f99e..b5c796d3 100644
--- a/include/cru/platform/graphics/NullPainter.hpp
+++ b/include/cru/platform/graphics/NullPainter.hpp
@@ -3,7 +3,7 @@
#include "cru/common/Base.hpp"
namespace cru::platform::graphics {
-class NullPainter : public Object, public virtual IPainter {
+class CRU_PLATFORM_GRAPHICS_API NullPainter : public Object, public virtual IPainter {
public:
NullPainter() = default;
diff --git a/include/cru/platform/graphics/Painter.hpp b/include/cru/platform/graphics/Painter.hpp
index 552a3307..4104a752 100644
--- a/include/cru/platform/graphics/Painter.hpp
+++ b/include/cru/platform/graphics/Painter.hpp
@@ -3,7 +3,7 @@
namespace cru::platform::graphics {
-struct IPainter : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IPainter : virtual IPlatformResource {
virtual Matrix GetTransform() = 0;
virtual void SetTransform(const Matrix& matrix) = 0;
diff --git a/include/cru/platform/graphics/Resource.hpp b/include/cru/platform/graphics/Resource.hpp
index cd1e5283..e559b0e9 100644
--- a/include/cru/platform/graphics/Resource.hpp
+++ b/include/cru/platform/graphics/Resource.hpp
@@ -4,7 +4,7 @@
namespace cru::platform::graphics {
struct IGraphicsFactory;
-struct IGraphicsResource : virtual IPlatformResource {
+struct CRU_PLATFORM_GRAPHICS_API IGraphicsResource : virtual IPlatformResource {
virtual IGraphicsFactory* GetGraphicsFactory() = 0;
};
} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/TextLayout.hpp b/include/cru/platform/graphics/TextLayout.hpp
index a040ec3b..f9ccc824 100644
--- a/include/cru/platform/graphics/TextLayout.hpp
+++ b/include/cru/platform/graphics/TextLayout.hpp
@@ -7,7 +7,7 @@
namespace cru::platform::graphics {
// Requirement:
// All text must be left-top aligned.
-struct ITextLayout : virtual IGraphicsResource {
+struct CRU_PLATFORM_GRAPHICS_API ITextLayout : virtual IGraphicsResource {
virtual String GetText() = 0;
virtual void SetText(String new_text) = 0;
diff --git a/include/cru/toml/Base.hpp b/include/cru/toml/Base.hpp
new file mode 100644
index 00000000..de1d558c
--- /dev/null
+++ b/include/cru/toml/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_TOML_EXPORT_API
+#define CRU_TOML_API __declspec(dllexport)
+#else
+#define CRU_TOML_API __declspec(dllimport)
+#endif
+#else
+#define CRU_TOML_API
+#endif
diff --git a/include/cru/toml/TomlDocument.hpp b/include/cru/toml/TomlDocument.hpp
index 637690f7..1e5caf71 100644
--- a/include/cru/toml/TomlDocument.hpp
+++ b/include/cru/toml/TomlDocument.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/Base.hpp"
#include "cru/common/String.hpp"
@@ -7,7 +9,7 @@
#include <unordered_map>
namespace cru::toml {
-class TomlSection {
+class CRU_TOML_API TomlSection {
public:
CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlSection)
CRU_DEFAULT_COPY(TomlSection)
@@ -29,7 +31,7 @@ class TomlSection {
std::unordered_map<String, String> values_;
};
-class TomlDocument {
+class CRU_TOML_API TomlDocument {
public:
CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlDocument)
CRU_DEFAULT_COPY(TomlDocument)
diff --git a/include/cru/toml/TomlParser.hpp b/include/cru/toml/TomlParser.hpp
index 52332506..c3091bad 100644
--- a/include/cru/toml/TomlParser.hpp
+++ b/include/cru/toml/TomlParser.hpp
@@ -7,12 +7,12 @@
namespace cru::toml {
// A very simple and tolerant TOML parser.
-class TomlParsingException : public Exception {
+class CRU_TOML_API TomlParsingException : public Exception {
public:
using Exception::Exception;
};
-class TomlParser {
+class CRU_TOML_API TomlParser {
public:
explicit TomlParser(String input);
diff --git a/include/cru/win/gui/Window.hpp b/include/cru/win/gui/Window.hpp
index 5ce3ed25..7a982da7 100644
--- a/include/cru/win/gui/Window.hpp
+++ b/include/cru/win/gui/Window.hpp
@@ -44,7 +44,6 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
// Set the rect of the window containing frame.
// The lefttop of the rect is relative to screen lefttop.
- // TODO: Known limitation: can't calc client rect and save.
void SetWindowRect(const Rect& rect) override;
bool RequestFocus() override;
@@ -149,8 +148,10 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
//*************** region: native messages ***************
+ void OnCreateInternal();
void OnDestroyInternal();
void OnPaintInternal();
+ void OnMoveInternal(int new_left, int new_top);
void OnResizeInternal(int new_width, int new_height);
void OnSetFocusInternal();
diff --git a/include/cru/xml/Base.hpp b/include/cru/xml/Base.hpp
new file mode 100644
index 00000000..5d6fe144
--- /dev/null
+++ b/include/cru/xml/Base.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef CRU_PLATFORM_WINDOWS
+#ifdef CRU_XML_EXPORT_API
+#define CRU_XML_API __declspec(dllexport)
+#else
+#define CRU_XML_API __declspec(dllimport)
+#endif
+#else
+#define CRU_XML_API
+#endif
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp
index cf2543c9..38f09d14 100644
--- a/include/cru/xml/XmlNode.hpp
+++ b/include/cru/xml/XmlNode.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "Base.hpp"
+
#include "cru/common/String.hpp"
#include <algorithm>
@@ -10,7 +12,7 @@ namespace cru::xml {
class XmlElementNode;
class XmlTextNode;
-class XmlNode {
+class CRU_XML_API XmlNode {
friend XmlElementNode;
public:
@@ -40,7 +42,7 @@ class XmlNode {
XmlElementNode* parent_ = nullptr;
};
-class XmlTextNode : public XmlNode {
+class CRU_XML_API XmlTextNode : public XmlNode {
public:
XmlTextNode() : XmlNode(Type::Text) {}
explicit XmlTextNode(String text)
@@ -61,7 +63,7 @@ class XmlTextNode : public XmlNode {
String text_;
};
-class XmlElementNode : public XmlNode {
+class CRU_XML_API XmlElementNode : public XmlNode {
public:
XmlElementNode() : XmlNode(Type::Element) {}
explicit XmlElementNode(String tag,
@@ -86,9 +88,9 @@ class XmlElementNode : public XmlNode {
}
const std::vector<XmlNode*> GetChildren() const { return children_; }
- int GetChildCount() const { return children_.size(); }
+ Index GetChildCount() const { return children_.size(); }
String GetAttribute(const String& key) const { return attributes_.at(key); }
- XmlNode* GetChildAt(int index) const { return children_[index]; }
+ XmlNode* GetChildAt(Index index) const { return children_[index]; }
void AddAttribute(String key, String value);
void AddChild(XmlNode* child);
diff --git a/include/cru/xml/XmlParser.hpp b/include/cru/xml/XmlParser.hpp
index 188a08f2..e916cc53 100644
--- a/include/cru/xml/XmlParser.hpp
+++ b/include/cru/xml/XmlParser.hpp
@@ -8,12 +8,12 @@
#include <optional>
namespace cru::xml {
-class XmlParsingException : public Exception {
+class CRU_XML_API XmlParsingException : public Exception {
public:
using Exception::Exception;
};
-class XmlParser {
+class CRU_XML_API XmlParser {
public:
explicit XmlParser(String xml);