68 Commits
8.0.1 ... 8.0.7

Author SHA1 Message Date
Andrew Johnson
e069c699e9 Final commit for 8.0.7 2025-12-15 11:44:53 -06:00
Andrew Johnson
8963b2dba1 Add release notes for changes since 8.0.6
- Jeremy Lorelli
- Andrew Johnson
- Dirk Zimoch
- Chris Johns
- Michael Davidsaver
2025-12-15 11:37:47 -06:00
Michael Davidsaver
9ec9a526f5 revise Timer phase reset 2025-12-05 17:01:00 -08:00
Chris Johns
b4114589ff Skip any missed timer events updating the timer to now
This stops a timer calling the callback for every missed event if the
time jumps forward when corrected or moved.
2025-12-05 17:01:00 -08:00
6689c9ce1f Allow testing deprecated functions without causing compiler warnings 2025-12-03 16:47:55 -08:00
Andrew Johnson
0c1773f25d Clang warnings: sprintf() => epicsSnprintf() 2025-12-01 18:20:27 -08:00
Andrew Johnson
d0ff9a9592 CI: Final GHA config adjustments
Don't change the MSC C++ standard when building submodules!
2025-12-01 17:39:24 -06:00
JJL772
bf36070860 Allow Timer to be cancelled during callback execution
Useful for when e.g. a periodic timer needs to cancel itself
2025-11-19 08:49:41 -08:00
Andrew Johnson
5552773e5e CI: Rename and adjust jobs (#102)
* Update Appveyor and GHA CI build configurations to more closely match Base CI.

* Other CI script clean-up
2025-11-10 12:29:19 -06:00
Andrew Johnson
b3a1077270 CI: Update Ubuntu 20.04 to 22.04 2025-05-05 12:26:24 -05:00
Ralph Lange
1c5f75bcd6 Merge pull request #97 from ralphlange/fix-ci
ci: consistent AppVeyor job config for pvData/pvAccess
2024-12-25 09:09:33 +01:00
Ralph Lange
2455039594 ci: consistent AppVeyor job config for pvData/pvAccess 2024-12-24 17:19:59 +01:00
Ralph Lange
f47676c225 Merge pull request #96 from ralphlange/fix-ci
Fix CI issues
2024-12-19 14:42:15 +01:00
Ralph Lange
0881e0ed86 ci: update appveyor.yml from base 2024-12-19 08:48:41 +01:00
Ralph Lange
e457b60b30 ci: Update GHA workflow from base
- Run Fedora in containers
- Add Linux cross builds
2024-12-18 21:32:11 +01:00
Ralph Lange
a6746f8161 GHA: Update actions/upload-artifact to v4 2024-12-16 12:08:55 +01:00
Ralph Lange
144f0228cc ci: update ci-scripts to v3.4.1 2023-12-15 09:40:45 +01:00
Andrew Johnson
7300e6b0bd Set next development version 2023-12-13 14:52:07 -06:00
Andrew Johnson
0ef8a36172 Set version numbers for release 2023-12-13 14:46:12 -06:00
Andrew Johnson
c0be043aaf Replease UNRELEASED 2023-12-13 14:43:07 -06:00
Ralph Lange
dd74289eaf Silence warning about uninitialized local variable
found by static code analysis (cppcheck @ sonarqube)
(that doesn't realize ">>=" calls an overloaded operator)
2023-11-01 09:41:07 -05:00
thomasms
3da69257a0 Remove duplicate doxygen comment - see issue #75 2023-11-01 09:39:33 -05:00
Michael Davidsaver
13e4e577bb gha update 2023-10-22 16:24:15 -07:00
Michael Davidsaver
5387face45 rename print.cpp -> jprint.cpp
In GHA builder somehow print.cpp becomes PRINT.obj
instead of print.obj for mkmf.pl, which later fails
when print.obj is missing.  (apparently windows
filesystems are now case sensitive...)
2023-10-22 16:24:15 -07:00
JJL772
eac2a8e70f Fix use-after-destroy in epicsRefSnapshopCurrent 2023-08-06 21:30:32 -07:00
JJL772
04fcb7e38f Don't return local copy of std::string in AnyScalar::bufferUnsafe 2023-08-06 21:30:32 -07:00
Andrew Johnson
45018a2163 Generate JSON5 when available
Fixes lp: #2029482 / GitHub #92
2023-08-06 21:28:01 -07:00
Simon Rose
b7ad4478a4 Update debugPtr to work with EPICS base 7.0.7
There are at least two changes to EPICS base since the addition of
debugPtr:
* In pvAccess/**/dbdToPv.cpp, a write to an ostream was added (also in
  pvData/**/testSerialization.cpp) which does not resolve correctly when
  the operator<< overload is in the global namespace.
* In pvAccess/**/caChannel.cpp, weak_ptr->expired() was added

The interface to deal with each of these has been added.
2023-05-29 17:09:29 -07:00
Michael Davidsaver
c16f19c80e Flip #if logic for unaligned access
Assume only x86 can correctly/efficiently handle unaligned access.
2023-05-24 21:49:38 -07:00
Michael Davidsaver
87018882d1 ARM/Linux can fault on unaligned access
Sometimes SIGBUS results from unaligned access.
2023-05-24 20:44:32 -07:00
2547514abb fix for use-after-free warning 2023-02-28 09:04:58 -08:00
Michael Davidsaver
9447eacbd2 gha update 2022-11-26 11:15:37 -08:00
Michael Davidsaver
0b424a71ec isprint() wants value in range [-1, 255]
The MSVC impl. assert()s this
2022-11-26 10:52:03 -08:00
Andrew Johnson
45671faaea Set next development version 2022-09-07 10:51:29 -05:00
Andrew Johnson
016d1154fc Set module version number for release 2022-09-07 10:17:07 -05:00
Michael Davidsaver
f3911d5831 add 3.16 build 2022-01-27 09:44:54 -08:00
Michael Davidsaver
93e90c5a04 fix 3.16 2022-01-27 09:27:19 -08:00
Michael Davidsaver
8039c75b3e .ci: update 2022-01-27 07:51:17 -08:00
Michael Davidsaver
a647c8b174 printJSON() use yajl_gen 2022-01-19 10:27:09 -08:00
Michael Davidsaver
d3b4976ea2 Set next development version 2021-02-25 09:36:05 -08:00
Michael Davidsaver
b1c8303870 Update version numbers for release 2021-02-25 09:35:12 -08:00
Michael Davidsaver
a3ef984f4f ci: switch travis -> github 2020-12-20 11:08:29 -08:00
Michael Davidsaver
ca86a63180 update release notes 2020-11-14 13:43:38 -08:00
Michael Davidsaver
07b79693af Deprecate/remove unused buffer alignment tools
ByteBuffer::align() does not work as expected
on some RTEMS targets where malloc() returns
buffers aligned only to 4 bytes.

SerializableControl::alignBuffer() and
DeserializableControl::alignData() are implemented,
but never called, in this module and pvAccessCPP.
ByteBuffer::align() is only needed to implement
these two methods.

Leave non-pure virtual stubs to assist in migration.
2020-11-14 11:07:15 -08:00
Michael Davidsaver
4ef9e18ac6 enable RTEMS CI testing 2020-11-13 20:51:23 -08:00
Michael Davidsaver
320cc3c60b shared_vector_convert<>() fix convert of empty array
Empty arrays can be untyped, but this doesn't matter.
2020-09-29 15:52:49 -07:00
Michael Davidsaver
45d0d76a7f Set next development version 2020-07-26 13:30:34 -07:00
Michael Davidsaver
b2b42d5f8c Update version numbers for release 2020-07-26 13:29:52 -07:00
Michael Davidsaver
90b1f2f6da doc 2020-06-17 14:08:14 -07:00
Michael Davidsaver
2e775ef2fb drop THROW_BASE_EXCEPTION_CAUSE() 2020-06-17 14:08:14 -07:00
Michael Davidsaver
f17d2bbca1 add maybeQuote()
Something for the *NIX gurus
to light their pipes with.
2020-06-17 14:08:14 -07:00
Michael Davidsaver
79b02254c4 update ci-scripts to 3.0.1 2020-06-17 14:06:50 -07:00
Michael Davidsaver
19245ce805 sharedVector extend base_ptr() to VS2013 2020-06-03 10:14:38 -07:00
Andrew Johnson
0fa927afa7 Set next development version 2020-05-28 16:26:00 -05:00
Andrew Johnson
d9b3f98e35 Update version numbers for release 2020-05-28 13:37:15 -05:00
Michael Davidsaver
81e7968230 doc 2020-05-20 14:54:39 -07:00
Michael Davidsaver
06f3b96992 ci-scripts 2.3.2 (with appveyor) 2020-04-27 12:18:16 -07:00
1038182a16 removed empty lines at end of file 2020-04-15 07:53:22 -07:00
60091bfe56 removed spaces at end of line 2020-04-15 07:53:22 -07:00
f4de6dd9b1 replaced tabs with spaces 2020-04-15 07:53:22 -07:00
Michael Davidsaver
3d93a80cce travis switch to ci-scripts 2019-12-20 10:33:03 -08:00
Michael Davidsaver
94eff54fa9 Revert "Properly declare isnan() in C++ testcode"
This reverts commit 07b75e4543.

std:: qualified names not portable until c++11
epicsMath.h changed to ensure that unqualified
names continue to work.
2019-12-19 18:50:33 -08:00
Michael Davidsaver
e9dde4d2f8 update doc 2019-12-13 09:32:42 -08:00
Michael Davidsaver
0a5e22e5b0 testPVData print additional sizes 2019-12-13 09:32:42 -08:00
Michael Davidsaver
3a5cfba4e1 catch exception by ref 2019-12-13 09:32:42 -08:00
Ralph Lange
07b75e4543 Properly declare isnan() in C++ testcode 2019-12-11 13:29:27 +01:00
Michael Davidsaver
e4f150b34f finalize doxygen 2019-11-03 20:03:24 -08:00
Andrew Johnson
ca2ae0d0e7 Incr version and set development flag after release 2019-10-31 17:04:21 -05:00
86 changed files with 1311 additions and 931 deletions

113
.appveyor.yml Normal file
View File

@@ -0,0 +1,113 @@
# .appveyor.yml for use with EPICS Base ci-scripts
# (see: https://github.com/epics-base/ci-scripts)
# This is YAML - indentation levels are crucial
#---------------------------------#
# build cache #
#---------------------------------#
# The AppVeyor cache allowance is way too small (1GB per account across all
# projects, branches and jobs) to be used for the dependency builds.
cache:
- C:\Users\appveyor\.tools
#---------------------------------#
# repository cloning #
#---------------------------------#
init:
# Set autocrlf to make batch files work
- cmd: git config --global core.autocrlf true
clone_depth: 5
#---------------------------------#
# build matrix configuration #
#---------------------------------#
# Build Configurations: dll/static, regular/debug
configuration:
- dynamic
- static
- dynamic-debug
- static-debug
# Environment variables: compiler toolchain, base version, setup file, ...
environment:
# common / default variables for all jobs
SETUP_PATH: .ci-local
EPICS_TEST_IMPRECISE_TIMING: YES
BASE: 7.0
matrix:
- CMP: vs2019
BASE: 3.15
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- CMP: vs2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- CMP: vs2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- CMP: vs2015
- CMP: gcc
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
# TODO: static linking w/ readline isn't working. Bypass auto-detect
COMMANDLINE_LIBRARY: EPICS
# Platform: processor architecture
platform: x64
# Matrix configuration: exclude sets of jobs
matrix:
exclude:
# MinGW debug builds use the same libraries, unlike VS
- configuration: dynamic-debug
CMP: gcc
- configuration: static-debug
CMP: gcc
#---------------------------------#
# building & testing #
#---------------------------------#
install:
- cmd: git submodule update --init --recursive
- cmd: pip install git+https://github.com/mdavidsaver/ci-core-dumper#egg=ci-core-dumper
- cmd: python .ci/cue.py prepare
build_script:
- cmd: python .ci/cue.py build
test_script:
- cmd: python -m ci_core_dumper install
- cmd: python .ci/cue.py -T 20M test
on_finish:
- ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- cmd: python .ci/cue.py -T 5M test-results
on_failure:
- cmd: python -m ci_core_dumper report
#---------------------------------#
# debugging #
#---------------------------------#
## To connect by remote desktop to a failed build, uncomment the lines below.
## You must connect within the usual build timeout limit (60 minutes),
## so adjust the build matrix above to just build the config of interest.
#on_failure:
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#---------------------------------#
# notifications #
#---------------------------------#
notifications:
- provider: Email
to:
- core-talk@aps.anl.gov
on_build_success: false
- provider: GitHubPullRequest

1
.ci Submodule

Submodule .ci added at 20f8e05393

6
.ci-local/defaults.set Normal file
View File

@@ -0,0 +1,6 @@
# EPICS Base
BASE_DIRNAME=base
BASE_REPONAME=epics-base
BASE_REPOOWNER=epics-base
BASE_VARNAME=EPICS_BASE
BASE_RECURSIVE=NO

View File

@@ -1,10 +0,0 @@
#!/bin/sh
set -e -x
make -j2
if [ "$TEST" != "NO" ]
then
make -j2 tapfiles
make -j2 -s test-results
fi

View File

@@ -1,83 +0,0 @@
#!/bin/sh
set -e -x
cat << EOF > configure/RELEASE.local
EPICS_BASE=$HOME/.source/epics-base
EOF
install -d "$HOME/.source"
cd "$HOME/.source"
git clone --quiet --depth 5 --branch "$BRBASE" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base
(cd epics-base && git log -n1 )
EPICS_HOST_ARCH=`sh epics-base/startup/EpicsHostArch`
# requires wine and g++-mingw-w64-i686
if [ "$WINE" = "32" ]
then
echo "Cross mingw32"
sed -i -e '/CMPLR_PREFIX/d' epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
cat << EOF >> epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
CMPLR_PREFIX=i686-w64-mingw32-
EOF
cat << EOF >> epics-base/configure/CONFIG_SITE
CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw
EOF
fi
if [ "$STATIC" = "YES" ]
then
echo "Build static libraries/executables"
cat << EOF >> epics-base/configure/CONFIG_SITE
SHARED_LIBRARIES=NO
STATIC_BUILD=YES
EOF
fi
case "$CMPLR" in
clang)
echo "Host compiler is clang"
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH
GNU = NO
CMPLR_CLASS = clang
CC = clang
CCC = clang++
EOF
# hack
sed -i -e 's/CMPLR_CLASS = gcc/CMPLR_CLASS = clang/' epics-base/configure/CONFIG.gnuCommon
clang --version
;;
*)
echo "Host compiler is default"
gcc --version
;;
esac
cat <<EOF >> epics-base/configure/CONFIG_SITE
USR_CPPFLAGS += $USR_CPPFLAGS
USR_CFLAGS += $USR_CFLAGS
USR_CXXFLAGS += $USR_CXXFLAGS
EOF
# set RTEMS to eg. "4.9" or "4.10"
# requires qemu, bison, flex, texinfo, install-info
if [ -n "$RTEMS" ]
then
echo "Cross RTEMS${RTEMS} for pc386"
curl -L "https://github.com/mdavidsaver/rsb/releases/download/20171203-${RTEMS}/i386-rtems${RTEMS}-trusty-20171203-${RTEMS}.tar.bz2" \
| tar -C / -xmj
sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' epics-base/configure/os/CONFIG_SITE.Common.RTEMS
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.RTEMS
RTEMS_VERSION=$RTEMS
RTEMS_BASE=$HOME/.rtems
EOF
cat << EOF >> epics-base/configure/CONFIG_SITE
CROSS_COMPILER_TARGET_ARCHS += RTEMS-pc386-qemu
EOF
fi
make -j2 -C epics-base $EXTRA

