Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update value reader and value writer implementation #62

Merged
merged 24 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2722574
Use updated ValueReader, ValueWriter interface
sonndinh Mar 12, 2024
90fcf1d
Fix CI and add read_bitmask
sonndinh Mar 18, 2024
51f9192
Update value reader
sonndinh Mar 20, 2024
6b05142
Add write_absent_value
sonndinh Mar 20, 2024
5d4e445
Check debugger availability
sonndinh Mar 20, 2024
61c71ff
Install gdb
sonndinh Mar 20, 2024
372058a
Remove debugger check
sonndinh Mar 20, 2024
89c969c
Disable jobs with latest-release branch. Try fixing the test bug.
sonndinh Mar 21, 2024
c2ae821
Fix workflow
sonndinh Mar 21, 2024
a905564
Failed to parse DataWriterQos because of invalid input
sonndinh Mar 22, 2024
fb050ce
Update security permission files
sonndinh Mar 22, 2024
fd8c895
Remove log messages
sonndinh Mar 22, 2024
599688a
Update signed security docs
sonndinh Mar 22, 2024
b097e6b
Try using newer Nan version
sonndinh Mar 22, 2024
d10bff8
Show python versions
sonndinh Mar 25, 2024
6e9a301
Node.js 14 doesn't work with python 3.11 and beyond
sonndinh Mar 25, 2024
7b9ade7
Step cannot have both uses and run keys
sonndinh Mar 25, 2024
4ef9835
Use Python 3.11 for node 16 due to the lack of distutils since Python…
sonndinh Mar 25, 2024
4b584dd
Update workflow
sonndinh Mar 25, 2024
4045d8a
Fix CI dependencies
sonndinh Mar 26, 2024
2ed6af7
Update path to openssl and xerces for Windows. Remove node 14 and 16
sonndinh Mar 26, 2024
00bfb27
Update OpenDDS repo path
sonndinh Mar 26, 2024
3e8cfef
From review
sonndinh Mar 28, 2024
84eaad4
Represent bitmask as array of flags
sonndinh Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# The jobs with latest-release configuration are disabled until OpenDDS 3.28
# which will have the updated ValueReader and ValueWriter interfaces.

jobs:
build:
strategy:
Expand All @@ -24,27 +27,14 @@ jobs:
- 20
opendds_branch:
- master
- latest-release
#- latest-release
m:
- {os: ubuntu-22.04, dds_security: 1}
- {os: ubuntu-22.04, dds_security: 0}
- {os: macos-12, dds_security: 1}
- {os: macos-12, dds_security: 0}
- {os: windows-2022, dds_security: 1}
- {os: windows-2022, dds_security: 0}
include:
- node_version: 18
opendds_branch: latest-release
m: {os: ubuntu-22.04, security: 0}
- node_version: 18
opendds_branch: latest-release
m: {os: windows-2022, security: 0}
- node_version: 20
opendds_branch: latest-release
m: {os: ubuntu-22.04, security: 1}
- node_version: 20
opendds_branch: latest-release
m: {os: windows-2022, security: 1}

