Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Expose the preprocessor definition via the function
Browse files Browse the repository at this point in the history
  • Loading branch information
incomingstick committed Dec 23, 2019
1 parent 8f53655 commit 832b10f
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 31 deletions.
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). However, note that all pre-v0.5.0 releases will have the suffix "-dev"

## [Unreleased]
There is likely a TON that has changed that is not noted below. This release is a HUGE one, so we likely missed something. If you notice something is missing, please open a PR to fix it (with commit citations please)!

### Added
- We are now on the Arch User Repository and supporting Arch as our first Linux distro, as it is what I ([@incomingstick](http://github.comincomingstick)) use!
- You can use the PKGBUILD branch of this Repo to build from `makepkg` that way
- Clone us out of the AUR yourself by running `git clone https://aur.archlinux.org/openrpg-git.git && cd openrpg-git && makepkg -si`
- You can use your favorite AUR helper, such as `yay`
- Run `$ yay -S openrpg`
- We have improved our CMake logic to include the use of CPack for packaging, especially on Windows! Check out our [downloads](https://openrpg.io/download/) page for your systems installer!
- We have improved our CMake logic to include the use of CPack for packaging, for all supported OS's! Check out our [downloads](https://openrpg.io/download/) page for your systems installer!
- Build scripts now include a package target for packaging with CPack
- NodeJS and `npm` integrated into the project workflow. You can now use npm and subsequently cmake-js to compile an additional `orpgAddon.node` binary that is a compiled node module.
- NodeJS and `npm` integrated into the project workflow. You can now use `npm` and subsequently `cmake-js` to compile an additional `orpgAddon.node` binary that is a compiled Node module.
- This NodeJS addon aims to be a complete wrap of the C++ libraries. As such, most functions and classes should operate as you would expect the C++ counterpart.
- Expose the `VERSION` preprocessor definition via the `ORPG_VERSION()` function
- An ASCII character sheet in `data/` thanks to [@var-username](https://github.com/var-username)
- data/character_sheets/ascii_char_sheet
- "data/character_sheets/Blank ASCII Character Sheet.txt"
Expand All @@ -35,9 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ORPG::Names`
- `ORPG::Character`
- `NameGenerator` class now has a constructor that takes a file location as a `std::string`, here are some important notes:
- By creating this constructor we are allowing an end user to specify the location the namelist we will read from. It is extremely important we explore this further. I [@incomingstick](http://github.comincomingstick)) do think this could prove a beneficial feature, if we allow end users to specify namelists.
- I [@incomingstick](http://github.comincomingstick)) created this function specifically to help the test suite. When testing on a fresh system, we are built before we test, but the release builds defines ASSET_LOC as: "/usr/local/data/openrpg" Because of this, it attempts to check a folder that has not been installed yet, and we need a way to NameGenerator to our source data folder.
- Character Generator program now takes full advantage of our Names library to allow for the use of first and last names
- By creating this constructor we are allowing an end user to specify the location the namelist we will read from. It is extremely important we explore any possible security implications of this further. I [@incomingstick](http://github.comincomingstick)) do think it could prove a beneficial feature to allow end users to specify namelists.
- I, [@incomingstick](http://github.comincomingstick), created this function specifically to help the test suite. When testing on a fresh system, we are built before we test, but the release builds defines ASSET_LOC as: "/usr/local/data/openrpg" Because of this, it attempts to check a folder that has not been installed yet, and we need a way to point NameGenerator to our source data folder.
- Character module now takes full advantage of our Names library to allow for the use of first and last names
- Added the Elf race to the Characters library
- `class Elf : public Character`
- `class HighElf : public Elf`
Expand Down Expand Up @@ -74,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Missing note in Core::print_basic_help() about how to exit OpenRPG.
- Fixed a bug in the ExpressionTree where the `globalReadOffset` was not being reset when a new expression was set
- Fixed a bug when stringing multiple rolls together that would causing the tree to parse an expression such as 2d6+4d8 as (2d6+4)d8
- Honestly there are a TON of bug fixes with the roll parser now that we are using the Mocha test suite
- Fixed a bug in NameGenerator that wasn't resetting the raceFile when a new race was set

### Removed
Expand Down Expand Up @@ -461,7 +466,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `openrpg` command welcome banner
- src/assets/banners/welcome_mat1

[Unreleased]: https://github.com/incomingstick/OpenRPG/compare/v0.4.4-dev...patch-v0.5.0-dev
[Unreleased]: https://github.com/incomingstick/OpenRPG/compare/v0.4.4-dev...master
[0.4.4-dev]: https://github.com/incomingstick/OpenRPG/compare/v0.4.3-dev...v0.4.4-dev
[0.4.3-dev]: https://github.com/incomingstick/OpenRPG/compare/v0.4.2-dev...v0.4.3-dev
[0.4.2-dev]: https://github.com/incomingstick/OpenRPG/compare/v0.4.1-dev...v0.4.2-dev
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ project(OpenRPG)
set(OpenRPG_VERSION_MAJOR 0)
set(OpenRPG_VERSION_MINOR 5)
set(OpenRPG_VERSION_TWEAK 0)
set(OpenRPG_VERSION_SUFFIX "dev")
set(OpenRPG_AUTHOR "Nicholas Gaulke")
string(TIMESTAMP YEAR %Y UTC)
string(TIMESTAMP DATE UTC)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# NOTE
## NOTE
This repository is for the back end libraries for OpenRPG. If you are looking for the App, please visit our sister repository, [here](https://github.com/incomingstick/OpenRPG-App).

# OpenRPG
Expand Down
3 changes: 1 addition & 2 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ edit the original config.h.in file NOT THIS FILE.
#define VERSION_MAJOR @OpenRPG_VERSION_MAJOR@
#define VERSION_MINOR @OpenRPG_VERSION_MINOR@
#define VERSION_TWEAK @OpenRPG_VERSION_TWEAK@
#define VERSION_SUFFIX "@OpenRPG_VERSION_SUFFIX@"
#define VERSION "v@OpenRPG_VERSION_MAJOR@.@OpenRPG_VERSION_MINOR@.@OpenRPG_VERSION_TWEAK@-@OpenRPG_VERSION_SUFFIX@"
#define VERSION "v@OpenRPG_VERSION_MAJOR@.@OpenRPG_VERSION_MINOR@.@OpenRPG_VERSION_TWEAK@"
#define AUTHOR "@OpenRPG_AUTHOR@"
#define COPYRIGHT "(C) 2016-@YEAR@ @OpenRPG_AUTHOR@"
#define ASSET_LOC "${DATA_INSTALL_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion include/character.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
character-generator - Character module global include
characters - Character module global include
Created on: May 28, 2017
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
Expand Down
21 changes: 21 additions & 0 deletions include/core/core-wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
core - core-wrapper.h
Created on: Dec 23, 2019
OpenRPG Software License - Version 1.0 - February 10th, 2017 <http://www.openrpg.io/about/license/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*/
#ifndef SRC_CORE_WRAPPER_H_
#define SRC_CORE_WRAPPER_H_

#include <node.h>
#include <node_object_wrap.h>

#include "config.h"

namespace ORPGJS {
void ORPG_VERSION(const v8::FunctionCallbackInfo<v8::Value>& args);
}

#endif /* SRC_CORE_WRAPPER_H_*/
6 changes: 6 additions & 0 deletions include/core/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ namespace ORPG {
**/
void CORE_EXPORT print_basic_help();

/**
* @desc returns a std::string of the preprocessor definition of VERSION
*
* @return std::string - the preprocessor definition of VERSION
**/
std::string CORE_EXPORT version_string();

extern bool CORE_EXPORT VB_FLAG;
extern bool CORE_EXPORT QUIET_FLAG;
Expand Down
2 changes: 1 addition & 1 deletion include/names.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
name-generator - Names module global include
names - Names module global include
Created on: May 28, 2017
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
Expand Down
2 changes: 1 addition & 1 deletion include/names/names-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ There is NO WARRANTY, to the extent permitted by law.

#include "names.h"

namespace ORPGGUI {
namespace ORPGJS {
void race_is_gendered(const v8::FunctionCallbackInfo<v8::Value>& args);
void race_has_last(const v8::FunctionCallbackInfo<v8::Value>& args);

Expand Down
2 changes: 1 addition & 1 deletion include/roll/roll-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ There is NO WARRANTY, to the extent permitted by law.

#include "roll.h"

namespace ORPGGUI {
namespace ORPGJS {
class DieWrapper : public ORPG::Die, public node::ObjectWrap {
private:
explicit DieWrapper(int max);
Expand Down
16 changes: 16 additions & 0 deletions include/wrappers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
nodejs - NodeJs module global include
Created on: Dec 23, 2019
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*/
#ifndef ORPGJS_H
#define ORPGJS_H

#include "core/core-wrapper.h"
#include "roll/roll-wrapper.h"
#include "names/names-wrapper.h"

#endif /* CHARACTER_H */
25 changes: 25 additions & 0 deletions src/core/core-wrapper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
core - core-wrapper.cpp
Created on: Dec 23, 2019
OpenRPG Software License - Version 1.0 - February 10th, 2017 <http://www.openrpg.io/about/license/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*/
#include "core/core-wrapper.h"

namespace ORPGJS {
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::NewStringType;
using v8::String;
using v8::Value;

/**
* @desc exports the VERSION preprocessor definition as a
**/
void ORPG_VERSION(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, VERSION, NewStringType::kNormal).ToLocalChecked());
}
}
2 changes: 1 addition & 1 deletion src/core/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
openrpg - utils.cpp
core - utils.cpp
Created on: Mar 23, 2016
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
Expand Down
4 changes: 3 additions & 1 deletion src/core/xml.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
openrpg - xml.h
core - xml.h
Created on: Sept 1, 2019
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
Expand Down Expand Up @@ -272,6 +272,8 @@ XMLDocument::~XMLDocument() {

/**
* TODO doc comments
* FIXME this crashes with the following error
* Expression: cannot dereference string iterator because it is out of range (e.g. an end iterator)
**/
bool XMLDocument::load_file(string filename) {
//TODO load file
Expand Down
6 changes: 3 additions & 3 deletions src/names/name-generator-wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
roll - DieWrapper.cpp
names - name-generator-wrapper.cpp
Created on: June 26, 2017
OpenRPG Software License - Version 1.0 - February 10th, 2017 <http://www.openrpg.io/about/license/>
Expand All @@ -9,7 +9,7 @@ There is NO WARRANTY, to the extent permitted by law.
#include <vector>
#include "names/names-wrapper.h"

namespace ORPGGUI {
namespace ORPGJS {
using v8::Context;
using v8::Function;
using v8::FunctionCallbackInfo;
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace ORPGGUI {
Local<Context> context = isolate->GetCurrentContext();
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
exports->Set(context, String::NewFromUtf8(isolate, "NameGenerator", NewStringType::kNormal).ToLocalChecked(),
tpl->GetFunction(context).ToLocalChecked());
tpl->GetFunction(context).ToLocalChecked()).Check();
}

void NameGeneratorWrapper::New(const FunctionCallbackInfo<Value>& args) {
Expand Down
2 changes: 1 addition & 1 deletion src/names/names.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
name-generator - names.cpp
names - names.cpp
Created on: Nov 10, 2016
OpenRPG Software License - Version 1.0 - February 10th, 2017 <https://openrpg.io/about/license/>
Expand Down
3 changes: 2 additions & 1 deletion src/nodejs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ set(ROLL_ADDON_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include/roll/)

set(ROLL_ADDON_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/node-addon.cpp
${CMAKE_SOURCE_DIR}/src/core/core-wrapper.cpp
${CMAKE_SOURCE_DIR}/src/roll/roll-wrapper.cpp
${CMAKE_SOURCE_DIR}/src/names/name-generator-wrapper.cpp
)

add_library(orpgNode SHARED ${ROLL_ADDON_SOURCES} ${CMAKE_JS_SRC})
set_target_properties(orpgNode PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(orpgNode ${CMAKE_JS_LIB} roll-parser names)
target_link_libraries(orpgNode ${CMAKE_JS_LIB} core roll-parser names)

# if the roll executable needs a higher standard than C++11 please update here
set_property(TARGET orpgNode PROPERTY CXX_STANDARD 11)
Expand Down
9 changes: 5 additions & 4 deletions src/nodejs/node-addon.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/*
roll - rollAddon.h
nodejs - node-addon.cpp
Created on: June 26, 2017
OpenRPG Software License - Version 1.0 - February 10th, 2017 <http://www.openrpg.io/about/license/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*/
#include <node.h>
#include "roll/roll-wrapper.h"
#include "names/names-wrapper.h"
#include "wrappers.h"

using namespace ORPG;

namespace ORPGGUI {
namespace ORPGJS {
using v8::Local;
using v8::Object;

Expand All @@ -21,6 +20,8 @@ namespace ORPGGUI {
ExpressionTreeWrapper::Init(exports);
NameGeneratorWrapper::Init(exports);

NODE_SET_METHOD(exports, "ORPG_VERSION", ORPG_VERSION);

NODE_SET_METHOD(exports, "race_has_last", race_has_last);
NODE_SET_METHOD(exports, "race_is_gendered", race_is_gendered);
}
Expand Down
6 changes: 6 additions & 0 deletions src/nodejs/openrpg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* Definitions by: incomingstick <https://github.com/incomingstick>
*/
declare module 'openrpg-libs' {
/**
* @desc This function exports the version number of the built OpenRPG libraries that are being used
* @return string - the version number of the built OpenRPG libraries that are being used
**/
export function ORPG_VERSION(): string;

export class Die {
public constructor(max: number);

Expand Down
8 changes: 4 additions & 4 deletions src/roll/roll-wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
roll - DieWrapper.cpp
roll - roll-wrapper.cpp
Created on: June 26, 2017
OpenRPG Software License - Version 1.0 - February 10th, 2017 <http://www.openrpg.io/about/license/>
Expand All @@ -8,7 +8,7 @@ There is NO WARRANTY, to the extent permitted by law.
*/
#include "roll/roll-wrapper.h"

namespace ORPGGUI {
namespace ORPGJS {
using v8::Context;
using v8::Function;
using v8::FunctionCallbackInfo;
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace ORPGGUI {
Local<Context> context = isolate->GetCurrentContext();
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
exports->Set(context, String::NewFromUtf8(isolate, "Die", NewStringType::kNormal).ToLocalChecked(),
tpl->GetFunction(context).ToLocalChecked());
tpl->GetFunction(context).ToLocalChecked()).Check();
}

void DieWrapper::New(const FunctionCallbackInfo<Value>& args) {
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace ORPGGUI {
Local<Context> context = isolate->GetCurrentContext();
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
exports->Set(context, String::NewFromUtf8(isolate, "ExpressionTree", NewStringType::kNormal).ToLocalChecked(),
tpl->GetFunction(context).ToLocalChecked());
tpl->GetFunction(context).ToLocalChecked()).Check();
}

void ExpressionTreeWrapper::New(const FunctionCallbackInfo<Value>& args) {
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const LOOP_COMP = 3e-1; // For higher processing computations this is used to c
const TESTING_ASSET_LOC = path.join(path.dirname(__dirname), 'data/');

// TODO shrink this via the use of lists and loops!
describe('OpenRPG', () => {
describe('OpenRPG '+ ORPG.ORPG_VERSION(), () => {
describe('Roll Module', () => {
describe('Die', () => {
let val;
Expand Down

0 comments on commit 832b10f

Please sign in to comment.