301
.github/workflows/ci-scripts-build.yml vendored Normal file
View File

@@ -0,0 +1,301 @@
# .github/workflows/ci-scripts-build.yml for use with EPICS Base ci-scripts
# (see: https://github.com/epics-base/ci-scripts)
# This is YAML - indentation levels are crucial
# Workflow name, shared by all branches
name: pvData
# Trigger on pushes and PRs to any branch
on:
push:
paths-ignore:
- .appveyor.yml
pull_request:
env:
SETUP_PATH: .ci-local:.ci
EPICS_TEST_IMPRECISE_TIMING: YES
EPICS_TEST_TIMEOUT: 300 # 5 min
jobs:
native:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# Set environment variables from matrix parameters
env:
# NB: PVA modules build against both BASE 7.0 and 3.15
BASE: ${{ matrix.base }}
CMP: ${{ matrix.cmp }}
BCFG: ${{ matrix.configuration }}
CI_CROSS_TARGETS: ${{ matrix.cross }}
EXTRA: ${{ matrix.extra }}
TEST: ${{ matrix.test }}
strategy:
fail-fast: false
matrix:
# Job names also name artifacts, character limitations apply
include:
- name: "7.0 Ub gcc c++20 Werror"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: default
# Turn all warnings into errors,
# except for those we could not fix (yet).
# Remove respective -Wno-error=... flag once it is fixed.
extra: "CMD_CXXFLAGS=-std=c++20
CMD_CPPFLAGS='-fdiagnostics-color
-fstack-protector-strong
-Wformat
-Werror
-Werror=format-security
-Wno-error=deprecated-declarations
-Wno-error=stringop-truncation
-Wno-error=restrict
-Wno-error=sizeof-pointer-memaccess
-Wno-error=nonnull
-Wno-error=dangling-pointer
-Wno-error=format-overflow
-Wno-error=stringop-overread
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3'
CMD_LDFLAGS=-Wl,-z,relro"
- name: "7.0 Ub gcc C++11, static"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: static
extra: "CMD_CXXFLAGS=-std=c++11"
- name: "7.0 Ub gcc u-char"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: static
extra: "CMD_CFLAGS=-funsigned-char CMD_CXXFLAGS=-funsigned-char"
- name: "7.0 Ub clang"
base: "7.0"
os: ubuntu-latest
cmp: clang
configuration: default
- name: "7.0 Ub clang C++11"
base: "7.0"
os: ubuntu-latest
cmp: clang
configuration: default
extra: "CMD_CXXFLAGS=-std=c++11"
- name: "7.0 MacOS clang"
base: "7.0"
os: macos-latest
cmp: clang
configuration: default
# Cross builds
- name: "3.15 Ub-22 gcc + MinGW"
base: "3.15"
os: ubuntu-22.04
cmp: gcc
configuration: default
cross: "windows-x64-mingw"
- name: "7.0 Ub gcc + linux-aarch64"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: default
cross: "linux-aarch64"
- name: "7.0 Ub gcc + linux-arm gnueabi"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: default
cross: "linux-arm@arm-linux-gnueabi"
- name: "7.0 Ub gcc + linux-arm gnueabihf"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: default
cross: "linux-arm@arm-linux-gnueabihf"
- name: "7.0 Ub gcc + MinGW"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: default
cross: "windows-x64-mingw"
- name: "7.0 Ub gcc + MinGW, static"
base: "7.0"
os: ubuntu-latest
cmp: gcc
configuration: static
cross: "windows-x64-mingw"
- name: "7.0 Ub-22 gcc + RT-4.9 pc386"
base: "7.0"
os: ubuntu-22.04
cmp: gcc
configuration: default
cross: "RTEMS-pc386-qemu@4.9"
- name: "7.0 Ub-22 gcc + RT-4.10 pc386"
base: "7.0"
os: ubuntu-22.04
cmp: gcc
configuration: default
cross: "RTEMS-pc386-qemu@4.10"
test: NO
- name: "7.0 Ub-22 gcc + RT-5.1 pc686"
base: "7.0"
os: ubuntu-22.04
cmp: gcc
configuration: default
cross: "RTEMS-pc686-qemu@5"
- name: "7.0 Ub-22 gcc + RT-5.1 beatnik,zynq_a9,uC5282"
base: "7.0"
os: ubuntu-22.04
cmp: gcc
configuration: default
cross: "RTEMS-beatnik@5:RTEMS-xilinx_zynq_a9_qemu@5:RTEMS-uC5282@5"
test: NO
# Windows builds
- name: "7.0 Win-22 MSC-22"
base: "7.0"
os: windows-2022
cmp: vs2022
configuration: default
- name: "7.0 Win-22 MSC-22 static"
base: "7.0"
os: windows-2022
cmp: vs2022
configuration: static
- name: "7.0 Win-22 MSC-22 debug"
base: "7.0"
os: windows-2022
cmp: vs2022
configuration: debug
extra: "CMD_CXXFLAGS=-analyze"
- name: "7.0 Win-22 MinGW"
base: "7.0"
os: windows-2022
cmp: gcc
configuration: default
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Automatic core dumper analysis
uses: mdavidsaver/ci-core-dumper@master
- name: "apt-get install"
run: |
sudo apt-get update
sudo apt-get -y install qemu-system-x86 g++-mingw-w64-x86-64 gdb
if: runner.os == 'Linux'
- name: Prepare and compile dependencies
run: python .ci/cue.py prepare
- name: Build main module
run: python .ci/cue.py build
- name: Run main module tests
run: python .ci/cue.py -T 60M test
- name: Upload tapfiles Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: tapfiles ${{ matrix.name }}
path: '**/O.*/*.tap'
if-no-files-found: ignore
- name: Collect and show test results
if: ${{ always() }}
run: python .ci/cue.py -T 5M test-results
docker:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
# Set environment variables from matrix parameters
env:
BASE: ${{ matrix.base }}
CMP: ${{ matrix.cmp }}
BCFG: ${{ matrix.configuration }}
EXTRA: ${{ matrix.extra }}
TEST: ${{ matrix.test }}
strategy:
fail-fast: false
matrix:
# Job names also name artifacts, character limitations apply
include:
- name: "7.0 CentOS-8 gcc"
base: "7.0"
image: centos:8
cmp: gcc
configuration: default
- name: "7.0 Rocky-9 gcc"
base: "7.0"
image: rockylinux:9
cmp: gcc
configuration: default
- name: "7.0 Fedora-33 gcc"
base: "7.0"
image: fedora:33
cmp: gcc
configuration: default
- name: "7.0 Fedora gcc"
base: "7.0"
image: fedora:latest
cmp: gcc
configuration: default
steps:
- name: "Fix repo URLs on CentOS-8"
# centos:8 is frozen, repos are in the vault
if: matrix.image=='centos:8'
run: |
sed -i -e "s|mirrorlist=|#mirrorlist=|" \
-e "s|#baseurl=http://mirror|baseurl=http://vault|" \
/etc/yum.repos.d/CentOS-Linux-{BaseOS,AppStream,Extras,Plus}.repo
- name: "Redhat setup"
run: |
dnf -y install python3 gdb make perl gcc-c++ glibc-devel readline-devel ncurses-devel perl-devel perl-Test-Simple
git --version || dnf -y install git
python3 --version
- uses: actions/checkout@v4
with:
submodules: true
- name: Automatic core dumper analysis
uses: mdavidsaver/ci-core-dumper@master
- name: Prepare and compile dependencies
run: python3 .ci/cue.py prepare
- name: Build main module
run: python3 .ci/cue.py build
- name: Run main module tests
run: python3 .ci/cue.py -T 20M test
- name: Upload tapfiles Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: tapfiles ${{ matrix.name }}
path: '**/O.*/*.tap'
if-no-files-found: ignore
- name: Collect and show test results
if: ${{ always() }}
run: python3 .ci/cue.py -T 5M test-results

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule ".ci"]
path = .ci
url = https://github.com/epics-base/ci-scripts

View File

@@ -1,43 +0,0 @@
language: c++
addons:
apt:
packages:
- libreadline6-dev
- libncurses5-dev
- perl
- clang
- g++-mingw-w64-i686
- qemu-system-x86
matrix:
include:
- dist: bionic
env: BRBASE=7.0 CMPLR=gcc
- dist: trusty
env: BRBASE=7.0 CMPLR=gcc
- dist: bionic
env: BRBASE=7.0 CMPLR=clang
- dist: trusty
env: BRBASE=7.0 CMPLR=clang
- dist: trusty
env: BRBASE=7.0 USR_CXXFLAGS=-std=c++11
- dist: trusty
env: BRBASE=7.0 CMPLR=clang USR_CXXFLAGS=-std=c++11
- dist: trusty
env: BRBASE=7.0 WINE=32 TEST=NO STATIC=YES
- dist: trusty
env: BRBASE=7.0 WINE=32 TEST=NO STATIC=NO
- dist: trusty
env: BRBASE=7.0 RTEMS=4.10 TEST=NO
- dist: trusty
env: BRBASE=7.0 RTEMS=4.9 TEST=NO
- dist: trusty
env: BRBASE=3.16
- dist: trusty
env: BRBASE=3.15
install:
- ./.ci/travis-prepare.sh
script:
- ./.ci/travis-build.sh

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = "PVData C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 8.0.1-dev
PROJECT_NUMBER = 8.0.7
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@@ -2,7 +2,7 @@
EPICS_PVD_MAJOR_VERSION = 8
EPICS_PVD_MINOR_VERSION = 0
EPICS_PVD_MAINTENANCE_VERSION = 1
EPICS_PVD_MAINTENANCE_VERSION = 7
# Development flag, set to zero for release versions

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = "PVData C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 8.0.0
PROJECT_NUMBER = 8.0.7
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@@ -2,6 +2,51 @@
@page release_notes Release Notes
Release 8.0.7 (Dec 2025)
========================
- Compatible changes
- Allow epics::pvData::Timer to be cancelled during callback execution.
- Clang compiler warnings cleaned up.
- Limit periodic timers to one catch-up after missing many events.
Release 8.0.6 (Dec 2023)
========================
- Compatible changes
- Actually enable JSON-5 output in PVStructure::Formatter::JSON when available.
- Fix unaligned access issues for some ARM/Linux targets.
Release 8.0.5 (Sep 2022)
========================
- Compatible changes
- Internal changes to use the YAJL API for generating JSON and JSON-5 output.
Release 8.0.4 (Feb 2021)
========================
- Incompatible changes
- Remove ByteBuffer::align()
- Compatible changes
- Deprecate SerializableControl::alignBuffer() and DeserializableControl::alignData()
- shared_vector_convert<>() fix convert of empty, untyped, array
Release 8.0.3 (July 2020)
=========================
- Incompatible changes
- Removed THROW_BASE_EXCEPTION_CAUSE() macro which has long ignored its cause.
Any external users should switch to the functionally identical THROW_BASE_EXCEPTION_CAUSE()
- Various printing of functions now conditionally escape strings
including quote '\"' and similar charactors.
Release 8.0.2 (May 2020)
========================
- Changes to documentation and unittests.
No functional changes to library.
Release 8.0.1 (Nov 2019)
==========================

View File

