summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-09 19:55:28 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-09 19:55:28 +0800
commita1e538564d4b2a60be70a32ec39afdba249ce37d (patch)
tree98ff5e3531bf8c70369dc846c0d653e4ea878128
parent982495a8ee6932f4a1586faf0c853ebaf951000f (diff)
Add support for Emscripten
-rw-r--r--CMakeLists.txt24
-rw-r--r--admin.cxx3
-rw-r--r--catalog.cxx1
-rw-r--r--client.cxx14
m---------libicclient0
-rw-r--r--member.cxx3
-rw-r--r--qicclient/admin.hxx4
-rw-r--r--qicclient/client.hxx15
-rw-r--r--qicclient/member.hxx4
9 files changed, 44 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 852c035..15a39d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,21 +6,33 @@ find_package(Qt5Core)
set(HDRS
${PROJECT_NAME}/product.hxx
${PROJECT_NAME}/catalog.hxx
- ${PROJECT_NAME}/ord.hxx
- ${PROJECT_NAME}/member.hxx
- ${PROJECT_NAME}/admin.hxx
${PROJECT_NAME}/client.hxx
)
+if (NOT EMSCRIPTEN)
+ set(HDRS
+ ${HDRS}
+ ${PROJECT_NAME}/ord.hxx
+ ${PROJECT_NAME}/member.hxx
+ ${PROJECT_NAME}/admin.hxx
+ )
+endif()
+
set(SRCS
${HDRS}
catalog.cxx
- ord.cxx
- member.cxx
- admin.cxx
client.cxx
)
+if (NOT EMSCRIPTEN)
+ set(SRCS
+ ${SRCS}
+ ord.cxx
+ member.cxx
+ admin.cxx
+ )
+endif()
+
if (EMSCRIPTEN OR IOS)
add_library(${PROJECT_NAME} STATIC ${SRCS})
else()
diff --git a/admin.cxx b/admin.cxx
index f59082f..97f036e 100644
--- a/admin.cxx
+++ b/admin.cxx
@@ -1,5 +1,6 @@
#include <cstddef>
#include <memory>
+#include <icclient/typedefs.h>
#include <icclient/admin.h>
#include "qicclient/admin.hxx"
@@ -8,7 +9,7 @@ namespace QICClient {
std::shared_ptr<Admin> Admin::logIn(QString const& username,
QString const& password, QString const& successPage,
QString const& nextPage, QString const& failPage,
- size_t (*handler)(void*, size_t, size_t, void*))
+ icclient_handler handler)
{
auto admin = new Admin{};
admin->setData(icclient_admin_login(username.toLatin1().constData(),
diff --git a/catalog.cxx b/catalog.cxx
index a4bf800..2fdd826 100644
--- a/catalog.cxx
+++ b/catalog.cxx
@@ -1,5 +1,6 @@
#include <cstddef>
#include <icclient/catalog.h>
+#include <icclient/typedefs.h>
#include <icclient/client.h>
#include "qicclient/catalog.hxx"
diff --git a/client.cxx b/client.cxx
index edb1c84..ff28eaa 100644
--- a/client.cxx
+++ b/client.cxx
@@ -1,10 +1,12 @@
#include <cstddef>
#include <memory>
#include <QObject>
+#include <icclient/typedefs.h>
#include <icclient/client.h>
-#include <icclient/member.h>
#include "qicclient/catalog.hxx"
+#ifndef __EMSCRIPTEN__
#include "qicclient/ord.hxx"
+#endif
#include "qicclient/client.hxx"
namespace QICClient {
@@ -19,29 +21,28 @@ namespace QICClient {
icclient_cleanup();
}
- void Client::results(QString const& prodGroup,
- size_t (*handler)(void*, size_t, size_t, void*))
+ void Client::results(QString const& prodGroup, icclient_handler handler)
{
icclient_catalog* catalog = nullptr;
icclient_results(prodGroup.toLatin1().constData(), handler, &catalog);
if (catalog) emit gotResults(new Catalog{catalog});
}
- void Client::allProducts(size_t (*handler)(void*, size_t, size_t, void*))
+ void Client::allProducts(icclient_handler handler)
{
icclient_catalog* catalog = nullptr;
icclient_allproducts(handler, &catalog);
if (catalog) emit gotResults(new Catalog{catalog});
}
- void Client::flyPage(QString const& sku,
- size_t (*handler)(void*, size_t, size_t, void*))
+ void Client::flyPage(QString const& sku,icclient_handler handler)
{
icclient_product* product = nullptr;
icclient_flypage(sku.toLatin1().constData(), handler, &product);
if (product) emit gotFlyPage(shared_ptr<Product>{new Product{product}});
}
+#ifndef __EMSCRIPTEN__
void Client::order(QString const& sku, Catalog const& catalog, Ord& order)
{
auto c_order = order.data();
@@ -49,5 +50,6 @@ namespace QICClient {
&c_order);
order.setData(c_order);
}
+#endif
}
diff --git a/libicclient b/libicclient
-Subproject 37b3483ea690318b9dfcbc840bfc8dd0d959b64
+Subproject c6e5f421e2738b6005f6c3da6700b1343214f7e
diff --git a/member.cxx b/member.cxx
index 82222bb..bd7b02f 100644
--- a/member.cxx
+++ b/member.cxx
@@ -1,5 +1,6 @@
#include <cstddef>
#include <memory>
+#include <icclient/typedefs.h>
#include <icclient/member.h>
#include "qicclient/member.hxx"
@@ -8,7 +9,7 @@ namespace QICClient {
std::shared_ptr<Member> Member::logIn(QString const& username,
QString const& password, QString const& successPage,
QString const& nextPage, QString const& failPage,
- size_t (*handler)(void*, size_t, size_t, void*))
+ icclient_handler handler)
{
auto member = new Member{};
member->setData(icclient_member_login(username.toLatin1().constData(),
diff --git a/qicclient/admin.hxx b/qicclient/admin.hxx
index f19f167..c123a2d 100644
--- a/qicclient/admin.hxx
+++ b/qicclient/admin.hxx
@@ -2,6 +2,7 @@
#define QICCLIENT_ADMIN_HXX
#include <QObject>
+#include <icclient/typedefs.h>
#include <icclient/admin.h>
struct icclient_admin;
@@ -31,8 +32,7 @@ namespace QICClient {
QString const& successPage = nullptr,
QString const& nextPage = nullptr,
QString const& failPage = nullptr,
- size_t (*handler)(void*, size_t, size_t,
- void*) = nullptr);
+ icclient_handler handler = nullptr);
QString const& userName() const { return m_userName; }
QString const& password() const { return m_password; }
diff --git a/qicclient/client.hxx b/qicclient/client.hxx
index 488a093..dfe1888 100644
--- a/qicclient/client.hxx
+++ b/qicclient/client.hxx
@@ -2,12 +2,15 @@
#define QICCLIENT_CLIENT_HXX
#include <QObject>
+#include <icclient/typedefs.h>
namespace QICClient {
using std::shared_ptr;
class Catalog;
+#ifndef __EMSCRIPTEN__
class Ord;
+#endif
class Client : public QObject
{
@@ -27,23 +30,22 @@ namespace QICClient {
* \param prodGroup The name of the product group.
* \param handler A pointer to a cURL write function callback.
*/
- void results(QString const& prodGroup,
- size_t (*handler)(void*, size_t, size_t, void*));
+ void results(QString const& prodGroup, icclient_handler handler);
/*!
* \brief For fetching data about all active products.
* \param handler A pointer to a cURL write function callback.
*/
- void allProducts(size_t (*handler)(void*, size_t, size_t, void*));
+ void allProducts(icclient_handler handler);
/*!
* \brief For fetching data about a specific product.
* \param sku The SKU of the item to order.
* \param handler A pointer to a cURL write function callback.
*/
- void flyPage(QString const& sku,
- size_t (*handler)(void*, size_t, size_t, void*));
+ void flyPage(QString const& sku, icclient_handler handler);
+#ifndef __EMSCRIPTEN__
/*!
* \brief For putting an item to a cart.
* \param sku The SKU of the item to order.
@@ -51,6 +53,7 @@ namespace QICClient {
* \param order The order.
*/
void order(QString const& sku, Catalog const& catalog, Ord& order);
+#endif
signals:
void gotResults(Catalog* catalog);
@@ -59,4 +62,4 @@ namespace QICClient {
}
-#endif // QICCLIENT_CLIENT_HXX
+#endif
diff --git a/qicclient/member.hxx b/qicclient/member.hxx
index fc3c77e..4e8010f 100644
--- a/qicclient/member.hxx
+++ b/qicclient/member.hxx
@@ -2,6 +2,7 @@
#define QICCLIENT_MEMBER_HXX
#include <QObject>
+#include <icclient/typedefs.h>
#include <icclient/member.h>
struct icclient_member;
@@ -61,8 +62,7 @@ namespace QICClient {
QString const& successPage = nullptr,
QString const& nextPage = nullptr,
QString const& failPage = nullptr,
- size_t (*handler)(void*, size_t, size_t,
- void*) = nullptr);
+ icclient_handler handler = nullptr);
QString const& userName() const { return m_userName; }
QString const& userNick() const { return m_userNick; }