Skip to content

Commit

Permalink
Merge pull request #3 from wsjcpp/version-0.0.3
Browse files Browse the repository at this point in the history
Version 0.0.3
  • Loading branch information
sea-kg authored Sep 18, 2020
2 parents 91631a7 + 52df854 commit 75d20c4
Show file tree
Hide file tree
Showing 29 changed files with 1,883 additions and 372 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# wsjcpp-jsonrpc20

[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-jsonrpc20.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-jsonrpc20)
[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-jsonrpc20.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-jsonrpc20) [![Total alerts](https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-jsonrpc20.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-jsonrpc20/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-jsonrpc20.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-jsonrpc20/context:cpp) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/wsjcpp/wsjcpp-jsonrpc20.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/wsjcpp/wsjcpp-jsonrpc20/context:python)

C++ Implementation for JsonRPC 2.0 (oriented on websockets)

Expand Down
4 changes: 2 additions & 2 deletions example-of-exported/py3/API.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SomeClient Python Library

Automatically generated by wsjcpp-jsonrpc20.
* Version: v0.0.2
* Date: Sun, 13 Sep 2020 19:26:47 GMT
* Version: v0.0.3
* Date: Fri, 18 Sep 2020 03:27:31 GMT

Example connect/disconnect:
```
Expand Down
28 changes: 14 additions & 14 deletions example-of-exported/py3/libwsjcppjson20client/SomeClient.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
### This file was automatically generated by wsjcpp-jsonrpc20
### Version: v0.0.2
### Date: Sun, 13 Sep 2020 19:26:47 GMT
### Version: v0.0.3
### Date: Fri, 18 Sep 2020 03:27:31 GMT

import asyncio
import websocket
Expand All @@ -13,7 +13,7 @@
class SomeClient:
__ws = None
__url = None
__cli_version = 'v0.0.2'
__cli_version = 'v0.0.3'
__loop = None
__token = None
__connecting = False
Expand Down Expand Up @@ -45,7 +45,7 @@ def hasConnection(self):
def getToken(self):
return self.__token
def setToken(self, token):
if self.__token == None:
if self.__token is None:
self.__token = token
else:
print('ERROR: Token can be set only once')
Expand All @@ -56,10 +56,10 @@ def close(self):
self.__ws = None

def receiveIncomingMesssages(self):
if self.__ws == None:
if self.__ws is None:
return None # TODO has not connection
while True:
if self.__ws == None:
if self.__ws is None:
return None # TODO has not connection
ready = select.select([self.__ws], [], [], 1)
if ready[0]:
Expand All @@ -83,7 +83,7 @@ async def __looper(self, messageId):
max_time = 5*10 # 5 seconds
counter_time = 0
while True:
if self.__ws == None:
if self.__ws is None:
return None # TODO has not connection
for inmsg in self.__incomingMesssages:
if inmsg['id'] == messageId:
Expand Down Expand Up @@ -130,7 +130,7 @@ def __sendCommand(self, req):
return result

def preprocessIncomeJson(self, jsonIn):
if jsonIn == None:
if jsonIn is None:
return jsonIn
if jsonIn['method'] == 'auth_logoff' and 'result' in jsonIn:
self.__token = None
Expand All @@ -157,12 +157,12 @@ def auth_login(self, login, password, client_app_name = None, client_app_version
"""
if not self.hasConnection(): return None
reqJson = self.generateBaseCommand('auth_login')
if login == None:
if login is None:
raise Exception('Parameter "login" expected (lib: SomeClient.auth_login)')
if not isinstance(login, str):
raise Exception('Parameter "login" expected datatype "str" (lib: SomeClient.auth_login )')
reqJson['params']['login'] = login
if password == None:
if password is None:
raise Exception('Parameter "password" expected (lib: SomeClient.auth_login)')
if not isinstance(password, str):
raise Exception('Parameter "password" expected datatype "str" (lib: SomeClient.auth_login )')
Expand Down Expand Up @@ -207,7 +207,7 @@ def auth_token(self, token, client_app_name = None, client_app_version = None):
"""
if not self.hasConnection(): return None
reqJson = self.generateBaseCommand('auth_token')
if token == None:
if token is None:
raise Exception('Parameter "token" expected (lib: SomeClient.auth_token)')
if not isinstance(token, str):
raise Exception('Parameter "token" expected datatype "str" (lib: SomeClient.auth_token )')
Expand Down Expand Up @@ -242,7 +242,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
"""
if not self.hasConnection(): return None
reqJson = self.generateBaseCommand('game_create')
if uuid == None:
if uuid is None:
raise Exception('Parameter "uuid" expected (lib: SomeClient.game_create)')
if not isinstance(uuid, str):
raise Exception('Parameter "uuid" expected datatype "str" (lib: SomeClient.game_create )')
Expand All @@ -251,7 +251,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
if not isinstance(name, str):
raise Exception('Parameter "name" expected datatype "str" (lib: SomeClient.game_create )')
reqJson['params']['name'] = name
if cost == None:
if cost is None:
raise Exception('Parameter "cost" expected (lib: SomeClient.game_create)')
if not isinstance(cost, int):
raise Exception('Parameter "cost" expected datatype "int" (lib: SomeClient.game_create )')
Expand All @@ -260,7 +260,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
if not isinstance(age, int):
raise Exception('Parameter "age" expected datatype "int" (lib: SomeClient.game_create )')
reqJson['params']['age'] = age
if public == None:
if public is None:
raise Exception('Parameter "public" expected (lib: SomeClient.game_create)')
if not isinstance(public, bool):
raise Exception('Parameter "public" expected datatype "bool" (lib: SomeClient.game_create )')
Expand Down
2 changes: 1 addition & 1 deletion example-of-exported/py3/libwsjcppjson20client/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .SomeClient import *
from .SomeClient import SomeClient
2 changes: 1 addition & 1 deletion example-of-exported/py3/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='libwsjcppjson20client',
version='v0.0.2',
version='v0.0.3',
packages=['libwsjcppjson20client'],
install_requires=['websocket-client>=0.56.0', 'requests>=2.21.0'],
keywords=['wsjcpp-jsonrpc20', 'wsjcpp', 'wsjcpp-jsonrpc20', 'example-python-client'],
Expand Down
4 changes: 2 additions & 2 deletions src.wsjcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Automaticly generated by [email protected]
cmake_minimum_required(VERSION 3.0)

add_definitions(-DWSJCPP_APP_VERSION="v0.0.2")
add_definitions(-DWSJCPP_APP_VERSION="v0.0.3")
add_definitions(-DWSJCPP_APP_NAME="wsjcpp-jsonrpc20")

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
Expand All @@ -17,7 +17,7 @@ set (WSJCPP_SOURCES "")
find_package(Threads REQUIRED)
list (APPEND WSJCPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

# wsjcpp-core:v0.1.7
# wsjcpp-core:v0.2.0
list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp_core/")
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp")
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.h")
Expand Down
103 changes: 103 additions & 0 deletions src.wsjcpp/wsjcpp_core/generate.WsjcppUnitTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/wsjcpp-safe-scripting

# log_info rootdir
# log_info script_filename

make_dir "./unit-tests.wsjcpp"
make_dir "./unit-tests.wsjcpp/src"

var user_class_name
set_value user_class_name arg1
normalize_class_name user_class_name
var class_name
set_value class_name "UnitTest"
concat class_name user_class_name

var base_filename
convert_CamelCase_to_snake_case class_name base_filename
# log_info base_filename

var filename_cpp
concat filename_cpp "./unit-tests.wsjcpp/src/" base_filename ".cpp"

var filename_h
concat filename_h "./unit-tests.wsjcpp/src/" base_filename ".h"

var ifndef_header
set_value ifndef_header base_filename
concat ifndef_header "_H"

to_upper_case ifndef_header

var content_header
concat content_header "#ifndef " ifndef_header "
#define " ifndef_header "

#include <wsjcpp_unit_tests.h>

class " class_name " : public WsjcppUnitTestBase {
public:
" class_name "();
virtual bool doBeforeTest() override;
virtual void executeTest() override;
virtual bool doAfterTest() override;
};

#endif // " ifndef_header


var content_source
concat content_source "
#include \"" base_filename ".h\"
#include <wsjcpp_core.h>

// ---------------------------------------------------------------------
// " class_name "

REGISTRY_WSJCPP_UNIT_TEST(" class_name ")

" class_name "::" class_name "()
: WsjcppUnitTestBase(\"" class_name "\") {
}

// ---------------------------------------------------------------------

bool " class_name "::doBeforeTest() {
// nothing
return true;
}

// ---------------------------------------------------------------------

void " class_name "::executeTest() {
compare(\"Not implemented\", true, false);
// TODO unit test source code here
}

// ---------------------------------------------------------------------

bool " class_name "::doAfterTest() {
// nothing
return true;
}

"

var file_source
concat file_source "src/" filename_cpp

write_file filename_h content_header
write_file filename_cpp content_source

log_info "
======
Generated class:
- " class_name "
Generated files:
- " filename_h "
- " filename_cpp "
======
"

wsjcpp_yml_unit_test_add user_class_name filename_h
wsjcpp_yml_unit_test_add user_class_name filename_cpp
11 changes: 10 additions & 1 deletion src.wsjcpp/wsjcpp_core/wsjcpp.hold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_cxx_standard: 11
cmake_minimum_required: 3.0

name: wsjcpp-core
version: v0.1.7
version: v0.2.0
description: Basic Utils for wsjcpp
issues: https://github.com/wsjcpp/wsjcpp-core/issues
repositories:
Expand Down Expand Up @@ -33,6 +33,9 @@ distribution:
- source-file: "src/wsjcpp_unit_tests_main.cpp"
target-file: "wsjcpp_unit_tests_main.cpp"
type: "unit-tests"
- source-file: "scripts.wsjcpp/generate.WsjcppUnitTest"
target-file: "generate.WsjcppUnitTest"
type: "safe-scripting-generate"
- source-file: "scripts.wsjcpp/generate.Class"
target-file: "generate.Class"
type: "safe-scripting-generate"
Expand Down Expand Up @@ -79,3 +82,9 @@ unit-tests:
description: "Test basic resources"
- name: "ListOfDirs"
description: "Check list of directories"
- name: "FilePermissions"
description: ""
- name: "StringPadding"
description: ""
- name: "DateTimeFormat"
description: ""
Loading

0 comments on commit 75d20c4

Please sign in to comment.