Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
broxen committed May 10, 2019
2 parents 6d5b16a + 37f9b59 commit 3286851
Show file tree
Hide file tree
Showing 867 changed files with 81,384 additions and 23,782 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve

---

### Pro Tips:
1. Prior to submitting a new issue, please [ensure that a similar issue does not already exist](https://github.com/Segs/Segs/issues). You can manually browse or use the search feature to determine if there would be duplicate issues as a result of your submission.
2. Please [thoroughly read the README](https://github.com/Segs/Segs/blob/master/README.md) before submitting issues related to build, installation, and configuration as this document should contain everything required to get up and running.
3. Populate the areas in the template below if applicable to the best of your ability to help us better understand the problem. Please remove the following line and all the text above to omit these tips in your submission.

---

### Describe the bug
A clear and concise description of what the bug is.

### To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

### Expected behavior
A clear and concise description of what you expected to happen.

### Screenshots or Attachments (if applicable)
If applicable, add screenshots to help explain your problem.

### SEGS Version, C++ Toolkit
- SEGS Build ID:
- C++ Toolkit:
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project

---

## Feature Summary
A clear and concise description of what the proposed feature is.

### Is your feature request related to a problem?
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] and link to any relevant GitHub Issues by using the `#123` format

### Proposed Implementation
Please describe how you believe your feature should be implemented. How would it work? What requirements might it have?

### Alternatives and Additional Remarks
Describe alternatives you've considered by providing a clear and concise description of any alternative solutions or features you've considered. Additional notes go here as well.

### Screenshots, Diagrams or Attachments (if applicable)
If applicable, add diagrams to help explain your request.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# common cmake build directories
build*/
bld/
doxygen/
out/
Expand Down Expand Up @@ -33,3 +32,4 @@ out/

# Environment activation script
activate.env
.directory
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ matrix:
compiler: "gcc-7"
env: BUILD='Debug' CC=gcc-7 CXX=g++-7
addons: *gcc7
# Disabling macOS builds temporarily until the app bundle issue can be resolved
# - os: osx
# osx_image: xcode9.2
# compiler: clang
# env: BUILD='Debug'
- os: osx
osx_image: xcode9.2
compiler: clang
env: BUILD='Debug'

before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo add-apt-repository ppa:beineri/opt-qt593-trusty -y; fi
Expand Down
9 changes: 3 additions & 6 deletions 3rd_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ if(MINGW) # ERICEDIT: If the OS is Windows:
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ace_LIBRARY_SHARED} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
endif()

########################################################################################
# Optional components
########################################################################################

if(ENABLE_SCRIPTING_ENGINE)
include(ExternalProject_LUA.cmake)
include(ExternalProject_SOL2.cmake)
endif()
include(ExternalProject_LUA.cmake)
include(ExternalProject_SOL2.cmake)
include(ExternalProject_JCON.cmake)

2 changes: 1 addition & 1 deletion 3rd_party/glm/simd/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
# define GLM_COMPILER (GLM_COMPILER_GCC71)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC72)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 3)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ >= 3)
# define GLM_COMPILER (GLM_COMPILER_GCC72)
# elif (__GNUC__ >= 8)
# define GLM_COMPILER (GLM_COMPILER_GCC80)
Expand Down
35 changes: 32 additions & 3 deletions 3rd_party/jcon-cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ JCON-CPP is a portable C++ JSON RPC 2.0 library that depends on Qt.

## Introduction

If you're using **C++ 11** and **Qt**, and want to create a **JSON RPC 2.0**
If you're using **C++ 14** and **Qt**, and want to create a **JSON RPC 2.0**
client or server, using either **TCP** or **WebSockets** as underlying transport
layer, then **JCON-CPP** might prove useful.

Expand All @@ -21,8 +21,24 @@ Platforms supported are: Linux, Windows, Mac OS, and Android.
4. `cmake ..`
5. `make -j4`

The build depends on the environment variable `QTDIR` to find the required Qt
dependencies.
The build depends on the build directive `CMAKE_PREFIX_PATH` to find the
required Qt dependencies, so if your CMake doesn't pick up on where to find Qt,
try adding `cmake -DCMAKE_PREFIX_PATH=<QTDIR> ..` in step 4 above.