@@ -30,7 +30,7 @@ static FieldCreatePtr fieldCreate = getFieldCreate();
struct CreateRequestImpl {
struct Node
struct Node
{
string name;
vector<Node> nodes;
@@ -55,7 +55,7 @@ struct CreateRequestImpl {
CreateRequestImpl() {}
void removeBlanks(string& str)
{
@@ -129,7 +129,7 @@ struct CreateRequestImpl {
if(pos==string::npos) break;
numValues++;
index = pos +1;
}
}
vector<string> valueList(numValues,"");
index=0;
for(size_t i=0; i<numValues; i++) {
@@ -483,4 +483,3 @@ PVStructure::shared_pointer createRequest(std::string const & request)
}} // namespace

View File

@@ -84,7 +84,7 @@ bool compare(const Structure& a, const Structure& b)
if(&a==&b)
return true;
if (a.getID()!=b.getID())
return false;
return false;
size_t nflds=a.getNumberFields();
if (b.getNumberFields()!=nflds)
return false;
@@ -111,7 +111,7 @@ bool compare(const Union& a, const Union& b)
if(&a==&b)
return true;
if (a.getID()!=b.getID())
return false;
return false;
size_t nflds=a.getNumberFields();
if (b.getNumberFields()!=nflds)
return false;
@@ -268,7 +268,7 @@ bool compareField(const PVUnion* left, const PVUnion* right)
if(*ls!=*right->getUnion())
return false;
if (ls->isVariant())
{
const PVField::const_shared_pointer& lval = left->get();

View File

@@ -24,10 +24,10 @@ using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
static std::vector<string> split(string commaSeparatedList) {
static std::vector<string> split(const string& commaSeparatedList) {
string::size_type numValues = 1;
string::size_type index=0;
while(true) {
@@ -60,7 +60,7 @@ void Convert::getString(string *buf,PVField const *pvField,int /*indentLevel*/)
size_t Convert::fromString(PVStructurePtr const &pvStructure, StringArray const & from, size_t fromStartIndex)
{
size_t processed = 0;
PVFieldPtrArray const & fieldsData = pvStructure->getPVFields();
if (fieldsData.size() != 0) {
size_t length = pvStructure->getStructure()->getNumberFields();
@@ -93,7 +93,7 @@ size_t Convert::fromString(PVStructurePtr const &pvStructure, StringArray const
}
}
}
return processed;
}

View File

@@ -15,6 +15,7 @@
#include <sstream>
#include <epicsString.h>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsThread.h>
@@ -113,7 +114,7 @@ std::tr1::shared_ptr<PVField> Field::build() const
std::ostream& operator<<(std::ostream& o, const Field& f)
{
return f.dump(o);
return f.dump(o);
};
Scalar::Scalar(ScalarType scalarType)
@@ -136,18 +137,18 @@ std::ostream& Scalar::dump(std::ostream& o) const
string Scalar::getID() const
{
static const string idScalarLUT[] = {
"boolean", // pvBoolean
"byte", // pvByte
"short", // pvShort
"int", // pvInt
"long", // pvLong
"ubyte", // pvUByte
"ushort", // pvUShort
"uint", // pvUInt
"ulong", // pvULong
"float", // pvFloat
"double", // pvDouble
"string" // pvString
"boolean", // pvBoolean
"byte", // pvByte
"short", // pvShort
"int", // pvInt
"long", // pvLong
"ubyte", // pvUByte
"ushort", // pvUShort
"uint", // pvUInt
"ulong", // pvULong
"float", // pvFloat
"double", // pvDouble
"string" // pvString
};
return idScalarLUT[scalarType];
}
@@ -227,7 +228,7 @@ static void serializeStructureField(const Structure* structure, ByteBuffer* buff
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = structure->getID();
if (id == Structure::DEFAULT_ID) // TODO slow comparison
if (id == Structure::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(string(), buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
@@ -263,13 +264,13 @@ static StructureConstPtr deserializeStructureField(const FieldCreate* fieldCreat
static void serializeUnionField(const Union* punion, ByteBuffer* buffer, SerializableControl* control)
{
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = punion->getID();
if (id == Union::DEFAULT_ID) // TODO slow comparison
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = punion->getID();
if (id == Union::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(string(), buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
FieldConstPtrArray const & fields = punion->getFields();
StringArray const & fieldNames = punion->getFieldNames();
@@ -297,7 +298,7 @@ static UnionConstPtr deserializeUnionField(const FieldCreate* fieldCreate, ByteB
if (id.empty())
return fieldCreate->createUnion(fieldNames, fields);
else
return fieldCreate->createUnion(id, fieldNames, fields);
return fieldCreate->createUnion(id, fieldNames, fields);
}
Array::Array(Type type)
@@ -323,18 +324,18 @@ ScalarArray::~ScalarArray()
const string ScalarArray::getIDScalarArrayLUT() const
{
static const string idScalarArrayLUT[] = {
"boolean[]", // pvBoolean
"byte[]", // pvByte
"short[]", // pvShort
"int[]", // pvInt
"long[]", // pvLong
"ubyte[]", // pvUByte
"ushort[]", // pvUShort
"uint[]", // pvUInt
"ulong[]", // pvULong
"float[]", // pvFloat
"double[]", // pvDouble
"string[]" // pvString
"boolean[]", // pvBoolean
"byte[]", // pvByte
"short[]", // pvShort
"int[]", // pvInt
"long[]", // pvLong
"ubyte[]", // pvUByte
"ushort[]", // pvUShort
"uint[]", // pvUInt
"ulong[]", // pvULong
"float[]", // pvFloat
"double[]", // pvDouble
"string[]" // pvString
};
return idScalarArrayLUT[elementType];
}
@@ -378,7 +379,8 @@ BoundedScalarArray::BoundedScalarArray(ScalarType elementType, size_t size)
string BoundedScalarArray::getID() const
{
char buffer[32];
sprintf(buffer, "%s<%zu>", ScalarTypeFunc::name(getElementType()), size);
epicsSnprintf(buffer, sizeof(buffer), "%s<%lu>",
ScalarTypeFunc::name(getElementType()), (unsigned long) size);
return string(buffer);
}
@@ -403,7 +405,8 @@ FixedScalarArray::FixedScalarArray(ScalarType elementType, size_t size)
string FixedScalarArray::getID() const
{
char buffer[32];
sprintf(buffer, "%s[%zu]", ScalarTypeFunc::name(getElementType()), size);
epicsSnprintf(buffer, sizeof(buffer), "%s[%lu]",
ScalarTypeFunc::name(getElementType()), (unsigned long) size);
return string(buffer);
}
@@ -427,7 +430,7 @@ StructureArray::~StructureArray()
string StructureArray::getID() const
{
return pstructure->getID() + "[]";
return pstructure->getID() + "[]";
}
std::ostream& StructureArray::dump(std::ostream& o) const
@@ -467,7 +470,7 @@ UnionArray::~UnionArray()
string UnionArray::getID() const
{
return punion->getID() + "[]";
return punion->getID() + "[]";
}
std::ostream& UnionArray::dump(std::ostream& o) const
@@ -555,7 +558,7 @@ Structure::~Structure()
string Structure::getID() const
{
return id;
return id;
}
FieldConstPtr Structure::getField(string const & fieldName) const {
@@ -771,7 +774,7 @@ int32 Union::guess(Type t, ScalarType s) const
string Union::getID() const
{
return id;
return id;
}
FieldConstPtr Union::getField(string const & fieldName) const {
@@ -966,7 +969,7 @@ FieldBuilder::FieldBuilder(const FieldBuilderPtr & _parentBuilder,
{}
FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder,
string const & _nestedName,
string const & _nestedName,
Type _nestedClassToBuild, bool _nestedArray)
:fieldCreate(_parentBuilder->fieldCreate)
,idSet(false)
@@ -979,10 +982,10 @@ FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder,
void FieldBuilder::reset()
{
id.erase();
id.erase();
idSet = false;
fieldNames.clear();
fields.clear();
fieldNames.clear();
fields.clear();
}
FieldBuilderPtr FieldBuilder::begin()
@@ -1001,7 +1004,7 @@ FieldBuilderPtr FieldBuilder::begin(StructureConstPtr S)
FieldBuilderPtr FieldBuilder::setId(string const & id)
{
this->id = id;
idSet = true;
idSet = true;
return shared_from_this();
}
@@ -1023,7 +1026,7 @@ FieldBuilderPtr FieldBuilder::add(string const & name, FieldConstPtr const & fie
} else if(*cur!=*field) {
THROW_EXCEPTION2(std::runtime_error, "duplicate field name w/ different type : "+name);
} // else exact duplicate is silently ignored
return shared_from_this();
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::addArray(string const & name, ScalarType scalarType)
@@ -1065,7 +1068,7 @@ FieldBuilderPtr FieldBuilder::addArray(string const & name, FieldConstPtr const
msg << element->getType();
THROW_EXCEPTION2(std::invalid_argument, msg.str());
}
return add(name, fld);
}
@@ -1100,7 +1103,7 @@ StructureConstPtr FieldBuilder::createStructure()
{
if (parentBuilder.get())
THROW_EXCEPTION2(std::runtime_error, "createStructure() called in nested FieldBuilder");
StructureConstPtr field(static_pointer_cast<const Structure>(createFieldInternal(structure)));
reset();
return field;
@@ -1110,7 +1113,7 @@ UnionConstPtr FieldBuilder::createUnion()
{
if (parentBuilder.get())
THROW_EXCEPTION2(std::runtime_error, "createUnion() called in nested FieldBuilder");
UnionConstPtr field(static_pointer_cast<const Union>(createFieldInternal(union_)));
reset();
return field;
@@ -1178,7 +1181,7 @@ FieldBuilderPtr FieldBuilder::endNested()
{
if (!parentBuilder)
THROW_EXCEPTION2(std::runtime_error, "FieldBuilder::endNested() can only be called to create nested fields");
FieldConstPtr nestedField = createFieldInternal(nestedClassToBuild);
if(createNested) {
@@ -1246,7 +1249,7 @@ ScalarArrayConstPtr FieldCreate::createScalarArray(ScalarType elementType) const
strm << elementType;
THROW_EXCEPTION2(std::invalid_argument, strm.str());
}
return scalarArrays[elementType];
}
@@ -1448,7 +1451,7 @@ static int decodeScalar(int8 code)
pvUInt, // unsigned 32-bits
pvULong // unsigned 64-bits
};
static const int floatLUT[] =
{
-1, // reserved
@@ -1655,4 +1658,3 @@ namespace std{
return o << "nullptr";
}
}

View File

@@ -28,7 +28,7 @@ PVArray::PVArray(FieldConstPtr const & field)
{
capacityMutable = false;
PVField::setImmutable();
}
}
bool PVArray::isCapacityMutable() const
{
@@ -49,7 +49,7 @@ PVArray::PVArray(FieldConstPtr const & field)
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array)
{
return array.dumpValue(manip.stream, manip.index);
return array.dumpValue(manip.stream, manip.index);
}
}}

View File

@@ -144,8 +144,7 @@ PVString::PVString(ScalarConstPtr const & scalar)
std::ostream& PVString::dumpValue(std::ostream& o) const
{
// we escape, but do not quote, for scalar string
o<<escape(get());
o<<maybeQuote(get());
return o;
}
@@ -160,17 +159,17 @@ void PVString::serialize(ByteBuffer *pbuffer,
void PVString::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, size_t offset, size_t count) const
{
// check bounds
// check bounds
const size_t length = storage.value.length();
/*if (offset < 0) offset = 0;
else*/ if (offset > length) offset = length;
//if (count < 0) count = length;
/*if (offset < 0) offset = 0;
else*/ if (offset > length) offset = length;
//if (count < 0) count = length;
const size_t maxCount = length - offset;
if (count > maxCount)
count = maxCount;
// write
const size_t maxCount = length - offset;
if (count > maxCount)
count = maxCount;
// write
SerializeHelper::serializeSubstring(storage.value, offset, count, pbuffer, pflusher);
}
@@ -191,7 +190,7 @@ template<typename T>
PVValueArray<T>::PVValueArray(ScalarArrayConstPtr const & scalarArray)
:base_t(scalarArray)
,value()
{}
PVValueArray<PVStructurePtr>::PVValueArray(StructureArrayConstPtr const & structureArray)
@@ -233,7 +232,7 @@ std::ostream& PVValueArray<T>::dumpValue(std::ostream& o) const
template<>
std::ostream& PVValueArray<std::string>::dumpValue(std::ostream& o, size_t index) const
{
return o << '"' << escape(this->view().at(index)) << '"';
return o << maybeQuote(this->view().at(index));
}
template<>
@@ -244,9 +243,9 @@ std::ostream& PVValueArray<std::string>::dumpValue(std::ostream& o) const
end(v.end());
o << '[';
if(it!=end) {
o << '"' << escape(*it++) << '"';
o << maybeQuote(*it++);
for(; it!=end; ++it)
o << ", \"" << escape(*it) << '"';
o << ", " << maybeQuote(*it);
}
return o << ']';
@@ -627,7 +626,7 @@ PVScalarArrayPtr PVDataCreate::createPVScalarArray(
return PVScalarArrayPtr(new PVStringArray(scalarArray));
}
throw std::logic_error("PVDataCreate::createPVScalarArray should never get here");
}
PVScalarArrayPtr PVDataCreate::createPVScalarArray(
@@ -780,4 +779,3 @@ namespace std{
return o << "nullptr";
}
}

View File

@@ -62,7 +62,7 @@ size_t PVField::getNumberFields() const
void PVField::setImmutable() {immutable = true;}
void PVField::postPut()
void PVField::postPut()
{
if(postHandler) postHandler->postPut();
}
@@ -91,7 +91,7 @@ bool PVField::equals(PVField &pv)
std::ostream& operator<<(std::ostream& o, const PVField& f)
{
return f.dumpValue(o);
return f.dumpValue(o);
};
string PVField::getFullName() const

View File

@@ -38,7 +38,7 @@ PVStructure::PVStructure(StructureConstPtr const & structurePtr)
pvFields.push_back(pvDataCreate->createPVField(fields[i]));
}
for(size_t i=0; i<numberFields; i++) {
pvFields[i]->setParentAndName(this,fieldNames[i]);
pvFields[i]->setParentAndName(this,fieldNames[i]);
}
}
@@ -168,7 +168,7 @@ PVFieldPtr PVStructure::getSubFieldImpl(const char *name, bool throws) const
std::stringstream ss;
ss << "Failed to get field: " << fullName << " ("
<< std::string(fullName, sep) << " not found)";
throw std::runtime_error(ss.str());
throw std::runtime_error(ss.str());
}
else
return PVFieldPtr();
@@ -184,7 +184,7 @@ PVFieldPtr PVStructure::getSubFieldImpl(const char *name, bool throws) const
std::stringstream ss;
ss << "Failed to get field: " << fullName
<< " (" << std::string(fullName, sep)
<< " is not a structure)";
<< " is not a structure)";
throw std::runtime_error(ss.str());
}
else
@@ -307,22 +307,22 @@ std::ostream& PVStructure::dumpValue(std::ostream& o) const
o << format::indent() << getStructure()->getID() << ' ' << getFieldName();
o << std::endl;
{
format::indent_scope s(o);
format::indent_scope s(o);
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
}
return o;
return o;
}

View File

@@ -218,10 +218,10 @@ std::ostream& PVStructureArray::dumpValue(std::ostream& o) const
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
dumpValue(o, i);
}
return o;

View File

@@ -23,7 +23,7 @@ using std::size_t;
using std::string;
namespace epics { namespace pvData {
#define PVUNION_UNDEFINED_INDEX -1
const int32 PVUnion::UNDEFINED_INDEX = PVUNION_UNDEFINED_INDEX;
@@ -75,13 +75,13 @@ PVFieldPtr PVUnion::select(int32 index)
return value;
}
PVFieldPtr PVUnion::select(string const & fieldName)
{
int32 index = variant ? -1 : static_cast<int32>(unionPtr->getFieldIndex(fieldName));
if (index == -1)
if (index == -1)
throw std::invalid_argument("no such fieldName");
return select(index);
return select(index);
}
void PVUnion::set(int32 index, PVFieldPtr const & value)
@@ -94,14 +94,14 @@ void PVUnion::set(int32 index, PVFieldPtr const & value)
{
// for undefined index we accept only null values
if (value)
throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX");
throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX");
}
else if (index < 0 || size_t(index) >= unionPtr->getFields().size())
throw std::invalid_argument("index out of bounds");
else if (!value)
throw std::invalid_argument("Can't set defined index w/ NULL");
else if (value->getField() != unionPtr->getField(index))
throw std::invalid_argument("selected field and its introspection data do not match");
throw std::invalid_argument("selected field and its introspection data do not match");
}
selector = index;
@@ -136,7 +136,7 @@ void PVUnion::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) cons
// write selector value
SerializeHelper::writeSize(selector, pbuffer, pflusher);
// write value, no value for UNDEFINED_INDEX
if (selector != UNDEFINED_INDEX)
if (selector != UNDEFINED_INDEX)
value->serialize(pbuffer, pflusher);
}
}
@@ -180,20 +180,20 @@ std::ostream& PVUnion::dumpValue(std::ostream& o) const
{
o << format::indent() << getUnion()->getID() << ' ' << getFieldName() << std::endl;
{
format::indent_scope s(o);
format::indent_scope s(o);
const PVField::const_shared_pointer& fieldField = get();
if (fieldField.get() == NULL)
o << format::indent() << "(none)" << std::endl;
else
{
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
if (fieldField.get() == NULL)
o << format::indent() << "(none)" << std::endl;
else
{
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
return o;
return o;
}
void PVUnion::copy(const PVUnion& from)

View File

@@ -217,10 +217,10 @@ std::ostream& PVUnionArray::dumpValue(std::ostream& o) const
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
dumpValue(o, i);
}
return o;

View File

@@ -21,7 +21,7 @@
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
static
StructureConstPtr buildValueAlarm(ScalarType vtype)
@@ -123,8 +123,8 @@ StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field,
while(gotValueAlarm) {
if(type==epics::pvData::scalar || type==epics::pvData::scalarArray) {
ScalarType scalarType = (type==epics::pvData::scalar) ?
static_pointer_cast<const Scalar>(field)->getScalarType() :
static_pointer_cast<const ScalarArray>(field)->getElementType();
static_pointer_cast<const Scalar>(field)->getScalarType() :
static_pointer_cast<const ScalarArray>(field)->getElementType();
switch(scalarType) {
case pvBoolean: valueAlarm = booleanAlarmField; break;
case pvByte: valueAlarm = byteAlarmField; break;
@@ -157,7 +157,7 @@ StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field,
if(first->getType()==epics::pvData::scalar
&& second->getType()==epics::pvData::scalarArray) {
ScalarConstPtr scalarFirst = static_pointer_cast<const Scalar>(first);
ScalarArrayConstPtr scalarArraySecond =
ScalarArrayConstPtr scalarArraySecond =
static_pointer_cast<const ScalarArray>(second);
if(scalarFirst->getScalarType()==pvInt
&& scalarArraySecond->getElementType()==pvString) {

View File

@@ -20,7 +20,7 @@
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
StandardPVField::StandardPVField()
: standardField(getStandardField()),

View File

@@ -59,7 +59,7 @@ namespace ScalarTypeFunc {
if(type>=pvBoolean && type<=pvDouble) return true;
return false;
}
static const char* names[] = {
"boolean",
"byte", "short", "int", "long",

View File

@@ -171,7 +171,7 @@ bool printEnumT(std::ostream& strm, const PVStructure& top, bool fromtop)
if(I>=ch.size()) {
strm<<" <undefined>";
} else {
strm<<' '<<escape(ch[I]);
strm<<' '<<maybeQuote(ch[I]);
}
return true;
}
@@ -180,7 +180,7 @@ void csvEscape(std::string& S)
{
// concise, not particularly efficient...
std::string temp(escape(S).style(escape::CSV).str());
if(S.find_first_of(" ,\\")!=S.npos) {// only quote if necessary (stupid Excel)
if(S.find_first_of("\" ,\\")!=S.npos) {// only quote if necessary (stupid Excel)
std::string temp2;
temp2.reserve(temp.size()+2);
temp2.push_back('\"');
@@ -188,7 +188,7 @@ void csvEscape(std::string& S)
temp2.push_back('\"');
temp2.swap(temp);
}
S = temp;
S.swap(temp);
}
bool printTable(std::ostream& strm, const PVStructure& top)
@@ -404,6 +404,9 @@ std::ostream& operator<<(std::ostream& strm, const PVStructure::Formatter& forma
if(format.xfmt==PVStructure::Formatter::JSON) {
JSONPrintOptions opts;
opts.multiLine = false;
#if EPICS_VERSION_INT>=VERSION_INT(7,0,6,1)
opts.json5 = true;
#endif
printJSON(strm, format.xtop, format.xshow ? *format.xshow : BitSet().set(0), opts);
strm<<'\n';
return strm;
@@ -497,7 +500,7 @@ std::ostream& operator<<(std::ostream& strm, const escape& Q)
case '\'': next = '\''; break;
case '\"': next = '\"'; if(Q.S==escape::CSV) quote = '"'; break;
default:
if(!isprint(C)) {
if(!isprint((unsigned char)C)) {
// print three charator escape
strm<<"\\x"<<hexdigit(C>>4)<<hexdigit(C);
} else {
@@ -514,4 +517,38 @@ std::ostream& operator<<(std::ostream& strm, const escape& Q)
return strm;
}
std::ostream& operator<<(std::ostream& strm, const maybeQuote& q)
{
bool esc = false;
for(size_t i=0, N=q.s.size(); i<N && !esc; i++) {
switch(q.s[i]) {
case '\a':
case '\b':
case '\f':
case '\n':
case '\r':
case '\t':
case ' ':
case '\v':
case '\\':
case '\'':
case '\"':
esc = true;
break;
default:
if(!isprint((unsigned char)q.s[i])) {
esc = true;
}
break;
}
}
if(esc) {
strm<<'"'<<escape(q.s)<<'"';
} else {
strm<<q.s;
}
return strm;
}
}} //epics::pvData

View File

@@ -17,7 +17,7 @@ using std::cout;
using std::endl;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
template<typename T>
void copy(
@@ -272,4 +272,3 @@ void copy(
}
}}

View File

@@ -7,4 +7,4 @@ INC += pv/json.h
LIBSRCS += parsehelper.cpp
LIBSRCS += parseany.cpp
LIBSRCS += parseinto.cpp
LIBSRCS += print.cpp
LIBSRCS += jprint.cpp

305
src/json/jprint.cpp Normal file
View File

@@ -0,0 +1,305 @@
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
#include <vector>
#include <sstream>
#include <errlog.h>
#include <yajl_gen.h>
#define epicsExportSharedSymbols
#include <pv/pvdVersion.h>
#include <pv/pvData.h>
#include <pv/valueBuilder.h>
#include <pv/bitSet.h>
#include "pv/json.h"
namespace pvd = epics::pvData;
namespace {
using namespace pvd::yajl;
void yg(yajl_gen_status sts) {
const char *msg = "<\?\?\?>";
switch(sts) {
case yajl_gen_status_ok:
case yajl_gen_generation_complete:
return;
#define CASE(STS) case STS: msg = #STS; break
CASE(yajl_gen_keys_must_be_strings);
CASE(yajl_gen_in_error_state);
CASE(yajl_gen_no_buf);
CASE(yajl_gen_invalid_number);
CASE(yajl_max_depth_exceeded);
#ifdef EPICS_YAJL_VERSION
CASE(yajl_gen_invalid_string);
#endif
#undef CASE
}
throw std::runtime_error(msg);
}
static
void stream_printer(void * ctx,
const char * str,
size_arg len)
{
std::ostream *strm = (std::ostream*)ctx;
strm->write(str, len);
}
struct args {
yajl_gen handle;
const pvd::JSONPrintOptions& opts;
std::string indent;
args(std::ostream& strm,
const pvd::JSONPrintOptions& opts)
:opts(opts)
,indent(opts.indent, ' ')
{
#ifndef EPICS_YAJL_VERSION
yajl_gen_config conf;
conf.beautify = opts.multiLine;
conf.indentString = indent.c_str();
if(!(handle = yajl_gen_alloc2(stream_printer, NULL, NULL, &strm)))
throw std::bad_alloc();
if(opts.json5) {
static bool warned;
if(!warned) {
warned = true;
errlogPrintf("Warning: Ignoring request to print JSON5. Update Base >= 7.0.6.1");
}
}
#else
if(!(handle = yajl_gen_alloc(NULL)))
throw std::bad_alloc();
if(opts.multiLine) {
yajl_gen_config(handle, yajl_gen_beautify, 1);
yajl_gen_config(handle, yajl_gen_indent_string, indent.c_str());
} else {
yajl_gen_config(handle, yajl_gen_beautify, 0);
}
# if EPICS_VERSION_INT>=VERSION_INT(7,0,6,1)
yajl_gen_config(handle, yajl_gen_json5, (int)opts.json5);
# else
if(opts.json5) {
static bool warned;
if(!warned) {
warned = true;
errlogPrintf("Warning: Ignoring request to print JSON5. Update Base >= 7.0.6.1");
}
}
# endif
yajl_gen_config(handle, yajl_gen_print_callback, stream_printer, &strm);
#endif
}
~args() {
yajl_gen_free(handle);
}
};
void yg_string(yajl_gen handle, const std::string& s) {
yg(yajl_gen_string(handle, (const unsigned char*)s.c_str(), s.size()));
}
void show_field(args& A, const pvd::PVField* fld, const pvd::BitSet *mask);
void show_struct(args& A, const pvd::PVStructure* fld, const pvd::BitSet *mask)
{
const pvd::StructureConstPtr& type = fld->getStructure();
const pvd::PVFieldPtrArray& children = fld->getPVFields();
const pvd::StringArray& names = type->getFieldNames();
yg(yajl_gen_map_open(A.handle));
for(size_t i=0, N=names.size(); i<N; i++)
{
if(mask && !mask->get(children[i]->getFieldOffset())) continue;
yg_string(A.handle, names[i]);
show_field(A, children[i].get(), mask);
}
yg(yajl_gen_map_close(A.handle));
}
void show_field(args& A, const pvd::PVField* fld, const pvd::BitSet *mask)
{
switch(fld->getField()->getType())
{
case pvd::scalar:
{
const pvd::PVScalar *scalar=static_cast<const pvd::PVScalar*>(fld);
switch(scalar->getScalar()->getScalarType()) {
case pvd::pvString: yg_string(A.handle, scalar->getAs<std::string>()); break;
case pvd::pvBoolean: yg(yajl_gen_bool(A.handle, scalar->getAs<pvd::boolean>())); break;
case pvd::pvDouble:
case pvd::pvFloat: yg(yajl_gen_double(A.handle, scalar->getAs<double>())); break;
// case pvd::pvULong: // can't always be exactly represented...
default:
yg(yajl_gen_integer(A.handle, scalar->getAs<pvd::int64>())); break;
}
}
return;
case pvd::scalarArray:
{
const pvd::PVScalarArray *scalar=static_cast<const pvd::PVScalarArray*>(fld);
pvd::shared_vector<const void> arr;
scalar->getAs<void>(arr);
yg(yajl_gen_array_open(A.handle));
switch(arr.original_type()) {
case pvd::pvString: {
pvd::shared_vector<const std::string> sarr(pvd::shared_vector_convert<const std::string>(arr));
for(size_t i=0, N=sarr.size(); i<N; i++) {
yg_string(A.handle, sarr[i]);
}
break;
}
case pvd::pvBoolean: {
pvd::shared_vector<const pvd::boolean> sarr(pvd::shared_vector_convert<const pvd::boolean>(arr));
for(size_t i=0, N=sarr.size(); i<N; i++) {
yg(yajl_gen_bool(A.handle, sarr[i]));
}
break;
}
case pvd::pvDouble:
case pvd::pvFloat: {
pvd::shared_vector<const double> sarr(pvd::shared_vector_convert<const double>(arr));
for(size_t i=0, N=sarr.size(); i<N; i++) {
yg(yajl_gen_double(A.handle, sarr[i]));
}
break;
}
default: {
pvd::shared_vector<const pvd::int64> sarr(pvd::shared_vector_convert<const pvd::int64>(arr));
for(size_t i=0, N=sarr.size(); i<N; i++) {
yg(yajl_gen_integer(A.handle, sarr[i]));
}
break;
}
}
yg(yajl_gen_array_close(A.handle));
}
return;
case pvd::structure:
show_struct(A, static_cast<const pvd::PVStructure*>(fld), mask);
return;
case pvd::structureArray:
{
pvd::PVStructureArray::const_svector arr(static_cast<const pvd::PVStructureArray*>(fld)->view());
yg(yajl_gen_array_open(A.handle));
for(size_t i=0, N=arr.size(); i<N; i++) {
if(arr[i])
show_struct(A, arr[i].get(), 0);
else
yg(yajl_gen_null(A.handle));
}
yg(yajl_gen_array_close(A.handle));
}
return;
case pvd::union_:
{
const pvd::PVUnion *U=static_cast<const pvd::PVUnion*>(fld);
const pvd::PVField::const_shared_pointer& C(U->get());
if(!C) {
yg(yajl_gen_null(A.handle));
} else {
show_field(A, C.get(), 0);
}
}
return;
case pvd::unionArray: {
const pvd::PVUnionArray *U=static_cast<const pvd::PVUnionArray*>(fld);
pvd::PVUnionArray::const_svector arr(U->view());
yg(yajl_gen_array_open(A.handle));
for(size_t i=0, N=arr.size(); i<N; i++) {
if(arr[i])
show_field(A, arr[i].get(), 0);
else
yg(yajl_gen_null(A.handle));
}
yg(yajl_gen_array_close(A.handle));
}
return;
}
// should not be reached
if(A.opts.ignoreUnprintable)
yg(yajl_gen_null(A.handle));
else
throw std::runtime_error("Encountered unprintable field type");
}
void expandBS(const pvd::PVStructure& top, pvd::BitSet& mask, bool parents) {
if(mask.get(0)) { // special handling because getSubField(0) not allowed
// wildcard
for(size_t idx=1, N=top.getNumberFields(); idx<N; idx++) {
mask.set(idx);
}
} else {
for(pvd::int32 idx = mask.nextSetBit(0), N=top.getNumberFields(); idx>=0 && idx<N; idx=mask.nextSetBit(idx+1)) {
pvd::PVField::const_shared_pointer fld = top.getSubFieldT(idx);
// look forward and mark all children
for(size_t i=idx+1, N=fld->getNextFieldOffset(); i<N; i++)
mask.set(i);
if(parents) {
// look back and mark all parents
// we've already stepped past all parents so siblings will not be automatically marked
for(const pvd::PVStructure *parent = fld->getParent(); parent; parent = parent->getParent()) {
mask.set(parent->getFieldOffset());
}
}
}
}
}
} // namespace
namespace epics{namespace pvData{
JSONPrintOptions::JSONPrintOptions()
:multiLine(true)
,ignoreUnprintable(true)
,indent(0)
,json5(false)
{}
void printJSON(std::ostream& strm,
const PVStructure& val,
const BitSet& mask,
const JSONPrintOptions& opts)
{
args A(strm, opts);
pvd::BitSet emask(mask);
expandBS(val, emask, true);
if(!emask.get(0)) return;
show_struct(A, &val, &emask);
}
void printJSON(std::ostream& strm,
const PVField& val,
const JSONPrintOptions& opts)
{
args A(strm, opts);
show_field(A, &val, 0);
}
}} // namespace epics::pvData

View File

@@ -1,231 +0,0 @@
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
#include <vector>
#include <sstream>
#define epicsExportSharedSymbols
#include <pv/pvdVersion.h>
#include <pv/pvData.h>
#include <pv/valueBuilder.h>
#include <pv/bitSet.h>
#include "pv/json.h"
namespace pvd = epics::pvData;
namespace {
struct args {
std::ostream& strm;
const pvd::JSONPrintOptions& opts;
unsigned indent;
args(std::ostream& strm,
const pvd::JSONPrintOptions& opts)
:strm(strm)
,opts(opts)
,indent(opts.indent)
{}
void doIntent() {
if(!opts.multiLine) return;
strm.put('\n');
unsigned i=indent;
while(i--) strm.put(' ');
}
};
void show_field(args& A, const pvd::PVField* fld, const pvd::BitSet *mask);
void show_struct(args& A, const pvd::PVStructure* fld, const pvd::BitSet *mask)
{
const pvd::StructureConstPtr& type = fld->getStructure();
const pvd::PVFieldPtrArray& children = fld->getPVFields();
const pvd::StringArray& names = type->getFieldNames();
A.strm.put('{');
A.indent++;
bool first = true;
for(size_t i=0, N=names.size(); i<N; i++)
{
if(mask && !mask->get(children[i]->getFieldOffset())) continue;
if(first)
first = false;
else
A.strm.put(',');
A.doIntent();
A.strm<<'\"'<<names[i]<<"\": ";
show_field(A, children[i].get(), mask);
}
A.indent--;
A.doIntent();
A.strm.put('}');
}
void show_field(args& A, const pvd::PVField* fld, const pvd::BitSet *mask)
{
switch(fld->getField()->getType())
{
case pvd::scalar:
{
const pvd::PVScalar *scalar=static_cast<const pvd::PVScalar*>(fld);
if(scalar->getScalar()->getScalarType()==pvd::pvString) {
A.strm<<'\"'<<scalar->getAs<std::string>()<<'\"';
} else {
A.strm<<scalar->getAs<std::string>();
}
}
return;
case pvd::scalarArray:
{
const pvd::PVScalarArray *scalar=static_cast<const pvd::PVScalarArray*>(fld);
const bool isstring = scalar->getScalarArray()->getElementType()==pvd::pvString;
pvd::shared_vector<const void> arr;
scalar->getAs<void>(arr);
pvd::shared_vector<const std::string> sarr(pvd::shared_vector_convert<const std::string>(arr));
A.strm.put('[');
for(size_t i=0, N=sarr.size(); i<N; i++) {
if(i!=0)
A.strm.put(',');
if(isstring)
A.strm.put('\"');
A.strm<<sarr[i];
if(isstring)
A.strm.put('\"');
}
A.strm.put(']');
}
return;
case pvd::structure:
show_struct(A, static_cast<const pvd::PVStructure*>(fld), mask);
return;
case pvd::structureArray:
{
pvd::PVStructureArray::const_svector arr(static_cast<const pvd::PVStructureArray*>(fld)->view());
A.strm.put('[');
A.indent++;
for(size_t i=0, N=arr.size(); i<N; i++) {
if(i!=0)
A.strm.put(',');
A.doIntent();
if(arr[i])
show_struct(A, arr[i].get(), 0);
else
A.strm<<"NULL";
}
A.indent--;
A.doIntent();
A.strm.put(']');
}
return;
case pvd::union_:
{
const pvd::PVUnion *U=static_cast<const pvd::PVUnion*>(fld);
const pvd::PVField::const_shared_pointer& C(U->get());
if(!C) {
A.strm<<"null";
} else {
show_field(A, C.get(), 0);
}
}
return;
case pvd::unionArray: {
const pvd::PVUnionArray *U=static_cast<const pvd::PVUnionArray*>(fld);
pvd::PVUnionArray::const_svector arr(U->view());
A.strm.put('[');
A.indent++;
for(size_t i=0, N=arr.size(); i<N; i++) {
if(i!=0)
A.strm.put(',');
A.doIntent();
if(arr[i])
show_field(A, arr[i].get(), 0);
else
A.strm<<"NULL";
}
A.indent--;
A.doIntent();
A.strm.put(']');
}
return;
}
// should not be reached
if(A.opts.ignoreUnprintable)
A.strm<<"// unprintable field type";
else
throw std::runtime_error("Encountered unprintable field type");
}
void expandBS(const pvd::PVStructure& top, pvd::BitSet& mask, bool parents) {
if(mask.get(0)) { // special handling because getSubField(0) not allowed
// wildcard
for(size_t idx=1, N=top.getNumberFields(); idx<N; idx++) {
mask.set(idx);
}
} else {
for(pvd::int32 idx = mask.nextSetBit(0), N=top.getNumberFields(); idx>=0 && idx<N; idx=mask.nextSetBit(idx+1)) {
pvd::PVField::const_shared_pointer fld = top.getSubFieldT(idx);
// look forward and mark all children
for(size_t i=idx+1, N=fld->getNextFieldOffset(); i<N; i++)
mask.set(i);
if(parents) {
// look back and mark all parents
// we've already stepped past all parents so siblings will not be automatically marked
for(const pvd::PVStructure *parent = fld->getParent(); parent; parent = parent->getParent()) {
mask.set(parent->getFieldOffset());
}
}
}
}
}
} // namespace
namespace epics{namespace pvData{
JSONPrintOptions::JSONPrintOptions()
:multiLine(true)
,ignoreUnprintable(true)
,indent(0)
{}
void printJSON(std::ostream& strm,
const PVStructure& val,
const BitSet& mask,
const JSONPrintOptions& opts)
{
args A(strm, opts);
pvd::BitSet emask(mask);
expandBS(val, emask, true);
if(!emask.get(0)) return;
show_struct(A, &val, &emask);
}
void printJSON(std::ostream& strm,
const PVField& val,
const JSONPrintOptions& opts)
{
args A(strm, opts);
show_field(A, &val, 0);
}
}} // namespace epics::pvData

View File

@@ -44,6 +44,7 @@ struct epicsShareClass JSONPrintOptions
bool multiLine; //!< include new lines
bool ignoreUnprintable;//!< ignore union/union array when encountered
unsigned indent; //!< Initial indentation (# of spaces)
bool json5; //!< Output extended JSON (eg. NaN). @since 8.1.0
JSONPrintOptions();
};

View File

@@ -31,7 +31,7 @@ AnyScalar::AnyScalar(const AnyScalar& o)
}
#if __cplusplus>=201103L
AnyScalar::AnyScalar(AnyScalar&& o)
AnyScalar::AnyScalar(AnyScalar&& o) noexcept
:_stype(o._stype)
{
typedef std::string string;
@@ -136,7 +136,7 @@ void AnyScalar::swap(AnyScalar& o) {
}
const void* AnyScalar::bufferUnsafe() const {
if(_stype==pvString) {
return as<std::string>().c_str();
return ref<std::string>().c_str();
} else {
return _wrap.blob;
}

View File

@@ -42,12 +42,12 @@
#define CHECK_POST() assert(words.empty() || words.back()!=0)
namespace epics { namespace pvData {
BitSet::shared_pointer BitSet::create(uint32 nbits)
{
return BitSet::shared_pointer(new BitSet(nbits));
}
BitSet::BitSet() {}
BitSet::BitSet(uint32 nbits)
@@ -327,7 +327,7 @@ namespace epics { namespace pvData {
SerializeHelper::writeSize(len, buffer, flusher);
flusher->ensureBuffer(len);
n = len / 8;
n = len / 8;
for (uint32 i = 0; i < n; i++)
buffer->putLong(words[i]);
@@ -338,7 +338,7 @@ namespace epics { namespace pvData {
void BitSet::deserialize(ByteBuffer* buffer, DeserializableControl* control) {
uint32 bytes = static_cast<uint32>(SerializeHelper::readSize(buffer, control)); // in bytes
uint32 bytes = static_cast<uint32>(SerializeHelper::readSize(buffer, control)); // in bytes
size_t wordsInUse = (bytes + 7) / BYTES_PER_WORD;
words.resize(wordsInUse);

View File

@@ -35,7 +35,7 @@ void shared_ptr_base::track_new()
}
// create new tracker if ptr!=nullptr, otherwise clear
void shared_ptr_base::track_new(void* ptr)
void shared_ptr_base::track_new(const void* ptr)
{
track_clear();
if(ptr){

View File

@@ -27,7 +27,7 @@
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
Event::~Event() {

View File

@@ -123,7 +123,7 @@ public:
AnyScalar(const AnyScalar& o);
#if __cplusplus>=201103L
AnyScalar(AnyScalar&& o);
AnyScalar(AnyScalar&& o) noexcept;
#endif
inline ~AnyScalar() {clear();}
@@ -140,7 +140,7 @@ public:
}
#if __cplusplus>=201103L
inline AnyScalar& operator=(AnyScalar&& o) {
inline AnyScalar& operator=(AnyScalar&& o) noexcept {
clear();
swap(o);
return *this;

View File

@@ -150,14 +150,17 @@ struct swap<8> {
#undef _PVA_swap64
/* PVD serialization doesn't pay attention to alignement,
* which some targets really care about and treat unaligned
* which some targets (ARM and powerpc) really care about and treat unaligned
* access as a fault, or with a heavy penalty (~= to a syscall).
*
* For those targets,, we will have to live with the increase
* in execution time and/or object code size of byte-wise copy.
*
* Treat x86 32/64 as an outlier, and assume all other targets
* need, or greatly benefit, from aligned access.
*/
#ifdef _ARCH_PPC
#if !(defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86))
template<typename T>
union alignu {
@@ -494,23 +497,6 @@ public:
{
return sizeof(T)>1 && _reverseEndianess;
}
/**
* Adjust position to the next multiple of 'size.
* @param size The alignment requirement, must be a power of 2. (unchecked)
* @param fill value to use for padding bytes (default '\0').
*
* @note This alignment is absolute, not necessarily with respect to _buffer.
*/
inline void align(std::size_t size, char fill='\0')
{
const std::size_t k = size - 1, bufidx = (std::size_t)_position;
if(bufidx&k) {
std::size_t npad = size-(bufidx&k);
assert(npad<=getRemaining());
std::fill(_position, _position+npad, fill);
_position += npad;
}
}
/**
* Put a boolean value into the byte buffer.
*

View File

@@ -78,7 +78,7 @@ protected:
// add ourselves to tracker
void track_new();
// create new tracker if ptr!=nullptr, otherwise clear
void track_new(void* ptr);
void track_new(const void* ptr);
// copy tracker and add ourself
void track_assign(const shared_ptr_base& o);
void track_clear();
@@ -286,6 +286,7 @@ public:
long use_count() const noexcept { return real.use_count(); }
bool unique() const noexcept { return real.unique(); }
bool expired() const noexcept { return real.expired(); }
};
template<class Base>
@@ -316,13 +317,12 @@ do_enable_shared_from_this(const shared_ptr<Store>& dest,
self->xxInternalSelf = actual;
}
}} // namespace epics::debug
template<typename T>
inline std::ostream& operator<<(std::ostream& strm, const epics::debug::shared_ptr<T>& ptr)
inline std::ostream& operator<<(std::ostream& strm, const shared_ptr<T>& ptr)
{
strm<<ptr.get();
return strm;
}
}} // namespace epics::debug
#endif // DEBUGPTR_H

View File

@@ -229,7 +229,6 @@ private:
#endif
#define THROW_BASE_EXCEPTION(msg) THROW_EXCEPTION2(::epics::pvData::BaseException, msg)
#define THROW_BASE_EXCEPTION_CAUSE(msg, cause) THROW_EXCEPTION2(::epics::pvData::BaseException, msg)
}
}

View File

@@ -16,6 +16,14 @@
#include <shareLib.h>
#if defined(PVD_INTERNAL)
# define PVD_DEPRECATED(msg)
#elif __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5
# define PVD_DEPRECATED(msg) __attribute__((deprecated(msg)))
#else
# define PVD_DEPRECATED(msg) EPICS_DEPRECATED
#endif
namespace epics { namespace pvData {
class SerializableControl;
@@ -47,11 +55,7 @@ namespace epics { namespace pvData {
* @param size The number of bytes.
*/
virtual void ensureBuffer(std::size_t size) =0;
/**
* Add pad bytes to buffer.
* @param alignment alignment required.
*/
virtual void alignBuffer(std::size_t alignment) =0;
virtual void alignBuffer(std::size_t alignment) PVD_DEPRECATED("Deprecated for lack of use") {}
/**
* Method for serializing primitive array data.
* Hook for supplying custom serialization implementation.
@@ -98,14 +102,8 @@ namespace epics { namespace pvData {
* @param size The number of bytes.
*/
virtual void ensureData(std::size_t size) =0;
/**
* Align buffer.
* Note that this takes care only current buffer alignment.
* If streaming protocol is used,
* care must be taken that entire stream is aligned.
* @param alignment size in bytes, must be power of two.
*/
virtual void alignData(std::size_t alignment) =0;
// Deprecated for lack of use
virtual void alignData(std::size_t alignment) PVD_DEPRECATED("Deprecated for lack of use") {};
/**
* Method for deserializing array data.
* Hook for supplying custom deserialization implementation.
@@ -150,7 +148,7 @@ namespace epics { namespace pvData {
*/
virtual void serialize(ByteBuffer *buffer,
SerializableControl *flusher) const = 0;
/**
/**
* Deserialize buffer.
* @param buffer serialization buffer.
* @param flusher deserialization control.
@@ -213,7 +211,7 @@ namespace epics { namespace pvData {
*/
virtual void serialize(ByteBuffer *buffer,
SerializableControl *flusher,BitSet *bitSet) const = 0;
/**
/**
* Deserialize buffer.
* @param buffer serialization buffer.
* @param flusher deserialization control.

View File

@@ -434,11 +434,11 @@ public:
_E_non_const* temp=new _E_non_const[i];
try{
std::copy(begin(), begin()+new_count, temp);
this->m_sdata.reset(temp, detail::default_array_deleter<E*>());
}catch(...){
delete[] temp;
throw;
}
this->m_sdata.reset(temp, detail::default_array_deleter<E*>());
this->m_offset = 0;
this->m_count = new_count;
this->m_total = i;
@@ -481,11 +481,11 @@ public:
std::copy(begin(),
begin()+n,
temp);
this->m_sdata.reset(temp, detail::default_array_deleter<pointer>());
}catch(...){
delete[] temp;
throw;
}
this->m_sdata.reset(temp, detail::default_array_deleter<pointer>());
this->m_offset= 0;
this->m_count = i;
this->m_total = new_total;
@@ -544,11 +544,11 @@ private:
/* Hack alert.
* For reasons of simplicity and efficiency, we want to use raw pointers for iteration.
* However, shared_ptr::get() isn't defined when !m_sdata, although practically it gives NULL.
* Unfortunately, many of the MSVC (<= VS 2010) STL methods assert() that iterators are never NULL.
* Unfortunately, many of the MSVC (<= VS 2013) STL methods assert() that iterators are never NULL.
* So we fudge here by abusing 'this' so that our iterators are always !NULL.
*/
inline E* base_ptr() const {
#if defined(_MSC_VER) && _MSC_VER<=1600
#if defined(_MSC_VER) && _MSC_VER<=1800
return this->m_count ? this->m_sdata.get() : (E*)(this-1);
#else
return this->m_sdata.get();
@@ -837,9 +837,13 @@ namespace detail {
typedef typename meta::strip_const<TO>::type to_t;
ScalarType stype = src.original_type(),
dtype = (ScalarType)ScalarTypeID<TO>::value;
if(stype==dtype) {
if(src.empty()) {
return shared_vector<TO>();
} else if(stype==dtype) {
// no convert needed
return shared_vector<TO>(src, detail::_shared_vector_cast_tag());
} else {
// alloc and convert
shared_vector<to_t> ret(src.size()/ScalarTypeFunc::elementSize(stype));

View File

@@ -28,10 +28,10 @@ namespace epics { namespace pvData {
class epicsShareClass Status : public epics::pvData::Serializable {
public:
POINTER_DEFINITIONS(Status);
/**
* Status type enum.
*/
enum StatusType {
/**
* Status type enum.
*/
enum StatusType {
/** Operation completed successfully. */
STATUSTYPE_OK,
/** Operation completed successfully, but there is a warning message. */
@@ -40,11 +40,11 @@ namespace epics { namespace pvData {
STATUSTYPE_ERROR,
/** Operation failed due to an unexpected error. */
STATUSTYPE_FATAL
};
static const char* StatusTypeName[];
static Status Ok;
};
static const char* StatusTypeName[];
static Status Ok;
static inline Status warn(const std::string& m) { return Status(STATUSTYPE_WARNING, m); }
static inline Status error(const std::string& m) { return Status(STATUSTYPE_ERROR, m); }
@@ -54,10 +54,10 @@ namespace epics { namespace pvData {
* Creates OK status; STATUSTYPE_OK, empty message and stackDump.
*/
Status() :m_statusType(STATUSTYPE_OK) {}
/**
* Create non-OK status.
*/
/**
* Create non-OK status.
*/
Status(StatusType type, std::string const & message);
/**

View File

@@ -60,6 +60,8 @@ private:
epicsTime timeToRun;
double period;
bool onList;
bool cancelled;
bool processing;
friend class Timer;
struct IncreasingTime;
};

View File

@@ -237,6 +237,14 @@ public:
std::ostream& operator<<(std::ostream& strm, const escape& Q);
};
struct maybeQuote {
const std::string& s;
maybeQuote(const std::string& s) :s(s) {}
};
epicsShareExtern
std::ostream& operator<<(std::ostream& strm, const maybeQuote& q);
}} // end namespace
#endif // PVTYPECAST_H

View File

@@ -271,10 +271,10 @@ char* epicsRefSnapshotCurrent()
snap.update();
std::ostringstream strm;
strm<<snap;
const char *str = strm.str().c_str();
char *ret = (char*)malloc(strlen(str)+1);
std::string str = strm.str();
char *ret = (char*)malloc(str.length()+1);
if(ret)
strcpy(ret, str);
strcpy(ret, str.c_str());
return ret;
}catch(std::exception& e){
return epicsStrDup(e.what());

View File

@@ -32,7 +32,7 @@ namespace epics {
}
void SerializeHelper::writeSize(std::size_t s, ByteBuffer* buffer) {
if(s==(std::size_t)-1) // null // TODO remove
if(s==(std::size_t)-1) // null not a size, but used in PVUnion::serialize()
buffer->putByte(-1);
else if(s<254)
buffer->putByte(static_cast<int8>(s));
@@ -103,7 +103,7 @@ namespace epics {
DeserializableControl* control) {
std::size_t size = SerializeHelper::readSize(buffer, control);
if(size!=(size_t)-1) // TODO null strings check, to be removed in the future
if(size!=(size_t)-1) // TODO null strings check, to be removed in the future
{
if (buffer->getRemaining()>=size)
{
@@ -174,14 +174,6 @@ struct ToString : public epics::pvData::SerializableControl
assert(bufwrap.getRemaining()>0);
}
virtual void alignBuffer(std::size_t alignment)
{
if(bufwrap.getRemaining()<alignment)
flushSerializeBuffer();
assert(bufwrap.getRemaining()>=alignment);
bufwrap.align(alignment);
}
virtual bool directSerialize(
ByteBuffer *existingBuffer,
const char* toSerialize,
@@ -232,16 +224,6 @@ struct FromString : public epics::pvData::DeserializableControl
throw std::logic_error("Incomplete buffer");
}
virtual void alignData(std::size_t alignment)
{
size_t pos = buf.getPosition(), k = alignment-1;
if(pos&k) {
std::size_t npad = alignment-(pos&k);
ensureData(npad);
buf.align(alignment);
}
}
virtual bool directDeserialize(
ByteBuffer *existingBuffer,
char* deserializeTo,

View File

@@ -32,7 +32,7 @@ Status::Status(StatusType type, string const & message, string const & stackDump
if (type == STATUSTYPE_OK)
throw std::invalid_argument("type == STATUSTYPE_OK");
}
void Status::maximize(const Status& o)
{
if(m_statusType < o.m_statusType) {
@@ -44,40 +44,40 @@ void Status::maximize(const Status& o)
void Status::serialize(ByteBuffer *buffer, SerializableControl *flusher) const
{
flusher->ensureBuffer(1);
if (m_statusType == STATUSTYPE_OK)
{
// special code for okStatus (optimization)
buffer->putByte((int8)-1);
}
else
{
buffer->putByte((int8)m_statusType);
SerializeHelper::serializeString(m_message, buffer, flusher);
SerializeHelper::serializeString(m_stackDump, buffer, flusher);
}
flusher->ensureBuffer(1);
if (m_statusType == STATUSTYPE_OK)
{
// special code for okStatus (optimization)
buffer->putByte((int8)-1);
}
else
{
buffer->putByte((int8)m_statusType);
SerializeHelper::serializeString(m_message, buffer, flusher);
SerializeHelper::serializeString(m_stackDump, buffer, flusher);
}
}
void Status::deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
{
flusher->ensureData(1);
int8 typeCode = buffer->getByte();
if (typeCode == (int8)-1)
{
// in most of the cases status will be OK, we statistically optimize
if (m_statusType != STATUSTYPE_OK)
{
m_statusType = STATUSTYPE_OK;
flusher->ensureData(1);
int8 typeCode = buffer->getByte();
if (typeCode == (int8)-1)
{
// in most of the cases status will be OK, we statistically optimize
if (m_statusType != STATUSTYPE_OK)
{
m_statusType = STATUSTYPE_OK;
m_message.clear();
m_stackDump.clear();
}
}
else
{
m_statusType = (StatusType)typeCode;
m_message = SerializeHelper::deserializeString(buffer, flusher);
m_stackDump = SerializeHelper::deserializeString(buffer, flusher);
}
}
}
else
{
m_statusType = (StatusType)typeCode;
m_message = SerializeHelper::deserializeString(buffer, flusher);
m_stackDump = SerializeHelper::deserializeString(buffer, flusher);
}
}
void Status::dump(std::ostream& o) const

View File

@@ -19,11 +19,13 @@
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
TimerCallback::TimerCallback()
: period(0.0),
onList(false)
onList(false),
cancelled(false),
processing(false)
{
}
@@ -50,6 +52,7 @@ void Timer::addElement(TimerCallbackPtr const & timerCallback)
temp.push_back(timerCallback);
timerCallback->onList = true;
timerCallback->cancelled = false;
// merge sorted lists.
// for us effectively insertion sort.
@@ -60,6 +63,11 @@ void Timer::addElement(TimerCallbackPtr const & timerCallback)
bool Timer::cancel(TimerCallbackPtr const &timerCallback)
{
Lock xx(mutex);
/* If we're processing, just set the cancel flag */
if (timerCallback->processing) {
timerCallback->cancelled = true;
return true;
}
if(!timerCallback->onList) return false;
if(!alive) {
timerCallback->onList = false;
@@ -107,6 +115,7 @@ void Timer::run()
TimerCallbackPtr work;
work.swap(queue.front());
work->onList = false;
work->processing = true;
queue.pop_front();
{
@@ -115,7 +124,15 @@ void Timer::run()
work->callback();
}
if(work->period > 0.0 && alive) {
work->processing = false;
if(work->period > 0.0 && alive && !work->cancelled) {
if(waitfor <= -work->period) {
// Periodic timer phase has fallen behind by at least one full period.
// Could be due to previous slow jobs, or a system time jump forward.
// Reset the phase.
work->timeToRun = now = epicsTime::getCurrent();
}
work->timeToRun += work->period;
addElement(work);
}

View File

@@ -30,9 +30,9 @@ static void castVTyped(size_t count, void *draw, const void *sraw)
{
TO *dest=(TO*)draw;
const FROM *src=(FROM*)sraw;
//std::transform(src, src+count, dest, castUnsafe<TO,FROM>);
try {
for(size_t i=0; i<count; i++) {
dest[i] = castUnsafe<TO,FROM>(src[i]);

View File

@@ -20,7 +20,7 @@
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
AlarmSeverity AlarmSeverityFunc::getSeverity(int value)
{

View File

@@ -44,11 +44,6 @@ public:
//default constructors and destructor are OK
//returns (false,true) if pvField(is not, is) a valid alarm structure
//An automatic detach is issued if already attached.
/*
* Attach to a field of a PVData object.
* @param pvField The pvField.
* @return (false,true) if the pvField (is not, is) an alarm structure.
*/
/*
* Attach to a field of a PVData object.
* @param pvField The pvField.

View File

@@ -18,7 +18,7 @@
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
string PVAlarm::noAlarmFound("No alarm structure found");
string PVAlarm::notAttached("Not attached to an alarm structure");

View File

@@ -15,7 +15,7 @@
#include <pv/pvData.h>
#include <pv/pvControl.h>
namespace epics { namespace pvData {
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
using std::string;

View File

@@ -18,7 +18,7 @@
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
string PVDisplay::noDisplayFound("No display structure found");
string PVDisplay::notAttached("Not attached to an display structure");

View File

@@ -18,7 +18,7 @@
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
string PVEnumerated::notFound("No enumerated structure found");
string PVEnumerated::notAttached("Not attached to an enumerated structure");

View File

@@ -18,7 +18,7 @@
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
namespace epics { namespace pvData {
string PVTimeStamp::noTimeStamp("No timeStamp structure found");
string PVTimeStamp::notAttached("Not attached to a timeStamp structure");
@@ -93,5 +93,5 @@ bool PVTimeStamp::set(TimeStamp const & timeStamp)
}
return returnValue;
}
}}

View File

@@ -19,7 +19,7 @@
#include <pv/pvType.h>
#include <pv/timeStamp.h>
namespace epics { namespace pvData {
namespace epics { namespace pvData {
const int32 milliSecPerSec = 1000;
const int32 microSecPerSec = 1000000;

View File

@@ -948,11 +948,11 @@ public:
typedef PVUnion & reference;
typedef const PVUnion & const_reference;
/**
* Undefined index.
* Default value upon PVUnion construction. Can be set by the user.
* Corresponds to @c null value.
*/
/**
* Undefined index.
* Default value upon PVUnion construction. Can be set by the user.
* Corresponds to @c null value.
*/
static const int32 UNDEFINED_INDEX;
/**
@@ -1081,9 +1081,9 @@ private:
friend class PVDataCreate;
UnionConstPtr unionPtr; // same as PVField::getField()
int32 selector;
PVFieldPtr value;
bool variant;
int32 selector;
PVFieldPtr value;
bool variant;
EPICS_NOT_COPYABLE(PVUnion)
};

View File

@@ -24,14 +24,6 @@
#include <pv/pvdVersion.h>
#include <shareLib.h>
#if defined(PVD_INTERNAL)
# define PVD_DEPRECATED(msg)
#elif __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5
# define PVD_DEPRECATED(msg) __attribute__((deprecated(msg)))
#else
# define PVD_DEPRECATED(msg) EPICS_DEPRECATED
#endif
#define PVD_DEPRECATED_52 PVD_DEPRECATED("See https://github.com/epics-base/pvDataCPP/issues/52")
/* C++11 keywords
@@ -1079,12 +1071,12 @@ public:
//! Create a new instance of in-line @c Field builder pre-initialized with and existing Structure
static FieldBuilderPtr begin(StructureConstPtr S);
/**
* Set ID of an object to be created.
* @param id id to be set.
/**
* Set ID of an object to be created.
* @param id id to be set.
* @return this instance of a @c FieldBuilder.
*/
FieldBuilderPtr setId(std::string const & id);
*/
FieldBuilderPtr setId(std::string const & id);
/**
* Add a @c Scalar.
@@ -1214,20 +1206,20 @@ private:
FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const Union*);
FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const UnionArray*);
FieldBuilder(FieldBuilderPtr const & parentBuilder,
std::string const & nestedName,
Type nestedClassToBuild, bool nestedArray);
std::string const & nestedName,
Type nestedClassToBuild, bool nestedArray);
const Field *findField(const std::string& name, Type ftype);
void reset();
FieldConstPtr createFieldInternal(Type type);
void reset();
FieldConstPtr createFieldInternal(Type type);
friend class FieldCreate;
const FieldCreatePtr fieldCreate;
std::string id;
bool idSet;
std::string id;
bool idSet;
StringArray fieldNames;
FieldConstPtrArray fields;
@@ -1251,11 +1243,11 @@ class epicsShareClass FieldCreate {
friend struct detail::field_factory;
public:
static const FieldCreatePtr &getFieldCreate();
/**
* Create a new instance of in-line @c Field builder.
* @return a new instance of a @c FieldBuilder.
*/
FieldBuilderPtr createFieldBuilder() const;
/**
* Create a new instance of in-line @c Field builder.
* @return a new instance of a @c FieldBuilder.
*/
FieldBuilderPtr createFieldBuilder() const;
/**
* Create a new instance of in-line @c Field builder pre-initialized with and existing Structure
* @return a new instance of a @c FieldBuilder.
@@ -1323,7 +1315,7 @@ public:
* @return a @c Structure interface for the newly created object.
*/
StructureConstPtr createStructure (
std::string const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**
@@ -1359,7 +1351,7 @@ public:
* @return a @c Union interface for the newly created object.
*/
UnionConstPtr createUnion (
std::string const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**

View File

@@ -72,7 +72,7 @@ static bool checkBitSetPVField(
bool BitSetUtil::compress(BitSetPtr const &bitSet,PVStructurePtr const &pvStructure)
{
return checkBitSetPVField(pvStructure,bitSet,0);
return checkBitSetPVField(pvStructure,bitSet,0);
}
}}

View File

@@ -12,6 +12,8 @@ include $(PVDATA_TEST)/pv/Makefile
include $(PVDATA_TEST)/property/Makefile
include $(PVDATA_TEST)/copy/Makefile
PROD_SRCS_RTEMS += rtemsTestData.c
# pvDataAllTests runs all the test programs in a known working order.
testHarness_SRCS += pvDataAllTests.c
@@ -30,6 +32,11 @@ TESTSPEC_RTEMS = pvdTestHarness.$(MUNCH_SUFFIX); pvDataAllTests
# Build test scripts for hosts
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),)
TESTPROD = $(TESTPROD_HOST)
TESTSCRIPTS += $(TESTS:%=%.t)
endif
include $(TOP)/configure/RULES

View File

@@ -203,8 +203,8 @@ static void testCreateRequestInternal() {
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
@@ -241,10 +241,10 @@ static void testCreateRequestInternal() {
testPass("request %s",request.c_str());
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}"
+ ")";
@@ -730,5 +730,3 @@ MAIN(testCreateRequest)
testMaskErr();
return testDone();
}

View File

@@ -31,16 +31,6 @@ void Unroller::unroll<0>(double /*d*/) {
THROW_BASE_EXCEPTION("the root cause");
}
void internalTestBaseException(int /*unused*/ = 0)
{
try {
// NOTE: 5, 4, 3, 2, 1 calls will be optimized and not shown
Unroller().unroll<5>(42.0);
} catch (BaseException& be3) {
THROW_BASE_EXCEPTION_CAUSE("exception 1", be3);
}
}
void testBaseExceptionTest() {
printf("testBaseException... ");
@@ -50,16 +40,6 @@ void testBaseExceptionTest() {
printf("\n\n%s\n\n", be.what());
}
try {
try {
internalTestBaseException();
} catch (BaseException& be2) {
THROW_BASE_EXCEPTION_CAUSE("exception 2", be2);
}
} catch (BaseException& be) {
printf("\n\n%s\n\n", be.what());
}
testPass("testBaseException");
}
@@ -88,4 +68,3 @@ MAIN(testBaseException)
testBaseExceptionTest();
return testDone();
}

View File

@@ -152,7 +152,7 @@ static void testOperators()
b2.set(256);
b1 ^= b2;
testOk1((b1.cardinality() == 2 && b1.get(1) == true && b1.get(256) == true));
testDiag("assign");
testOk1(b1 != b2);

View File

@@ -14,6 +14,11 @@
#include <cstring>
#include <memory>
// allow to test deprecated functions without causing compiler warnings
#include <compilerDependencies.h>
#undef EPICS_DEPRECATED
#define EPICS_DEPRECATED
#include <testMain.h>
#include <pv/pvUnitTest.h>
@@ -217,38 +222,6 @@ void testUnaligned()
{
testDiag("test correctness of unaligned access");
ByteBuffer buf(32, EPICS_ENDIAN_BIG);
// malloc() should give us a buffer aligned to at least native integer size
buf.align(sizeof(int));
testOk1(buf.getPosition()==0);
buf.clear();
buf.put<uint8>(0x42);
buf.put<uint16>(0x1020);
buf.align(2, '\x41');
testOk1(buf.getPosition()==4);
testOk1(memcmp(buf.getBuffer(), "\x42\x10\x20\x41", 4)==0);
buf.clear();
buf.put<uint8>(0x42);
buf.put<uint32>(0x12345678);
buf.align(4, '\x41');
testOk1(buf.getPosition()==8);
testOk1(memcmp(buf.getBuffer(), "\x42\x12\x34\x56\x78\x41\x41\x41", 8)==0);
buf.clear();
buf.put<uint8>(0x42);
uint64 val = 0x12345678;
val<<=32;
val |= 0x90abcdef;
buf.put<uint64>(val);
buf.align(8, '\x41');
testOk1(buf.getPosition()==16);
testOk1(memcmp(buf.getBuffer(), "\x42\x12\x34\x56\x78\x90\xab\xcd\xef\x41\x41\x41", 8)==0);
}
static
@@ -305,7 +278,7 @@ void testArrayBE()
MAIN(testByteBuffer)
{
testPlan(104);
testPlan(97);
testDiag("Tests byteBuffer");
testBasicOperations();
testInverseEndianness(EPICS_ENDIAN_BIG, expect_be);

View File

@@ -12,4 +12,3 @@ printf("EPICS_BYTE_ORDER: %s\n", (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE) ? "li
printf("EPICS_FLOAT_WORD_ORDER: %s\n", (EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE) ? "little" : "big");
return 0;
}

View File

@@ -47,4 +47,3 @@ MAIN(testEvent)
testBasicEvent();
return testDone();
}

View File

@@ -81,7 +81,7 @@ void test()
testOk1(userOverrunBitSet->get(secondsOffset));
testOk1(userOverrunBitSet->get(nanosecondsOffset));
testOk1(userOverrunBitSet->get(userTagOffset));
BitSetUtil::compress(userChangeBitSet,pvStructure);
BitSetUtil::compress(userOverrunBitSet,pvStructure);
testOk1(userChangeBitSet->cardinality()==4);
@@ -138,4 +138,3 @@ MAIN(testOverrunBitSet)
test();
return testDone();
}

View File

@@ -67,10 +67,6 @@ public:
virtual void ensureBuffer(std::size_t /*size*/) {
}
virtual void alignBuffer(std::size_t alignment) {
buffer->align(alignment);
}
virtual bool directSerialize(ByteBuffer* /*existingBuffer*/, const char* /*toSerialize*/,
std::size_t /*elementCount*/, std::size_t /*elementSize*/)
{
@@ -95,10 +91,6 @@ public:
virtual void ensureData(size_t /*size*/) {
}
virtual void alignData(size_t alignment) {
buffer->align(alignment);
}
virtual bool directDeserialize(ByteBuffer* /*existingBuffer*/, char* /*deserializeTo*/,
std::size_t /*elementCount*/, std::size_t /*elementSize*/)
{
@@ -146,48 +138,48 @@ void testEquals() {
PVDataCreatePtr factory = getPVDataCreate();
testOk1(factory.get()!=NULL);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
PVScalarPtr scalar1 = factory->createPVScalar(scalarType);
PVScalarPtr scalar2 = factory->createPVScalar(scalarType);
testOk1((*scalar1)==(*scalar2));
PVScalarPtr scalar1 = factory->createPVScalar(scalarType);
PVScalarPtr scalar2 = factory->createPVScalar(scalarType);
testOk1((*scalar1)==(*scalar2));
PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType);
PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType);
testOk1((*array1)==(*array2));
}
PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType);
PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType);
testOk1((*array1)==(*array2));
}
// and a structure
// and a structure
PVStructurePtr structure1 = factory->createPVStructure(getStandardField()->timeStamp());
PVStructurePtr structure2 = factory->createPVStructure(getStandardField()->timeStamp());
testOk1((*structure1)==(*structure2));
testOk1((*structure1)==(*structure2));
// and a structure array
PVStructureArrayPtr structureArray1 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure1->getStructure()));
PVStructureArrayPtr structureArray2 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure2->getStructure()));
testOk1((*structureArray1)==(*structureArray2));
// variant union
PVUnionPtr variantUnion1 = factory->createPVVariantUnion();
PVUnionPtr variantUnion2 = factory->createPVVariantUnion();
testOk1((*variantUnion1)==(*variantUnion2));
variantUnion1->set(structure1);
variantUnion2->set(structure1);
testOk1((*variantUnion1)==(*variantUnion2));
testOk1((*structureArray1)==(*structureArray2));
variantUnion2->set(structureArray1);
testOk1((*variantUnion1)!=(*variantUnion2));
// variant union array
PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray();
PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray();
testOk1((*variantUnionArray1)==(*variantUnionArray2));
// variant union
PVUnionPtr variantUnion1 = factory->createPVVariantUnion();
PVUnionPtr variantUnion2 = factory->createPVVariantUnion();
testOk1((*variantUnion1)==(*variantUnion2));
// union
variantUnion1->set(structure1);
variantUnion2->set(structure1);
testOk1((*variantUnion1)==(*variantUnion2));
variantUnion2->set(structureArray1);
testOk1((*variantUnion1)!=(*variantUnion2));
// variant union array
PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray();
PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray();
testOk1((*variantUnionArray1)==(*variantUnionArray2));
// union
UnionConstPtr punion = getFieldCreate()->createFieldBuilder()->
add("double", pvDouble)->
add("double2", pvDouble)->
@@ -198,30 +190,30 @@ void testEquals() {
endNested()->
addArray("intArray", pvInt)->
createUnion();
PVUnionPtr union1 = factory->createPVUnion(punion);
PVUnionPtr union2 = factory->createPVUnion(punion);
testOk1((*union1)==(*union2));
union1->select<PVDouble>("double")->put(1.2);
union2->select<PVDouble>("double")->put(1.2);
testOk1((*union1)==(*union2));
union2->select<PVDouble>("double")->put(2.2);
testOk1((*union1)!=(*union2));
PVUnionPtr union1 = factory->createPVUnion(punion);
PVUnionPtr union2 = factory->createPVUnion(punion);
testOk1((*union1)==(*union2));
union2->select<PVDouble>("double2")->put(1.2);
testOk1((*union1)!=(*union2));
union1->select<PVDouble>("double")->put(1.2);
union2->select<PVDouble>("double")->put(1.2);
testOk1((*union1)==(*union2));
union2->select("nested");
testOk1((*union1)!=(*union2));
union2->select<PVDouble>("double")->put(2.2);
testOk1((*union1)!=(*union2));
testOk1((*union1)!=(*variantUnion2));
PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
testOk1((*unionArray1)==(*unionArray2));
union2->select<PVDouble>("double2")->put(1.2);
testOk1((*union1)!=(*union2));
testOk1((*variantUnionArray1)!=(*unionArray2));
union2->select("nested");
testOk1((*union1)!=(*union2));
testOk1((*union1)!=(*variantUnion2));
PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
testOk1((*unionArray1)==(*unionArray2));
testOk1((*variantUnionArray1)!=(*unionArray2));
}
template<typename PVT>
@@ -264,7 +256,7 @@ void testScalar() {
testDiag("type %s", ScalarTypeFunc::name(pvBoolean));
PVBooleanPtr pvBoolean =
std::tr1::static_pointer_cast<PVBoolean>(factory->createPVScalar(epics::pvData::pvBoolean));
std::tr1::static_pointer_cast<PVBoolean>(factory->createPVScalar(epics::pvData::pvBoolean));
pvBoolean->put(false);
serializationTest(pvBoolean);
pvBoolean->put(true);
@@ -284,7 +276,7 @@ void testScalar() {
testDiag("type %s", ScalarTypeFunc::name(pvString));
PVStringPtr pvString =
std::tr1::static_pointer_cast<PVString>(factory->createPVScalar(epics::pvData::pvString));
std::tr1::static_pointer_cast<PVString>(factory->createPVScalar(epics::pvData::pvString));
pvString->put("");
serializationTest(pvString);
pvString->put("s");
@@ -382,7 +374,7 @@ void testStructure() {
testOk1(factory.get()!=NULL);
testDiag("\tSimple structure serialization");
PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp());
PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp());
pvStructure->getSubField<PVLong>("secondsPastEpoch")->put(123);
pvStructure->getSubField<PVInt>("nanoseconds")->put(456);
pvStructure->getSubField<PVInt>("userTag")->put(789);
@@ -390,11 +382,11 @@ void testStructure() {
serializationTest(pvStructure);
testDiag("\tComplex structure serialization");
pvStructure = factory->createPVStructure(
getStandardField()->structureArray(
getStandardField()->timeStamp(), "alarm,control,display,timeStamp")
);
// TODO fill with data
pvStructure = factory->createPVStructure(
getStandardField()->structureArray(
getStandardField()->timeStamp(), "alarm,control,display,timeStamp")
);
// TODO fill with data
serializationTest(pvStructure);
}
@@ -439,17 +431,17 @@ void testUnion() {
PVUnionArrayPtr variantArray = factory->createPVVariantUnionArray();
testOk1(variantArray.get()!=NULL);
variantArray->setLength(6);
PVUnionArray::svector data;
PVUnionPtr u = factory->createPVVariantUnion();
data.push_back(u);
u = factory->createPVVariantUnion();
u->set(factory->createPVStructure(getStandardField()->timeStamp()));
data.push_back(u);
u = factory->createPVVariantUnion();
u->set(factory->createPVStructure(getStandardField()->control()));
data.push_back(u);
@@ -458,18 +450,18 @@ void testUnion() {
variantArray->replace(freeze(data));
serializationTest(variantArray);
testDiag("\tVariant union test");
UnionConstPtr punion = getFieldCreate()->createFieldBuilder()->
add("doubleValue", pvDouble)->
add("intValue", pvInt)->
createUnion();
u = factory->createPVUnion(punion);
testOk1(NULL!=u.get());
// null union test
u = factory->createPVUnion(punion);
testOk1(NULL!=u.get());
// null union test
testOk1(NULL==u->get().get());
testOk1(PVUnion::UNDEFINED_INDEX == u->getSelectedIndex());
testOk1("" == u->getSelectedFieldName());
@@ -480,13 +472,13 @@ void testUnion() {
testOk1(0 == u->getSelectedIndex());
testOk1("doubleValue" == u->getSelectedFieldName());
serializationTest(u);
u->select<PVInt>("intValue")->put(543);
testOk1(543 == u->get<PVInt>()->get());
testOk1(1 == u->getSelectedIndex());
testOk1("intValue" == u->getSelectedFieldName());
serializationTest(u);
u->select<PVInt>(1)->put(5432);
testOk1(5432 == u->get<PVInt>()->get());
serializationTest(u);
@@ -496,12 +488,12 @@ void testUnion() {
testOk1(PVUnion::UNDEFINED_INDEX == u->getSelectedIndex());
testOk1("" == u->getSelectedFieldName());
serializationTest(u);
u->set("doubleValue", doubleValue);
testOk1(doubleValue.get() == u->get().get());
testOk1(0 == u->getSelectedIndex());
serializationTest(u);
try
{
u->set(1, doubleValue);
@@ -523,7 +515,7 @@ void testUnion() {
// expected
testPass("PVUnion.select(int32) index out of bounds test");
}
try
{
u->select(-2);
@@ -545,22 +537,22 @@ void testUnion() {
// expected
testPass("PVUnion.set(int32, PVFieldPtr const&) index out of bounds test");
}
testDiag("\tUnion array test");
PVUnionArrayPtr unionArray = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
testOk1(unionArray.get()!=NULL);
unionArray->setLength(6);
data.clear();
u = factory->createPVUnion(punion);
data.push_back(u);
u = factory->createPVUnion(punion);
u->select<PVDouble>(0)->put(12);
data.push_back(u);
u = factory->createPVUnion(punion);
u->select<PVInt>(1)->put(421);
data.push_back(u);
@@ -569,7 +561,7 @@ void testUnion() {
unionArray->replace(freeze(data));
serializationTest(unionArray);
}
void testStructureArray() {
@@ -633,38 +625,38 @@ void serializationFieldTest(FieldConstPtr const & field)
{
testShow()<<CURRENT_FUNCTION<<"\n"<<field;
buffer->clear();
buffer->clear();
// serialize
field->serialize(buffer, flusher);
// serialize
field->serialize(buffer, flusher);
// deserialize
buffer->flip();
// deserialize
buffer->flip();
FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control);
FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control);
testShow()<<" after "<<(void*)field.get()<<" == "<<(void*)deserializedField.get();
testOk1(*field == *deserializedField);
testOk1(*field == *deserializedField);
}
void testIntrospectionSerialization()
{
testDiag("Testing introspection serialization...");
testDiag("Testing introspection serialization...");
FieldCreatePtr factory = getFieldCreate();
testOk1(factory.get()!=NULL);
FieldCreatePtr factory = getFieldCreate();
testOk1(factory.get()!=NULL);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
ScalarConstPtr scalar = factory->createScalar(scalarType);
serializationFieldTest(scalar);
ScalarConstPtr scalar = factory->createScalar(scalarType);
serializationFieldTest(scalar);
ScalarArrayConstPtr array = factory->createScalarArray(scalarType);
serializationFieldTest(array);
}
ScalarArrayConstPtr array = factory->createScalarArray(scalarType);
serializationFieldTest(array);
}
// and a structure
StructureConstPtr structure = getStandardField()->timeStamp();
@@ -677,11 +669,11 @@ void testIntrospectionSerialization()
// variant union
UnionConstPtr variant = factory->createVariantUnion();
serializationFieldTest(variant);
// variant array union
UnionArrayConstPtr variantArray = factory->createVariantUnionArray();
serializationFieldTest(variantArray);
// union
UnionConstPtr punion = factory->createFieldBuilder()->
add("double", pvDouble)->
@@ -693,7 +685,7 @@ void testIntrospectionSerialization()
addArray("intArray", pvInt)->
createUnion();
serializationFieldTest(punion);
// union array
UnionArrayConstPtr punionArray = factory->createUnionArray(punion);
serializationFieldTest(punionArray);
@@ -748,7 +740,7 @@ void testBoundedString() {
try {
pvStr->put("tooLargeString");
testFail("too large string accepted");
} catch (std::overflow_error oe) {
} catch (std::overflow_error& oe) {
// OK
}
@@ -877,7 +869,7 @@ MAIN(testSerialization) {
testStructure();
testStructureId();
testStructureArray();
testUnion();
testArraySizeType();
@@ -894,4 +886,3 @@ MAIN(testSerialization) {
return testDone();
}

View File

@@ -474,6 +474,9 @@ void testVectorConvert()
testOk1(ints.unique());
testOk1(strings.size()==ints.size());
testOk1(strings.at(0)=="42");
testDiag("convert empty array");
testOk1(pvd::shared_vector_convert<double>(pvd::shared_vector<pvd::int32>()).empty());
}
void testWeak()
@@ -522,7 +525,7 @@ void testICE()
testOk1(B.size()==6);
testOk1(A.data()!=check);
testOk1(B.data()==check);
D = B; // create second const reference
// clears D, but reference to B
@@ -695,7 +698,7 @@ void testCXX11Init()
MAIN(testSharedVector)
{
testPlan(191);
testPlan(192);
testDiag("Tests for shared_vector");
testDiag("sizeof(shared_vector<pvd::int32>)=%lu",

View File

@@ -123,7 +123,7 @@ const char bigtest[] =
" ,{\"a\":9, \"b\":10}\n"
" ],\n"
" \"any\": \"4.2\",\n"
" \"almost\": \"hello\"\n"
" \"almost\": \"long string /with\\\\ several \\\" and ' characters\\u001f\\u2705\"\n"
"}";
// intentionally not setting "extra"
@@ -204,7 +204,7 @@ void testInto()
}
testFieldEqual<pvd::PVString>(val, "any", "4.2");
testFieldEqual<pvd::PVString>(val, "almost", "hello");
testFieldEqual<pvd::PVString>(val, "almost", "long string /with\\ several \" and ' characters\x1f\xe2\x9c\x85");
}
void testroundtrip()
@@ -255,19 +255,19 @@ void testroundtrip()
round2 = strm.str();
}
testEqual(round2, "{\"scalar\": 42,"
"\"ivec\": [1,2,3],"
"\"svec\": [\"one\",\"two\"],"
"\"sub\": {"
"\"x\": {"
"\"y\": 43"
testEqual(round2, "{\"scalar\":42,"
"\"ivec\":[1,2,3],"
"\"svec\":[\"one\",\"two\"],"
"\"sub\":{"
"\"x\":{"
"\"y\":43"
"}},"
"\"extra\": 0,"
"\"sarr\": [{\"a\": 5,\"b\": 6},"
"{\"a\": 7,\"b\": 8},"
"{\"a\": 9,\"b\": 10}],"
"\"any\": \"4.2\","
"\"almost\": \"hello\""
"\"extra\":0,"
"\"sarr\":[{\"a\":5,\"b\":6},"
"{\"a\":7,\"b\":8},"
"{\"a\":9,\"b\":10}],"
"\"any\":\"4.2\","
"\"almost\":\"long string /with\\\\ several \\\" and ' characters\\u001F\xe2\x9c\x85\""
"}");
}

View File

@@ -134,12 +134,12 @@ void showNTScalarNumeric()
{
testDiag("%s", CURRENT_FUNCTION);
pvd::PVStructurePtr input(pvd::getPVDataCreate()->createPVStructure(scalarNumeric));
input->getSubFieldT<pvd::PVScalar>("value")->putFrom(-42);
input->getSubFieldT<pvd::PVScalar>("value")->putFrom(pvd::int32(-42));
testDiff("<undefined> -42 \n", print(input->stream()));
input->getSubFieldT<pvd::PVScalar>("alarm.severity")->putFrom(1);
input->getSubFieldT<pvd::PVScalar>("alarm.status")->putFrom(1);
input->getSubFieldT<pvd::PVScalar>("alarm.severity")->putFrom(pvd::int32(1));
input->getSubFieldT<pvd::PVScalar>("alarm.status")->putFrom(pvd::int32(1));
input->getSubFieldT<pvd::PVString>("alarm.message")->put("FOO");
testDiff("<undefined> -42 MINOR DEVICE FOO \n", print(input->stream()));
@@ -162,8 +162,8 @@ void showNTScalarString()
testDiff("<undefined> bar \n", print(input->stream()));
input->getSubFieldT<pvd::PVScalar>("alarm.severity")->putFrom(1);
input->getSubFieldT<pvd::PVScalar>("alarm.status")->putFrom(1);
input->getSubFieldT<pvd::PVScalar>("alarm.severity")->putFrom(pvd::int32(1));
input->getSubFieldT<pvd::PVScalar>("alarm.status")->putFrom(pvd::int32(1));
input->getSubFieldT<pvd::PVString>("alarm.message")->put("FOO");
testDiff("<undefined> bar MINOR DEVICE FOO \n", print(input->stream()));
@@ -197,12 +197,12 @@ void showNTEnum()
input->getSubFieldT<pvd::PVInt>("value.index")->put(1);
testDiff("<undefined> (1) a two\n", print(input->stream()), "two");
testDiff("<undefined> (1) \"a two\"\n", print(input->stream()), "two");
testDiff("epics:nt/NTEnum:1.0 \n"
" enum_t value (1) a two\n"
" enum_t value (1) \"a two\"\n"
" int index 1\n"
" string[] choices [\"one\", \"a two\"]\n"
" string[] choices [one, \"a two\"]\n"
" alarm_t alarm \n"
" int severity 0\n"
" int status 0\n"
@@ -247,7 +247,7 @@ void showNTTable()
iarr.push_back(42); // will not be shown
input->getSubFieldT<pvd::PVIntArray>("value.colA")->replace(pvd::freeze(iarr));
sarr.push_back("one\x7f");
sarr.push_back("one\x7f\x80");
sarr.push_back("two words");
sarr.push_back("A '\"'");
input->getSubFieldT<pvd::PVStringArray>("value.colB")->replace(pvd::freeze(sarr));
@@ -255,7 +255,7 @@ void showNTTable()
testDiff("<undefined> \n"
"labelA \"label B\"\n"
" 1 one\\x7F\n"
" 1 one\\x7F\\x80\n"
" 2 \"two words\"\n"
" 3 \"A \\'\"\"\\'\"\n"
, print(input->stream()),
@@ -299,7 +299,7 @@ void testRaw()
testDiff("omg \n"
" string scalar \n" // bit 1
" string[] scalarArray [\"hello\", \"world\\x7F\"]\n"
" string[] scalarArray [hello, \"world\\x7F\"]\n"
" structure below\n"
" int A 0\n" // bit 4
" union select\n"
@@ -319,7 +319,7 @@ void testRaw()
testDiff("omg \n"
"\033[1m string scalar \n"
"\033[0m\033[1m string[] scalarArray [\"hello\", \"world\\x7F\"]\n"
"\033[0m\033[1m string[] scalarArray [hello, \"world\\x7F\"]\n"
"\033[0m structure below\n"
"\033[1m int A 0\n"
"\033[0m union select\n"
@@ -347,13 +347,20 @@ void testEscape()
testEqual("hello\"\"world", std::string(SB()<<pvd::escape("hello\"world").style(pvd::escape::CSV)));
testEqual("hello\"\"world", pvd::escape("hello\"world").style(pvd::escape::CSV).str());
testEqual("hello_world", std::string(SB()<<pvd::maybeQuote("hello_world")));
testEqual("\"hello_world\\\"\"", std::string(SB()<<pvd::maybeQuote("hello_world\"")));
testEqual("\"hello world\"", std::string(SB()<<pvd::maybeQuote("hello world")));
testEqual("\"hello\\nworld\"", std::string(SB()<<pvd::maybeQuote("hello\nworld")));
testEqual("\"hello\\\"world\"", std::string(SB()<<pvd::maybeQuote("hello\"world")));
testEqual("\"hello\\x7Fworld\"", std::string(SB()<<pvd::maybeQuote("hello\x7Fworld")));
}
} // namespace
MAIN(testprinter)
{
testPlan(20);
testPlan(26);
showNTScalarNumeric();
showNTScalarString();
showNTEnum();

View File

@@ -64,7 +64,7 @@ static void testAlarm()
{
testDiag("testAlarm\n");
Alarm alarm;
PVAlarm pvAlarm;
PVAlarm pvAlarm;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("alarm"));
if(pvField.get()==NULL) {
@@ -93,7 +93,7 @@ static void testTimeStamp()
{
testDiag("testTimeStamp\n");
TimeStamp timeStamp;
PVTimeStamp pvTimeStamp;
PVTimeStamp pvTimeStamp;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("timeStamp"));
if(pvField.get()==NULL) {
@@ -132,7 +132,7 @@ static void testControl()
{
testDiag("testControl\n");
Control control;
PVControl pvControl;
PVControl pvControl;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("control"));
if(pvField.get()==NULL) {
@@ -159,7 +159,7 @@ static void testDisplay()
{
testDiag("testDisplay\n");
Display display;
PVDisplay pvDisplay;
PVDisplay pvDisplay;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("display"));
if(pvField.get()==NULL) {
@@ -191,7 +191,7 @@ static void testDisplay()
static void testEnumerated()
{
testDiag("testEnumerated\n");
PVEnumerated pvEnumerated;
PVEnumerated pvEnumerated;
bool result;
PVFieldPtr pvField = enumeratedRecord->getSubField<PVStructure>(string("value"));
if(pvField.get()==NULL) {
@@ -232,4 +232,3 @@ MAIN(testProperty)
printRecords();
return testDone();;
}

View File

@@ -6,6 +6,7 @@
#include <testMain.h>
#include <epicsUnitTest.h>
#include <epicsStdio.h>
#include <pv/current_function.h>
#include <pv/pvData.h>
@@ -54,7 +55,7 @@ void buildMiss()
for(size_t i=0; i<1000; i++) {
// unique name each time to (partially) defeat caching
char buf[10];
sprintf(buf, "field%zu", i);
epicsSnprintf(buf, sizeof(buf), "field%lu", (unsigned long) i);
record.start();

View File

@@ -31,7 +31,7 @@ static StandardPVFieldPtr standardPVField;
static void test()
{
std::ostringstream oss;
testDiag("\ntestBitSetUtil\n");
StringArray fieldNames;
PVFieldPtrArray pvFields;
@@ -127,4 +127,3 @@ MAIN(testBitSetUtil)
test();
return testDone();
}

View File

@@ -25,7 +25,7 @@ void test_factory()
testOk1(fb.get() != 0);
FieldBuilderPtr fb2 = fieldCreate->createFieldBuilder();
testOk1(fb.get() != fb2.get());
testOk1(fb.get() != fb2.get());
}
void test_structure()
@@ -34,7 +34,7 @@ void test_structure()
FieldCreatePtr fieldCreate = getFieldCreate();
FieldBuilderPtr fb = fieldCreate->createFieldBuilder();
// test with simple (non-nested) structure
std::string ID = "testStructureID";
StructureConstPtr s = fb->setId(ID)->
@@ -44,7 +44,7 @@ void test_structure()
testOk1(s.get() != 0);
testOk1(ID == s->getID());
testOk1(2 == s->getFields().size());
FieldConstPtr f0 = s->getField(0);
testOk1(scalar == f0->getType());
testOk1("double" == s->getFieldName(0));
@@ -54,13 +54,13 @@ void test_structure()
testOk1(scalarArray == f1->getType());
testOk1("intArray" == s->getFieldName(1));
testOk(pvInt == std::tr1::static_pointer_cast<const ScalarArray>(f1)->getElementType(), "f1 element type == int");
// test reuse with empty structure
StructureConstPtr emptyStructure = fb->createStructure();
testOk1(emptyStructure.get() != 0);
testOk1(Structure::DEFAULT_ID == emptyStructure->getID());
testOk1(0 == emptyStructure->getFields().size());
// test add/addArray with Field
StructureConstPtr s2 = fb->add("s", s)->
addArray("sArray", s)->
@@ -137,7 +137,7 @@ void test_nestedStructure()
testDiag("Test test_nestedStructure()");
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
@@ -163,21 +163,21 @@ void test_nestedStructure()
{
StructureConstPtr s2 = std::tr1::static_pointer_cast<const Structure>(f1);
testOk1(s2.get() != 0);
testOk1(NESTED_ID == s2->getID());
testOk1(2 == s2->getFields().size());
FieldConstPtr f20 = s2->getField(0);
testOk1(scalar == f20->getType());
testOk1("short" == s2->getFieldName(0));
testOk(pvShort == std::tr1::static_pointer_cast<const Scalar>(f20)->getScalarType(), "f20 scalar type == short");
FieldConstPtr f21 = s2->getField(1);
testOk1(scalar == f21->getType());
testOk1("long" == s2->getFieldName(1));
testOk(pvLong == std::tr1::static_pointer_cast<const Scalar>(f21)->getScalarType(), "f21 element type == long");
}
FieldConstPtr f2 = s->getField(2);
@@ -185,15 +185,15 @@ void test_nestedStructure()
testOk1("intArray" == s->getFieldName(2));
testOk(pvInt == std::tr1::static_pointer_cast<const ScalarArray>(f2)->getElementType(), "f2 element type == int");
}
}
void test_nestedStructureArray()
{
testDiag("Test test_nestedStructureArray()");
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
@@ -219,21 +219,21 @@ void test_nestedStructureArray()
{
StructureConstPtr s2 = std::tr1::static_pointer_cast<const StructureArray>(f1)->getStructure();
testOk1(s2.get() != 0);
testOk1(NESTED_ID == s2->getID());
testOk1(2 == s2->getFields().size());
FieldConstPtr f20 = s2->getField(0);
testOk1(scalar == f20->getType());
testOk1("short" == s2->getFieldName(0));
testOk(pvShort == std::tr1::static_pointer_cast<const Scalar>(f20)->getScalarType(), "f20 scalar type == short");
FieldConstPtr f21 = s2->getField(1);
testOk1(scalar == f21->getType());
testOk1("long" == s2->getFieldName(1));
testOk(pvLong == std::tr1::static_pointer_cast<const Scalar>(f21)->getScalarType(), "f21 element type == long");
}
FieldConstPtr f2 = s->getField(2);

View File

@@ -32,7 +32,7 @@ static void testScalarCommon(ScalarType stype,
ScalarConstPtr pscalar = fieldCreate->createScalar(stype);
Type type = pscalar->getType();
testOk1(type==scalar);
std::ostringstream oss;
oss << type;
testOk1(oss.str().compare("scalar")==0);
@@ -307,17 +307,17 @@ static void testUnion()
testOk1(union1arr->getUnion()==union1);
testOk1(union1arr->getID()=="union[]");
UnionConstPtr variantUnion1 = fieldCreate->createVariantUnion();
testOk1(variantUnion1->getNumberFields()==0);
testOk1(variantUnion1->getID() == Union::ANY_ID);
UnionArrayConstPtr variantUnion1arr = fieldCreate->createVariantUnionArray();
testOk1(variantUnion1arr->getUnion()==variantUnion1);
testOk1(variantUnion1arr->getID()=="any[]");
}
static void testBoundedString()

View File

@@ -33,7 +33,7 @@ MAIN(testOperators)
PVDoublePtr pvValue = pvStructure->getSubField<PVDouble>("value");
*pvValue <<= testDV;
double dv;
double dv = 0.;
*pvValue >>= dv;
testOk1(testDV == dv);
@@ -72,7 +72,7 @@ MAIN(testOperators)
pvStructure = standardPVField->scalarArray(pvDouble,"alarm,timeStamp");
std::cout << *pvStructure << std::endl;
PVDoubleArray::svector values(3);
values[0] = 1.1; values[1] = 2.2; values[2] = 3.3;
PVDoubleArrayPtr darray = pvStructure->getSubField<PVDoubleArray>("value");
@@ -95,4 +95,3 @@ MAIN(testOperators)
return testDone();
}

View File

@@ -41,6 +41,10 @@ static string allProperties("alarm,timeStamp,display,control,valueAlarm");
static void testSizes()
{
#define SHOW(T) testDiag("sizeof(" #T ")==%zu", sizeof(T))
SHOW(std::string);
SHOW(std::vector<int>);
SHOW(shared_vector<int>);
SHOW(std::tr1::shared_ptr<PVField>);
SHOW(Field);
SHOW(Structure);
SHOW(StructureArray);
@@ -77,7 +81,7 @@ static void testCreatePVStructure()
pvFields.push_back(pv1);
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
fieldNames,pvFields);
std::cout << "testCreatePVStructure PASSED" << std::endl;
}
@@ -340,7 +344,7 @@ static void testPVScalar()
testPVScalarWithProperties(string("float"),pvFloat);
testPVScalarWithProperties(string("double"),pvDouble);
testPVScalarWithProperties(string("string"),pvString);
std::cout << "testPVScalar PASSED" << std::endl;
}
@@ -382,7 +386,7 @@ static void testScalarArray()
}
static void testRequest()
{
{
StringArray nullNames;
FieldConstPtrArray nullFields;
StringArray optionNames(1);
@@ -787,4 +791,3 @@ MAIN(testPVData)
}
return testDone();
}

View File

@@ -113,9 +113,9 @@ static void testCompress()
static void testRemove()
{
testDiag("Test structure array remove");
PVStructureArray::svector contents(10);
for(size_t i=0; i<contents.size(); i++)
contents[i] = standardField->alarm()->build();

View File

@@ -64,4 +64,3 @@ MAIN(testPVType)
printf("PASSED\n");
return testDone();
}

View File

@@ -203,4 +203,3 @@ MAIN(testPVUnion)
testClearUnion();
return testDone();
}

View File

@@ -68,4 +68,3 @@ MAIN(testStandardField)
testPass("testStandardField");
return testDone();
}

View File

@@ -73,4 +73,3 @@ MAIN(testStandardPVField)
testPass("testStandardPVField");
return testDone();
}

2
testApp/rtemsTestData.c Normal file
View File

@@ -0,0 +1,2 @@
/* no test data */
const void* epicsRtemsFSImage = 0;