runs-on: ${{ matrix.m.os }}
steps:
Expand All @@ -65,25 +55,25 @@ jobs:
- name: 'Checkout OpenDDS'
uses: actions/checkout@v3
with:
repository: objectcomputing/OpenDDS
repository: OpenDDS/OpenDDS
ref: ${{ matrix.opendds_branch }}
path: OpenDDS
fetch-depth: 1
- name: 'Set Up node'
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: 'Install ssl and xerces (ubuntu)'
- name: 'Install xerces (ubuntu)'
if: ${{ matrix.m.dds_security == 1 && matrix.m.os == 'ubuntu-22.04' }}
run: |-
sudo apt-get update
sudo apt-get -y install libssl-dev libxerces-c-dev
sudo apt-get -y install libxerces-c-dev
- name: 'Install xerces (macos)'
if: ${{ matrix.m.dds_security == 1 && matrix.m.os == 'macos-12' }}
run: |
brew install xerces-c
- name: Setup for run-vcpkg
if: runner.os == 'Windows'
if: ${{ matrix.m.dds_security == 1 && matrix.m.os == 'windows-2022' }}
shell: cmd
run: |
echo { "name": "opendds", "version-string": "github-actions", "dependencies": [ "openssl", "xerces-c" ] } > vcpkg.json
Expand Down Expand Up @@ -136,7 +126,7 @@ jobs:
echo "npm_config_devdir=$GITHUB_WORKSPACE\\opendds-node-gyp-devdir" >> $GITHUB_ENV
if [ ${{ matrix.m.dds_security }} == 1 ]; then
CONFIG_OPTIONS+=" --security"
CONFIG_OPTIONS+=" --xerces3=$VCPKG_ROOT\\installed\\x64-windows --openssl=$VCPKG_ROOT\\installed\\x64-windows"
CONFIG_OPTIONS+=" --xerces3=$VCPKG_INSTALLED_DIR\\x64-windows --openssl=$VCPKG_INSTALLED_DIR\\x64-windows"
BUILD_TARGETS+=";OpenDDS_Security"
fi
echo "CONFIG_OPTIONS=$CONFIG_OPTIONS" >> $GITHUB_ENV
Expand All @@ -151,7 +141,7 @@ jobs:
./configure --no-tests ${{ env.CONFIG_OPTIONS }}
tools/scripts/show_build_config.pl
. setenv.sh
make -j3 ${{ env.BUILD_TARGETS }}
make -j4 ${{ env.BUILD_TARGETS }}
iguessthislldo marked this conversation as resolved.
Show resolved Hide resolved
- name: 'Configure OpenDDS (windows)'
if: ${{ matrix.m.os == 'windows-2022' }}
shell: cmd
Expand All @@ -173,7 +163,14 @@ jobs:
run: |-
npm install
${{ env.ACE_ROOT }}/bin/mwc.pl -type gnuace -exclude ACE_TAO,OpenDDS
make -j2 || make
make -j4 || make
- name: Install gdb (ubuntu)
if: ${{ matrix.m.os == 'ubuntu-22.04' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install gdb
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
- name: 'Change Core File Pattern (ubuntu)'
if: ${{ matrix.m.os == 'ubuntu-22.04' }}
shell: bash
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "http://github.com/oci-labs/node-opendds.git"
"url": "https://github.com/OpenDDS/node-opendds.git"
},
"keywords": [
"dds",
Expand All @@ -27,6 +27,6 @@
"license": "BSD-3-Clause",
"gypfile": true,
"dependencies": {
"nan": "^2.16.0"
"nan": "^2.19.0"
}
}
12 changes: 11 additions & 1 deletion src/NodeDRListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,18 @@ void NodeDRListener::push_back(const DDS::SampleInfo& src, const void* sample)
return;
}

// TODO: When OpenDDS's vwrite works with key-only samples, e.g. from a dispose or
// unregister_instance call on the writer, this can be removed so that those samples
// can be delivered to the Javascript side.
if (!src.valid_data) {
return;
}

if (vd_) {
vd_->write(nvw_, sample);
if (!vd_->write(nvw_, sample)) {
ACE_ERROR((LM_WARNING, "WARNING: ValueDispatcher write failed\n"));
return;
}
}