## Include Files

Depending on if you're implementing a server or a client and whether you're
using TCP or WebSockets, you need to include some of these files:
```c++
#include <jcon/json_rpc_tcp_client.h>
#include <jcon/json_rpc_tcp_server.h>
#include <jcon/json_rpc_websocket_client.h>
#include <jcon/json_rpc_websocket_server.h>
```

## Example Code

There's example code of both a server and a client in the file `src/main.cpp`.

## Creating a Server

Expand Down Expand Up @@ -61,6 +77,12 @@ Register your service with:
rpc_server->registerServices({ new ExampleService() });
```
Note that (as of 2018-11-21) there is also a variant of `registerServices` that
takes a `QMap<QObject*, QString>`, where the keys are the services, and the
values are strings that will need to be used as prefixes when calling the
corresponding RPC methods. This can be used as a simple namespace mechanism.
Please refer to the example code in `src/main.cpp`.
The server will take over ownership of the service object, and the memory will
be freed at shutdown. Note that the `registerServices` method changed its
signature 2016-10-20, from being a variadic template expecting `unique_ptrs`, to
Expand Down Expand Up @@ -146,6 +168,13 @@ single argument), use `callExpandArgs` and `callAsyncExpandArgs`.
Bug reports and pull requests are welcome on GitHub at
https://github.com/joncol/jcon-cpp.
Please follow these
[guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
for creating commit messages.
Also make sure to follow the existing code style. No lines with more than 80
characters, spaces instead of tabs for instance.
## License
Expand Down
64 changes: 35 additions & 29 deletions 3rd_party/jcon-cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ if(USE_QT)
find_program(QT_UIC_EXECUTABLE uic)
endif()

if(APPLE)
# icon
if(EXISTS "${PROJECT_NAME}.icns")
# set how it shows up in the Info.plist file
set(MACOSX_BUNDLE_ICON_FILE ${PROJECT_NAME}.icns)

# set where in the bundle to put the icns file
set_source_files_properties(${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

# include the icns file in the target
set(${PROJECT_NAME}_sources ${${PROJECT_NAME}_sources} ${PROJECT_NAME}.icns)
endif()

add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources} ${UI_HEADERS})
elseif(WIN32)
#if(APPLE)
# # icon
# if(EXISTS "${PROJECT_NAME}.icns")
# # set how it shows up in the Info.plist file
# set(MACOSX_BUNDLE_ICON_FILE ${PROJECT_NAME}.icns)
#
# # set where in the bundle to put the icns file
# set_source_files_properties(${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
#
# # include the icns file in the target
# set(${PROJECT_NAME}_sources ${${PROJECT_NAME}_sources} ${PROJECT_NAME}.icns)
# endif()
#
# add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources} ${UI_HEADERS})
if(WIN32)
add_executable(${PROJECT_NAME} WIN32 ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources} ${UI_HEADERS})
else()
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources} ${UI_HEADERS})
Expand All @@ -53,29 +53,35 @@ if(USE_QT)
qt5_use_modules(${PROJECT_NAME} Core Network Test WebSockets Widgets)
endif()

if(APPLE)
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}")

set(plugin_dest_dir ${PROJECT_NAME}.app/Contents/MacOS)
set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app")

install(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
" COMPONENT Runtime)

else()
#if(APPLE)
# set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}")
#
# set(plugin_dest_dir ${PROJECT_NAME}.app/Contents/MacOS)
# set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app")
#
# install(CODE "
# include(BundleUtilities)
# fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
# " COMPONENT Runtime)
#
#else()
install(TARGETS ${EXECUTABLE_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static)
endif()
#endif()

if(MINGW)
get_filename_component(MINGW_DIR ${CMAKE_C_COMPILER} PATH)

file(GLOB LIBGCC_DLL_PATH "${MINGW_DIR}/libgcc_s_*.dll")
if(NOT LIBGCC_DLL_PATH)
message(FATAL_ERROR "Could not find libgcc dll")
endif()

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MINGW_DIR}/libgcc_s_dw2-1.dll"
"${LIBGCC_DLL_PATH}"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MINGW_DIR}/libstdc++-6.dll"
Expand Down
1 change: 1 addition & 0 deletions 3rd_party/jcon-cpp/src/jcon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/jcon
)
target_compile_definitions(jcon PUBLIC NDEBUG)
5 changes: 4 additions & 1 deletion 3rd_party/jcon-cpp/src/jcon/json_rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ QJsonObject JsonRpcClient::createRequestJsonObject(const QString& method,

QJsonObject JsonRpcClient::createNotificationJsonObject(const QString& method)
{
return createRequestJsonObject(method, "null");
return QJsonObject {
{ "jsonrpc", "2.0" },
{ "method", method }
};
}

bool JsonRpcClient::connectToServer(const QString& host, int port)
Expand Down
4 changes: 4 additions & 0 deletions 3rd_party/jcon-cpp/src/jcon/json_rpc_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ QByteArray JsonRpcEndpoint::processBuffer(const QByteArray& buffer,
QByteArray buf(buffer);

JCON_ASSERT(buf[0] == '{');
if (buf[0] != '{') {
m_logger->logInfo(QString("malformed request"));
return nullptr;
}

bool in_string = false;
int brace_nesting_level = 0;
Expand Down
56 changes: 53 additions & 3 deletions 3rd_party/jcon-cpp/src/jcon/json_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@ JsonRpcServer::~JsonRpcServer()
}

void JsonRpcServer::registerServices(const QObjectList& services)
{
m_services.clear();
for (auto s : services) {
m_services[s] = "";
}
m_ns_separator = "";
}

void JsonRpcServer::registerServices(const ServiceMap& services,
const QString& ns_separator)
{
m_services = services;
m_ns_separator = ns_separator;
}

void JsonRpcServer::jsonRequestReceived(const QJsonObject& request,
Expand Down Expand Up @@ -103,11 +114,28 @@ bool JsonRpcServer::dispatch(const QString& method_name,
const QString& request_id,
QVariant& return_value)
{
for (auto& s : m_services) {
QString method_ns;
QString method_name_without_ns;
std::tie(method_ns, method_name_without_ns) =
namespaceAndMethodName(method_name);

QObjectList services;
for (auto it = m_services.begin(); it != m_services.end(); ++it) {
QObject* s = it.key();
QString ns = it.value();
if (ns.isEmpty() || ns == method_ns) {
services.push_back(s);
}
}

for (auto s : services) {
const QMetaObject* meta_obj = s->metaObject();
for (int i = 0; i < meta_obj->methodCount(); ++i) {
for (int i = meta_obj->methodOffset();
i < meta_obj->methodCount();
++i)
{
auto meta_method = meta_obj->method(i);
if (meta_method.name() == method_name) {
if (meta_method.name() == method_name_without_ns) {
if (params.type() == QVariant::List ||
params.type() == QVariant::StringList)
{
Expand All @@ -118,13 +146,35 @@ bool JsonRpcServer::dispatch(const QString& method_name,
if (call(s, meta_method, params.toMap(), return_value)) {
return true;
}
} else if (params.type() == QVariant::Invalid) {
if (call(s, meta_method, QVariantList(), return_value)) {
return true;
}
}
}
}
}
return false;
}

std::pair<QString, QString>
JsonRpcServer::namespaceAndMethodName(const QString& full_name)
{
if (m_ns_separator.isEmpty()) {
return {"", full_name};
}
QString ns;
QString method_name;
int li = full_name.lastIndexOf(m_ns_separator);
if (li > 0) {
ns = full_name.left(li);
method_name = full_name.mid(li + m_ns_separator.length());
} else {
return {"", full_name};
}
return {ns, method_name};
}

bool JsonRpcServer::call(QObject* object,
const QMetaMethod& meta_method,
const QVariantList& args,
Expand Down
Loading

0 comments on commit 3286851

Please sign in to comment.