Local<Value> argv[] = {
Expand Down
67 changes: 53 additions & 14 deletions src/NodeValueReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ struct ToFactory<v8::BigInt> : ToFactoryBase<v8::BigInt> {
namespace NodeOpenDDS {

NodeValueReader::NodeValueReader(v8::Local<v8::Object> obj)
: current_index_(0)
, use_name_(false)
{
// Nest initial object so first begin_struct behaves appropriately
current_object_ = Nan::New<v8::Object>();
Nan::Set(current_object_, 0, obj);

current_index_ = 0;
use_name_ = false;
}

bool NodeValueReader::begin_struct()
bool NodeValueReader::begin_struct(OpenDDS::DCPS::Extensibility /*extensibility*/)
{
return begin_nested();
}
Expand All @@ -49,30 +48,52 @@ bool NodeValueReader::end_struct()
}

bool NodeValueReader::begin_struct_member(OpenDDS::XTypes::MemberId& member_id, const OpenDDS::DCPS::MemberHelper& helper)
{
while (members_remaining()) {
Nan::MaybeLocal<v8::Value> mlv = Nan::Get(property_names_.ToLocalChecked(), current_index_);
// mlv is not empty at this point.
current_property_name_ = mlv.ToLocalChecked();
Nan::Utf8String name(current_property_name_);
if (helper.get_value(member_id, *name)) {
return true;
}
++current_index_;
}
return false;
}

bool NodeValueReader::members_remaining()
{
if (!property_names_.IsEmpty()) {
while (property_names_.ToLocalChecked()->Length() > current_index_) {
while (current_index_ < property_names_.ToLocalChecked()->Length()) {
Nan::MaybeLocal<v8::Value> mlv = Nan::Get(property_names_.ToLocalChecked(), current_index_);
if (!mlv.IsEmpty()) {
current_property_name_ = mlv.ToLocalChecked();
Nan::Utf8String name(current_property_name_);
if (helper.get_value(member_id, *name)) {
return true;
}
return true;
}
++current_index_;
}
}
return false;
}

bool NodeValueReader::member_has_value()
{
Nan::MaybeLocal<v8::Value> mlvai = current_property_name_.IsEmpty() ?
Nan::Get(current_object_, current_index_) : Nan::Get(current_object_, current_property_name_);
if (!mlvai.IsEmpty()) {
v8::Local<v8::Value> lvai = mlvai.ToLocalChecked();
return !lvai->IsNull();
}
return false;
}

bool NodeValueReader::end_struct_member()
{
++current_index_;
return true;
}

bool NodeValueReader::begin_union()
bool NodeValueReader::begin_union(OpenDDS::DCPS::Extensibility /*extensibility*/)
{
return begin_nested();
}
Expand Down Expand Up @@ -130,7 +151,7 @@ bool NodeValueReader::end_union_member()
return true;
}

bool NodeValueReader::begin_array()
bool NodeValueReader::begin_array(OpenDDS::XTypes::TypeKind /*elem_kind*/)
{
return begin_nested();
}
Expand All @@ -140,7 +161,7 @@ bool NodeValueReader::end_array()
return end_nested();
}

bool NodeValueReader::begin_sequence()
bool NodeValueReader::begin_sequence(OpenDDS::XTypes::TypeKind /*elem_kind*/)
{
return begin_nested();
}
Expand Down Expand Up @@ -290,7 +311,7 @@ bool NodeValueReader::read_float128(long double& value)

#endif

bool NodeValueReader::read_fixed(OpenDDS::FaceTypes::Fixed& /*value*/)
bool NodeValueReader::read_fixed(ACE_CDR::Fixed& /*value*/)
{
return false;
}
Expand Down Expand Up @@ -362,6 +383,24 @@ bool NodeValueReader::read_long_enum(ACE_CDR::Long& value, const OpenDDS::DCPS::
return false;
}

bool NodeValueReader::read_bitmask(ACE_CDR::ULongLong& value, const OpenDDS::DCPS::BitmaskHelper& helper)
{
Nan::MaybeLocal<v8::Value> mlvai = use_name_ ? Nan::Get(current_object_, current_property_name_) : Nan::Get(current_object_, current_index_);
if (!mlvai.IsEmpty()) {
std::string temp;
if (read_string(temp)) {
value = string_to_bitmask(temp, helper);
return true;
}
}

if (primitive_helper<v8::Integer>(value, &v8::Value::IsNumber, strtoull)) {
return true;
}

return false;
}

bool NodeValueReader::begin_nested()
{
Nan::MaybeLocal<v8::Value> mlvai = use_name_ ? Nan::Get(current_object_, current_property_name_) : Nan::Get(current_object_, current_index_);
Expand Down
13 changes: 8 additions & 5 deletions src/NodeValueReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@ class NodeValueReader : public OpenDDS::DCPS::ValueReader {
public:
explicit NodeValueReader(v8::Local<v8::Object> obj);

bool begin_struct();
bool begin_struct(OpenDDS::DCPS::Extensibility extensibility);
bool end_struct();
bool begin_struct_member(OpenDDS::XTypes::MemberId& member_id, const OpenDDS::DCPS::MemberHelper& helper);
bool members_remaining();
bool member_has_value();
bool end_struct_member();

bool begin_union();
bool begin_union(OpenDDS::DCPS::Extensibility extensibility);
bool end_union();
bool begin_discriminator();
bool end_discriminator();
bool begin_union_member();
bool end_union_member();

bool begin_array();
bool begin_array(OpenDDS::XTypes::TypeKind elem_kind);
bool end_array();
bool begin_sequence();
bool begin_sequence(OpenDDS::XTypes::TypeKind elem_kind);
bool elements_remaining();
bool end_sequence();
bool begin_element();
Expand All @@ -67,13 +69,14 @@ class NodeValueReader : public OpenDDS::DCPS::ValueReader {
bool read_float128(long double& value);
#endif

bool read_fixed(OpenDDS::FaceTypes::Fixed& value);
bool read_fixed(ACE_CDR::Fixed& value);
bool read_char8(ACE_CDR::Char& value);
bool read_char16(ACE_CDR::WChar& value);
bool read_string(std::string& value);
bool read_wstring(std::wstring& value);

bool read_long_enum(ACE_CDR::Long& value, const OpenDDS::DCPS::EnumHelper& helper);
bool read_bitmask(ACE_CDR::ULongLong& value, const OpenDDS::DCPS::BitmaskHelper& helper);

private:
NodeValueReader();
Expand Down
Loading
Loading