Showing preview only (2,513K chars total). Download the full file or copy to clipboard to get everything.
Repository: microsoft/napajs
Branch: master
Commit: b38a2385c076
Files: 458
Total size: 2.3 MB
Directory structure:
gitextract_sogveh4o/
├── .gitignore
├── .npmignore
├── .travis.yml
├── CMakeLists.txt
├── LICENSE.txt
├── README.md
├── appveyor.yml
├── benchmark/
│ ├── README.md
│ ├── bench-utils.ts
│ ├── bench.ts
│ ├── execute-overhead.ts
│ ├── execute-scalability.ts
│ ├── node-napa-perf-comparison.ts
│ ├── store-overhead.ts
│ ├── transport-overhead.ts
│ └── tsconfig.json
├── build.bat
├── build.js
├── docs/
│ ├── api/
│ │ ├── index.md
│ │ ├── log.md
│ │ ├── memory.md
│ │ ├── metric.md
│ │ ├── module.md
│ │ ├── napa-globals.md
│ │ ├── node-api.md
│ │ ├── store.md
│ │ ├── sync.md
│ │ ├── transport.md
│ │ └── zone.md
│ └── design/
│ └── transport-js-builtins.md
├── examples/
│ ├── modules/
│ │ ├── README.md
│ │ ├── async-number/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── binding.gyp
│ │ │ ├── lib/
│ │ │ │ ├── async-number.ts
│ │ │ │ └── tsconfig.json
│ │ │ ├── napa/
│ │ │ │ └── addon.cpp
│ │ │ ├── package.json
│ │ │ └── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ ├── hello-world/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── binding.gyp
│ │ │ ├── lib/
│ │ │ │ ├── hello-world.ts
│ │ │ │ └── tsconfig.json
│ │ │ ├── napa/
│ │ │ │ └── addon.cpp
│ │ │ ├── package.json
│ │ │ └── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ └── plus-number/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── inc/
│ │ │ └── plus-number.h
│ │ ├── lib/
│ │ │ ├── plus-number.ts
│ │ │ └── tsconfig.json
│ │ ├── napa/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── addon.cpp
│ │ │ ├── plus-number-wrap.cpp
│ │ │ └── plus-number-wrap.h
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── CMakeLists.txt
│ │ │ └── plus-number.cpp
│ │ ├── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ └── unittest/
│ │ ├── CMakeLists.txt
│ │ ├── catch/
│ │ │ ├── LICENSE.txt
│ │ │ └── catch.hpp
│ │ ├── main.cpp
│ │ └── run.js
│ └── tutorial/
│ ├── estimate-pi-in-parallel/
│ │ ├── README.md
│ │ ├── estimate-pi-in-parallel.js
│ │ └── package.json
│ ├── max-square-sub-matrix/
│ │ ├── README.md
│ │ ├── max-square-sub-matrix.js
│ │ └── package.json
│ ├── napa-runner/
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── estimate-PI.js
│ │ ├── main.cpp
│ │ └── package.json
│ ├── parallel-quick-sort/
│ │ ├── README.md
│ │ ├── package.json
│ │ └── parallel-quick-sort.js
│ ├── recursive-fibonacci/
│ │ ├── README.md
│ │ ├── package.json
│ │ └── recursive-fibonacci.js
│ └── synchronized-loading/
│ ├── README.md
│ ├── package.json
│ ├── phone-book-data.json
│ ├── phone-book.js
│ └── synchronized-loading.js
├── inc/
│ ├── napa/
│ │ ├── assert.h
│ │ ├── async.h
│ │ ├── capi.h
│ │ ├── exports.h
│ │ ├── log.h
│ │ ├── memory/
│ │ │ ├── allocator-debugger.h
│ │ │ ├── allocator.h
│ │ │ └── common.h
│ │ ├── memory.h
│ │ ├── module/
│ │ │ ├── binding/
│ │ │ │ ├── basic-wraps.h
│ │ │ │ └── wraps.h
│ │ │ ├── binding.h
│ │ │ ├── common.h
│ │ │ ├── module-internal.h
│ │ │ ├── module-node-compat.h
│ │ │ ├── object-wrap.h
│ │ │ ├── shareable-wrap.h
│ │ │ └── transport-context-wrap.h
│ │ ├── module.h
│ │ ├── providers/
│ │ │ ├── logging.h
│ │ │ └── metric.h
│ │ ├── result-codes.inc
│ │ ├── stl/
│ │ │ ├── allocator.h
│ │ │ ├── deque.h
│ │ │ ├── list.h
│ │ │ ├── map.h
│ │ │ ├── queue.h
│ │ │ ├── set.h
│ │ │ ├── stack.h
│ │ │ ├── string.h
│ │ │ ├── unordered_map.h
│ │ │ ├── unordered_set.h
│ │ │ └── vector.h
│ │ ├── transport/
│ │ │ ├── transport-context.h
│ │ │ ├── transport.h
│ │ │ └── transportable.h
│ │ ├── transport.h
│ │ ├── types.h
│ │ ├── utils.h
│ │ ├── v8-helpers/
│ │ │ ├── array.h
│ │ │ ├── console.h
│ │ │ ├── conversion.h
│ │ │ ├── flow.h
│ │ │ ├── function.h
│ │ │ ├── json.h
│ │ │ ├── maybe.h
│ │ │ ├── object.h
│ │ │ ├── ptr.h
│ │ │ ├── string.h
│ │ │ └── time.h
│ │ ├── v8-helpers.h
│ │ ├── version.h
│ │ ├── zone/
│ │ │ ├── napa-async-runner.h
│ │ │ └── node-async-runner.h
│ │ └── zone.h
│ └── napa.h
├── lib/
│ ├── binding.js
│ ├── core/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── README.md
│ │ ├── core-modules.json
│ │ ├── timers/
│ │ │ ├── timer-api.ts
│ │ │ └── timer.ts
│ │ └── timers.ts
│ ├── index.ts
│ ├── log.ts
│ ├── memory/
│ │ ├── allocator.ts
│ │ ├── handle.ts
│ │ └── shareable.ts
│ ├── memory.ts
│ ├── metric.ts
│ ├── runtime/
│ │ └── platform.ts
│ ├── runtime.ts
│ ├── store/
│ │ ├── store-api.ts
│ │ └── store.ts
│ ├── store.ts
│ ├── sync/
│ │ └── lock.ts
│ ├── sync.ts
│ ├── transport/
│ │ ├── builtin-object-transporter.ts
│ │ ├── function-transporter.ts
│ │ ├── transport.ts
│ │ └── transportable.ts
│ ├── transport.ts
│ ├── tsconfig.json
│ ├── v8/
│ │ └── stack-trace.ts
│ ├── v8.ts
│ ├── zone/
│ │ ├── function-call.ts
│ │ ├── zone-impl.ts
│ │ └── zone.ts
│ └── zone.ts
├── node/
│ ├── CMakeLists.txt
│ ├── addon.cpp
│ ├── node-zone-delegates.cpp
│ └── node-zone-delegates.h
├── package.json
├── scripts/
│ ├── clean.js
│ ├── embedded.js
│ ├── install.js
│ └── paths.js
├── src/
│ ├── CMakeLists.txt
│ ├── api/
│ │ └── capi.cpp
│ ├── memory/
│ │ └── built-in-allocators.cpp
│ ├── module/
│ │ ├── core-modules/
│ │ │ ├── core-modules.h
│ │ │ ├── napa/
│ │ │ │ ├── allocator-debugger-wrap.cpp
│ │ │ │ ├── allocator-debugger-wrap.h
│ │ │ │ ├── allocator-wrap.cpp
│ │ │ │ ├── allocator-wrap.h
│ │ │ │ ├── call-context-wrap.cpp
│ │ │ │ ├── call-context-wrap.h
│ │ │ │ ├── lock-wrap.cpp
│ │ │ │ ├── lock-wrap.h
│ │ │ │ ├── metric-wrap.cpp
│ │ │ │ ├── metric-wrap.h
│ │ │ │ ├── napa-binding.cpp
│ │ │ │ ├── napa-binding.h
│ │ │ │ ├── shared-ptr-wrap.cpp
│ │ │ │ ├── shared-ptr-wrap.h
│ │ │ │ ├── store-wrap.cpp
│ │ │ │ ├── store-wrap.h
│ │ │ │ ├── timer-wrap.cpp
│ │ │ │ ├── timer-wrap.h
│ │ │ │ ├── transport-context-wrap-impl.cpp
│ │ │ │ ├── transport-context-wrap-impl.h
│ │ │ │ ├── zone-wrap.cpp
│ │ │ │ └── zone-wrap.h
│ │ │ └── node/
│ │ │ ├── console.cpp
│ │ │ ├── console.h
│ │ │ ├── file-system-helpers.cpp
│ │ │ ├── file-system-helpers.h
│ │ │ ├── file-system.cpp
│ │ │ ├── file-system.h
│ │ │ ├── os.cpp
│ │ │ ├── os.h
│ │ │ ├── path.cpp
│ │ │ ├── path.h
│ │ │ ├── process.cpp
│ │ │ ├── process.h
│ │ │ ├── tty-wrap.cpp
│ │ │ └── tty-wrap.h
│ │ ├── loader/
│ │ │ ├── binary-module-loader.cpp
│ │ │ ├── binary-module-loader.h
│ │ │ ├── core-module-loader.cpp
│ │ │ ├── core-module-loader.h
│ │ │ ├── javascript-module-loader.cpp
│ │ │ ├── javascript-module-loader.h
│ │ │ ├── json-module-loader.cpp
│ │ │ ├── json-module-loader.h
│ │ │ ├── module-cache.cpp
│ │ │ ├── module-cache.h
│ │ │ ├── module-file-loader.h
│ │ │ ├── module-loader-helpers.cpp
│ │ │ ├── module-loader-helpers.h
│ │ │ ├── module-loader.cpp
│ │ │ ├── module-loader.h
│ │ │ ├── module-resolver-cache.cpp
│ │ │ ├── module-resolver-cache.h
│ │ │ ├── module-resolver.cpp
│ │ │ └── module-resolver.h
│ │ └── module.cpp
│ ├── platform/
│ │ ├── dll.cpp
│ │ ├── dll.h
│ │ ├── filesystem.cpp
│ │ ├── filesystem.h
│ │ ├── os.cpp
│ │ ├── os.h
│ │ ├── platform.h
│ │ ├── process.cpp
│ │ ├── process.h
│ │ └── thread-local.h
│ ├── providers/
│ │ ├── console-logging-provider.h
│ │ ├── nop-logging-provider.h
│ │ ├── nop-metric-provider.h
│ │ ├── providers.cpp
│ │ └── providers.h
│ ├── settings/
│ │ ├── settings-parser.cpp
│ │ ├── settings-parser.h
│ │ └── settings.h
│ ├── store/
│ │ ├── store.cpp
│ │ └── store.h
│ ├── utils/
│ │ └── string.h
│ ├── v8-extensions/
│ │ ├── CMakeLists.txt
│ │ ├── array-buffer-allocator.cpp
│ │ ├── array-buffer-allocator.h
│ │ ├── deserializer.cpp
│ │ ├── deserializer.h
│ │ ├── externalized-contents.cpp
│ │ ├── externalized-contents.h
│ │ ├── serialized-data.cpp
│ │ ├── serialized-data.h
│ │ ├── serializer.cpp
│ │ ├── serializer.h
│ │ ├── v8-common.cpp
│ │ ├── v8-common.h
│ │ ├── v8-extensions-macros.h
│ │ ├── v8-extensions.cpp
│ │ └── v8-extensions.h
│ └── zone/
│ ├── async-complete-task.cpp
│ ├── async-complete-task.h
│ ├── async-context.h
│ ├── async-runner.cpp
│ ├── call-context.cpp
│ ├── call-context.h
│ ├── call-task.cpp
│ ├── call-task.h
│ ├── eval-task.cpp
│ ├── eval-task.h
│ ├── napa-zone.cpp
│ ├── napa-zone.h
│ ├── node-zone.cpp
│ ├── node-zone.h
│ ├── schedule-phase.h
│ ├── scheduler.cpp
│ ├── scheduler.h
│ ├── simple-thread-pool.cpp
│ ├── simple-thread-pool.h
│ ├── task-decorators.h
│ ├── task.h
│ ├── terminable-task.cpp
│ ├── terminable-task.h
│ ├── timer.cpp
│ ├── timer.h
│ ├── worker-context.cpp
│ ├── worker-context.h
│ ├── worker.cpp
│ ├── worker.h
│ └── zone.h
├── test/
│ ├── memory-test.ts
│ ├── module/
│ │ ├── addon/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── addon.cpp
│ │ │ ├── simple-object-wrap.cpp
│ │ │ └── simple-object-wrap.h
│ │ ├── cycle-a.js
│ │ ├── cycle-b.js
│ │ ├── jsmodule.js
│ │ ├── node_modules/
│ │ │ └── file.js
│ │ ├── resolution-tests.js
│ │ ├── sub-folder/
│ │ │ ├── addon/
│ │ │ │ └── mock-addon.napa
│ │ │ └── file.js
│ │ └── test.json
│ ├── module-test.ts
│ ├── napa-zone/
│ │ ├── function-as-module.ts
│ │ ├── test-main.ts
│ │ └── test.ts
│ ├── store-test.ts
│ ├── sync-test.ts
│ ├── timer-test.ts
│ ├── transport-test.ts
│ ├── tsconfig.json
│ └── zone-test.ts
├── third-party/
│ ├── args/
│ │ ├── LICENSE
│ │ └── args.hxx
│ ├── catch/
│ │ ├── LICENSE.txt
│ │ └── catch.hpp
│ └── rapidjson/
│ ├── LICENSE.txt
│ ├── allocators.h
│ ├── document.h
│ ├── encodedstream.h
│ ├── encodings.h
│ ├── error/
│ │ ├── en.h
│ │ └── error.h
│ ├── filereadstream.h
│ ├── filewritestream.h
│ ├── fwd.h
│ ├── internal/
│ │ ├── biginteger.h
│ │ ├── diyfp.h
│ │ ├── dtoa.h
│ │ ├── ieee754.h
│ │ ├── itoa.h
│ │ ├── meta.h
│ │ ├── pow10.h
│ │ ├── regex.h
│ │ ├── stack.h
│ │ ├── strfunc.h
│ │ ├── strtod.h
│ │ └── swap.h
│ ├── istreamwrapper.h
│ ├── memorybuffer.h
│ ├── memorystream.h
│ ├── msinttypes/
│ │ ├── inttypes.h
│ │ └── stdint.h
│ ├── ostreamwrapper.h
│ ├── pointer.h
│ ├── prettywriter.h
│ ├── rapidjson.h
│ ├── reader.h
│ ├── schema.h
│ ├── stream.h
│ ├── stringbuffer.h
│ └── writer.h
└── unittest/
├── CMakeLists.txt
├── main.cpp
├── module/
│ ├── file-system-helpers-tests.cpp
│ ├── module-resolver-cache-tests.cpp
│ ├── module-resolver-tests.cpp
│ └── test-files/
│ ├── node_modules/
│ │ ├── resolve-nm-file
│ │ ├── resolve-nm-file-js.js
│ │ ├── resolve-nm-file-js.json
│ │ ├── resolve-nm-file-js.napa
│ │ ├── resolve-nm-file-json.json
│ │ ├── resolve-nm-file-json.napa
│ │ ├── resolve-nm-file-napa.napa
│ │ ├── resolve-nm-file.js
│ │ ├── resolve-nm-file.json
│ │ ├── resolve-nm-file.napa
│ │ ├── resolver-nm/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-nm-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-nm-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-nm-napa/
│ │ └── index.napa
│ ├── resolve-directory/
│ │ ├── resolver/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-napa/
│ │ └── index.napa
│ ├── resolve-env/
│ │ ├── resolve-env-file
│ │ ├── resolve-env-file-js.js
│ │ ├── resolve-env-file-js.json
│ │ ├── resolve-env-file-js.napa
│ │ ├── resolve-env-file-json.json
│ │ ├── resolve-env-file-json.napa
│ │ ├── resolve-env-file-napa.napa
│ │ ├── resolve-env-file.js
│ │ ├── resolve-env-file.json
│ │ ├── resolve-env-file.napa
│ │ ├── resolver-env/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-env-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-env-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-env-napa/
│ │ └── index.napa
│ ├── resolve-file
│ ├── resolve-file-js.js
│ ├── resolve-file-js.json
│ ├── resolve-file-js.napa
│ ├── resolve-file-json.json
│ ├── resolve-file-json.napa
│ ├── resolve-file-napa.napa
│ ├── resolve-file-no.js
│ ├── resolve-file.js
│ ├── resolve-file.json
│ └── resolve-file.napa
├── platform/
│ └── filesystem-tests.cpp
├── run.js
├── settings/
│ └── parser-tests.cpp
├── utils/
│ └── string-tests.cpp
└── zone/
├── scheduler-tests.cpp
└── timer-tests.cpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
bin
build
node_modules
types
# ignore all js files under lib except explicit ones specified here
lib/**/*.js
!lib/core/*.js
!lib/zone/zone-main.js
!lib/binding.js
# ignore all js files under test
test/**/*.js
test/module/test-dir
test/module/test-file
!test/module/node_modules
!test/module/**/*.js
!unittest/module/test-files/node_modules
# ignore all js files under benchmark
benchmark/**/*.js
package-lock.json
!tsconfig.json
# ignore all VSCode files
.vscode
# ignore npm related files
npm-debug.log
================================================
FILE: .npmignore
================================================
bin
build
examples
# Exclude TypeScript source files.
benchmark/**/*.ts
benchmark/tsconfig.json
lib/**/*.ts
lib/tsconfig.json
test/**/*.ts
test/module/test-dir
test/module/test-file
test/tsconfig.json
.vscode
.npmrc
.npmignore
.taskkey
.travis.yml
appveyor.yml
npm-debug.log
================================================
FILE: .travis.yml
================================================
language: node_js
compiler: default
matrix:
exclude:
# Disable the default build and use customized matrix only.
- compiler: default
include:
# Node 6.x Linux (Precise) G++5.4.1
- os: linux
dist: precise
node_js: '6'
compiler: g++-5
addons:
apt:
# The apt source 'ubuntu-toolchain-r-test' is for GCC 5+
# The apt source 'george-edison55-precise-backports' is for CMake 3.2+
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- g++-5
- cmake-data
- cmake
env:
- COMPILER_OVERRIDE="CXX=g++-5 CC=gcc-5"
# Node 6.x OS X (Yosemite) AppleClang 6.1
- os: osx
node_js: '6'
osx_image: xcode6.4
# Node LTS (8.x) Linux (Trusty) G++6.4.0
- os: linux
dist: trusty
node_js: '8'
compiler: g++-6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- COMPILER_OVERRIDE="CXX=g++-6 CC=gcc-6"
# Node LTS (8.x) OS X (El Capitan) AppleClang 7.3
- os: osx
node_js: '8'
osx_image: xcode7.3
# Node (9.x) Linux (Trusty) G++6.4.0
- os: linux
dist: trusty
node_js: '9'
compiler: g++-6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- COMPILER_OVERRIDE="CXX=g++-6 CC=gcc-6"
# Node (9.x) macOS (Sierra) AppleClang 8.1
- os: osx
node_js: '9'
osx_image: xcode8.3
# Node Current (10.x) Linux (Trusty) G++7.3.0
- os: linux
dist: trusty
node_js: '10'
compiler: g++-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- COMPILER_OVERRIDE="CXX=g++-7 CC=gcc-7"
# Node Current (10.x) macOS (High Sierra) AppleClang 9.1
- os: osx
node_js: '10'
osx_image: xcode9.3
before_install:
- |
if [ $TRAVIS_OS_NAME == linux ]; then
export ${COMPILER_OVERRIDE}
fi
install:
- npm install cmake-js -g
- npm install --no-fetch
script:
- npm test
- npm run unittest
================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project("napa")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
# Require Cxx14 features
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT WIN32 AND NOT APPLE)
# Set symbol visibility to hidden by default.
# Napa shared library shares a few classes with napa-binding.node with different compile definition,
# exposing the same symbols from both shared libraries may cause improper behaviors under gcc.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN)
# Prevent symbol relocations internal to our wrapper library to be overwritten by the application.
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic -Wl,-Bsymbolic-functions")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-Bsymbolic -Wl,-Bsymbolic-functions")
# Mark object non-lazy runtime binding.
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,now")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,now")
endif ()
# Build napa shared library.
add_subdirectory(src)
if (CMAKE_JS_VERSION)
# Build napa addon for node.
add_subdirectory(node)
add_subdirectory(test/module/addon)
endif()
================================================
FILE: LICENSE.txt
================================================
Napa.JS
Copyright (c) Microsoft Corporation. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
[](https://travis-ci.org/Microsoft/napajs)
[](https://ci.appveyor.com/project/napajs/napajs)
[](https://www.npmjs.com/package/napajs)
[](https://www.npmjs.com/package/napajs)
# Napa.js
Napa.js is a multi-threaded JavaScript runtime built on [V8](https://github.com/v8/v8), which was originally designed to develop highly iterative services with non-compromised performance in Bing. As it evolves, we find it useful to complement [Node.js](https://nodejs.org) in CPU-bound tasks, with the capability of executing JavaScript in multiple V8 isolates and communicating between them. Napa.js is exposed as a Node.js module, while it can also be embedded in a host process without Node.js dependency.
## Installation
Install the latest stable version:
```
npm install napajs
```
Other options can be found in [Build Napa.js](https://github.com/Microsoft/napajs/wiki/build-napa.js).
## Quick Start
```js
const napa = require('napajs');
const zone1 = napa.zone.create('zone1', { workers: 4 });
// Broadcast code to all 4 workers in 'zone1'.
zone1.broadcast('console.log("hello world");');
// Execute an anonymous function in any worker thread in 'zone1'.
zone1.execute(
(text) => text,
['hello napa'])
.then((result) => {
console.log(result.value);
});
```
More examples:
* [Estimate PI in parallel](./examples/tutorial/estimate-pi-in-parallel)
* [Max sub-matrix of 1s with layered parallelism](./examples/tutorial/max-square-sub-matrix)
* [Parallel Quick Sort](./examples/tutorial/parallel-quick-sort)
* [Recursive Fibonacci with multiple JavaScript threads](./examples/tutorial/recursive-fibonacci)
* [Synchronized loading](./examples/tutorial/synchronized-loading)
## Features
- Multi-threaded JavaScript runtime.
- Node.js compatible module architecture with NPM support.
- API for object transportation, object sharing and synchronization across JavaScript threads.
- API for pluggable logging, metric and memory allocator.
- Distributed as a Node.js module, as well as supporting embed scenarios.
## Documentation
- [Napa.js Home](https://github.com/Microsoft/napajs/wiki)
- [API Reference](./docs/api/index.md)
- [FAQ](https://github.com/Microsoft/napajs/wiki/FAQ)
# Contribute
You can contribute to Napa.js in following ways:
* [Report issues](https://github.com/Microsoft/napajs/issues) and help us verify fixes as they are checked in.
* Review the [source code changes](https://github.com/Microsoft/napajs/pulls).
* Contribute to core module compatibility with Node.
* Contribute bug fixes.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).<br> For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact opencode@microsoft.com with any additional questions or comments.
# License
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the [MIT](https://github.com/Microsoft/napajs/blob/master/LICENSE.txt) License.
================================================
FILE: appveyor.yml
================================================
environment:
matrix:
# Windows Server 2012 R2 Visual C++ Build Tools 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
nodejs_version: 6
# Windows Server 2012 R2 Visual C++ Build Tools 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
nodejs_version: 8
# Windows Server 2016 Visual C++ Build Tools 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
nodejs_version: 9
# Windows Server 2016 Visual C++ Build Tools 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
nodejs_version: 10
platform:
- x64
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install cmake-js -g
- npm install --no-fetch
# Skip MSBuild stage
build: off
test_script:
- npm test
- npm run unittest
================================================
FILE: benchmark/README.md
================================================
# Benchmark
## Summary
- JavaScript execution in napajs is on par with node, using the same version of V8, which is expected.
- `zone.execute` scales linearly on number of workers, which is expected.
- The overhead of calling `zone.execute` from node is around 0.1ms after warm-up. The cost of using anonymous function is neglectable.
- `transport.marshall` cost on small plain JavaScript values is about 3x of JSON.stringify.
- The overhead of `store.set` and `store.get` is around 0.06ms plus transport overhead on the objects.
We got this report on environment below:
| Name | Value |
|-------------------|---------------------------------------------------------------------------------------|
|**Processor** |Intel(R) Xeon(R) CPU L5640 @ 2.27GHz, 8 virtual processors |
|**System Type** |x64-based PC |
|**Physical Memory**|16.0 GB |
|**OS version** |Microsoft Windows Server 2012 R2 |
## Napa vs. Node on JavaScript execution
Please refer to [node-napa-perf-comparison.ts](node-napa-perf-comparison.ts).
| node time | napa time |
| --------- | --------- |
| 3026.76 | 3025.81 |
## Linear scalability
`zone.execute` scales linearly on number of workers. We performed 1M CRC32 calls on a 1024-length string on each worker, here are the numbers. We still need to understand why the time of more workers running parallel would beat less workers.
| | node | napa - 1 worker | napa - 2 workers | napa - 4 workers | napa - 8 workers |
| ------- | ----------- | --------------- | ---------------- | ---------------- | ---------------- |
| time | 8,649521600 | 6146.98 | 4912.57 | 4563.48 | 6168.41 |
| cpu% | ~15% | ~15% | ~27% | ~55% | ~99% |
Please refer to [execute-scalability.ts](./execute-scalability.ts) for test details.
## Execute overhead
The overhead of `zone.execute` includes
1. Marshalling cost of arguments in caller thread.
2. Queuing time before a worker can execute.
3. Unmarshalling cost of arguments in target worker.
4. Marshalling cost of return value from target worker.
5. Queuing time before caller callback is notified.
6. Unmarshalling cost of return value in caller thread.
In this section we will examine #2 and #5. So we use empty function with no arguments and no return value.
Transport overhead (#1, #3, #4, #6) varies by size and complexity of payload, will be benchmarked separately in [Transport Overhead](#transport-overhead) section.
Please refer to [execute-overhead.ts](./execute-overhead.ts) for test details.
### Overhead after warm-up
Average overhead is around 0.06ms to 0.12ms for `zone.execute`.
| repeat | zone.execute (ms) |
|----------|-------------------|
| 200 | 24.932 |
| 5000 | 456.893 |
| 10000 | 810.687 |
| 50000 | 3387.361 |
*10000 times of zone.execute on anonymous function is 807.241ms. The gap is within range of bench noise.
### Overhead during warm-up:
| Sequence of call | Time (ms) |
|------------------|-----------|
| 1 | 6.040 |
| 2 | 4.065 |
| 3 | 5.250 |
| 4 | 4.652 |
| 5 | 1.572 |
| 6 | 1.366 |
| 7 | 1.403 |
| 8 | 1.213 |
| 9 | 0.450 |
| 10 | 0.324 |
| 11 | 0.193 |
| 12 | 0.238 |
| 13 | 0.191 |
| 14 | 0.230 |
| 15 | 0.203 |
| 16 | 0.188 |
| 17 | 0.188 |
| 18 | 0.181 |
| 19 | 0.185 |
| 20 | 0.182 |
## Transport overhead
The overhead of `transport.marshall` includes
1. overhead of needing replacer callback during JSON.stringify. (even an empty callback will slow down JSON.stringify significantly)
2. traverse every value during JSON.stringify, to check value type and get `cid` to put into payload.
- a. If value doesn't need special care.
- b. If value is a transportable object that needs special care.
2.b is related to individual transportable classes, which may vary per individual class. Thus we examine #1 and #2.a in this test.
The overhead of `transport.unmarshall` includes
1. overhead of needing reviver callback during JSON.parse.
2. traverse every value during JSON.parse, to check if object has `_cid` property.
- a. If value doesn't have property `_cid`.
- b. Otherwise, find constructor and call the [`Transportable.marshall`](../docs/api/transport.md#transportable-marshall).
We also evaluate only #1, #2.a in this test.
Please refer to [transport-overhead.ts](./transport-overhead.ts) for test details.
\*All operations are repeated for 1000 times.
| payload type | size | JSON.stringify (ms) | transport.marshall (ms) | JSON.parse (ms) | transport.unmarshall (ms) |
| ---------------------------------- | ----- | ------------------- | ----------------------- | --------------- | ------------------------- |
| 1 level - 10 integers | 91 | 4.90 | 18.05 (3.68x) | 3.50 | 17.98 (5.14x) |
| 1 level - 100 integers | 1081 | 65.45 | 92.78 (1.42x) | 20.45 | 122.25 (5.98x) |
| 10 level - 2 integers | 18415 | 654.40 | 2453.37 (3.75x) | 995.02 | 2675.72 (2.69x) |
| 2 level - 10 integers | 991 | 19.74 | 66.82 (3.39x) | 27.85 | 138.45 (4.97x) |
| 3 level - 5 integers | 1396 | 33.66 | 146.33 (4.35x) | 51.54 | 189.07 (3.67x) |
| 1 level - 10 strings - length 10 | 201 | 3.81 | 10.17 (2.67x) | 9.46 | 20.81 (2.20x) |
| 1 level - 100 strings - length 10 | 2191 | 76.53 | 115.74 (1.51x) | 77.71 | 181.24 (2.33x) |
| 2 level - 10 strings - length 10 | 2091 | 30.15 | 97.65 (3.24x) | 95.51 | 213.20 (2.23x) |
| 3 level - 5 strings - length 10 | 2646 | 41.95 | 155.42 (3.71x) | 123.82 | 227.90 (1.84x) |
| 1 level - 10 strings - length 100 | 1101 | 7.74 | 12.19 (1.57x) | 17.34 | 29.83 (1.72x) |
| 1 level - 100 strings - length 100 | 11191 | 66.17 | 112.83 (1.71x) | 197.67 | 282.63 (1.43x) |
| 2 level - 10 strings - length 100 | 11091 | 68.46 | 149.99 (2.19x) | 202.85 | 298.19 (1.47x) |
| 3 level - 5 integers | 13896 | 89.46 | 208.21 (2.33x) | 265.25 | 418.42 (1.58x) |
| 1 level - 10 booleans | 126 | 2.84 | 8.14 (2.87x) | 3.06 | 14.20 (4.65x) |
| 1 level - 100 booleans | 1341 | 20.28 | 59.36 (2.93x) | 21.59 | 121.15 (5.61x) |
| 2 level - 10 booleans | 1341 | 23.92 | 89.62 (3.75x) | 31.84 | 137.92 (4.33x) |
| 3 level - 5 booleans | 1821 | 36.15 | 138.24 (3.82x) | 55.71 | 195.50 (3.51x) |
## Store access overhead
The overhead of `store.set` includes
1. Overhead of calling `transport.marshall` on value.
2. Overhead of put marshalled data and transport context into C++ map (with exclusive_lock).
The overhead of `store.get` includes
1. Overhead of getting marshalled data and transport context from C++ map (with shared_lock).
2. Overhead of calling `transport.unmarshall` on marshalled data.
For `store.set`, numbers below indicates the cost beyond marshall is around 0.07~0.4ms varies per payload size. (10B to 18KB). `store.get` takes a bit more: 0.06~0.9ms with the same payload size variance. If the value in store is not updated frequently, it's always good to cache it in JavaScript world.
Please refer to [store-overhead.ts](./store-overhead.ts) for test details.
\*All operations are repeated for 1000 times.
| payload type | size | transport.marshall (ms) | store.save (ms) | transport.unmarshall (ms) | store.get (ms) |
| ---------------------------------- | ----- | ----------------------- | --------------- | ------------------------- | -------------- |
| 1 level - 1 integers | 10 | 2.54 | 73.85 | 3.98 | 65.57 |
| 1 level - 10 integers | 91 | 8.27 | 98.55 | 17.23 | 90.89 |
| 1 level - 100 integers | 1081 | 97.10 | 185.31 | 144.75 | 274.39 |
| 10 level - 2 integers | 18415 | 2525.18 | 2973.17 | 3093.06 | 3927.80 |
| 2 level - 10 integers | 991 | 71.22 | 174.01 | 154.76 | 276.04 |
| 3 level - 5 integers | 1396 | 127.06 | 219.73 | 182.27 | 337.59 |
| 1 level - 10 strings - length 10 | 201 | 14.43 | 79.68 | 31.28 | 84.71 |
| 1 level - 100 strings - length 10 | 2191 | 104.40 | 212.44 | 173.32 | 239.09 |
| 2 level - 10 strings - length 10 | 2091 | 79.54 | 188.72 | 189.29 | 252.83 |
| 3 level - 5 strings - length 10 | 2646 | 155.14 | 257.78 | 276.22 | 342.95 |
| 1 level - 10 strings - length 100 | 1101 | 15.22 | 89.84 | 30.87 | 88.18 |
| 1 level - 100 strings - length 100 | 11191 | 119.89 | 284.05 | 287.17 | 403.77 |
| 2 level - 10 strings - length 100 | 11091 | 137.10 | 299.32 | 244.13 | 297.12 |
| 3 level - 5 integers | 13896 | 183.84 | 310.89 | 285.80 | 363.50 |
| 1 level - 10 booleans | 126 | 5.74 | 49.89 | 22.69 | 97.27 |
| 1 level - 100 booleans | 1341 | 57.41 | 157.80 | 106.30 | 218.05 |
| 2 level - 10 booleans | 1341 | 76.93 | 150.25 | 104.02 | 185.82 |
| 3 level - 5 booleans | 1821 | 102.47 | 171.44 | 150.42 | 207.27 |
================================================
FILE: benchmark/bench-utils.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
/// <summary> Utility function to generate object for testing. </summary>
export function generateString(length: number): string {
return Array(length).join('x');
}
export function generateObject(keys: number, depth: number, valueType: string = "string", valueLength = 7) {
let object: any = {};
for (let i = 0; i < keys; ++i) {
let key = `key${i}`;
let value: any = null;
if (depth > 1) {
value = generateObject(keys, depth - 1, valueType, valueLength);
}
else if (valueType === 'string') {
// We try to make each string different.
value = generateString(valueLength - 1) + (depth * keys + i);
}
else if (valueType === 'number') {
value = i;
}
else if (valueType === 'boolean') {
value = i % 2 == 0;
}
object[key] = value;
}
return object;
}
export function timeDiffInMs(diff: [number, number]): number {
return (diff[0] * 1e9 + diff[1]) / 1e6;
}
export function formatTimeDiff(diff: number | [number, number], printUnit: boolean = false): string {
if (Array.isArray(diff)) {
diff = timeDiffInMs(diff);
}
let message = diff.toFixed(2);
if (printUnit) {
message += "ms"
}
return message;
}
export function formatRatio(dividend: number, divider: number): string {
return "(" + (dividend / divider).toFixed(2) + "x)";
}
================================================
FILE: benchmark/bench.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as nodeNapaPerfComp from './node-napa-perf-comparison';
import * as executeOverhead from './execute-overhead';
import * as executeScalability from './execute-scalability';
import * as transportOverhead from './transport-overhead';
import * as storeOverhead from './store-overhead';
export function bench(): Promise<void> {
// Non-zone related benchmarks.
transportOverhead.bench();
storeOverhead.bench();
// Create zones for execute related benchmark.
let singleWorkerZone = napa.zone.create('single-worker-zone', { workers: 1});
let multiWorkerZone = napa.zone.create('multi-worker-zone', { workers: 8 });
return nodeNapaPerfComp.bench(singleWorkerZone)
.then(() => { return executeOverhead.bench(singleWorkerZone); })
.then(() => { return executeScalability.bench(multiWorkerZone);});
}
bench();
================================================
FILE: benchmark/execute-overhead.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as mdTable from 'markdown-table';
import { formatTimeDiff } from './bench-utils';
function batchExecuteOnNamedFunction(
zone: napa.zone.Zone,
repeat: number,
args: any[]): Promise<void> {
return new Promise<void>((resolve, reject) => {
let finished = 0;
let start = process.hrtime();
for (let i = 0; i < repeat; ++i) {
zone.execute("", "test", args).then(() => {
++finished;
if (finished === repeat) {
resolve();
}
});
}
});
}
function batchExecuteOnAnonymousFunction(
zone: napa.zone.Zone,
repeat: number,
args: any[]): Promise<void> {
return new Promise<void>((resolve, reject) => {
let finished = 0;
let start = process.hrtime();
for (let i = 0; i < repeat; ++i) {
zone.execute(() => {}, args).then(() => {
++finished;
if (finished === repeat) {
resolve();
}
});
}
});
}
export async function bench(zone: napa.zone.Zone): Promise<void> {
console.log("Benchmarking execute overhead...");
// Prepare a empty function.
await zone.broadcast("function test() {}");
const ARGS = [1, "hello", {a: 1, b: true}];
// Warm-up.
const WARMUP_REPEAT: number = 20;
console.log("## Execute overhead during warmup\n")
let warmupTable = [];
warmupTable.push(["call #", "time (ms)"]);
for (let i = 0; i < WARMUP_REPEAT; ++i) {
let start = process.hrtime();
await zone.execute("", "test", ARGS);
warmupTable.push([i.toString(), formatTimeDiff(process.hrtime(start))]);
}
console.log(mdTable(warmupTable));
// execute after warm-up
const REPEAT: number = 10000;
console.log("## `zone.execute` overhead (use function name)\n");
let start = process.hrtime();
await batchExecuteOnNamedFunction(zone, REPEAT, ARGS);
console.log(`Elapse of running empty function by name for ${REPEAT} times: ${formatTimeDiff(process.hrtime(start), true)}\n`);
console.log("## `zone.execute` overhead (use anonymous function)\n");
start = process.hrtime();
await batchExecuteOnAnonymousFunction(zone, REPEAT, ARGS);
console.log(`Elapse of running empty anonymous function for ${REPEAT} times: ${formatTimeDiff(process.hrtime(start), true)}\n`);
return;
}
================================================
FILE: benchmark/execute-scalability.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as assert from 'assert';
import * as mdTable from 'markdown-table';
import { formatTimeDiff } from './bench-utils';
function makeCRCTable(){
var c;
var crcTable = [];
for(var n =0; n < 256; n++){
c = n;
for(var k =0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
crcTable[n] = c;
}
return crcTable;
}
let crcTable = makeCRCTable();
function crc32(str: string) {
let crc = 0 ^ (-1);
for (var i = 0; i < str.length; i++ ) {
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
};
function testCrc() {
const REPEAT: number = 1000000;
let result = 0;
let key = Array(1024).join('x');
for (let i = 0; i < REPEAT; ++i) {
let hash = crc32(key);
result = result ^ hash;
}
return result;
}
export async function bench(zone: napa.zone.Zone): Promise<void> {
console.log("Benchmarking execute scalability...");
// Prepare a empty function.
await zone.broadcast(makeCRCTable.toString());
await zone.broadcast("var crcTable = makeCRCTable();");
await zone.broadcast(crc32.toString());
await zone.broadcast(testCrc.toString());
// Warm-up.
let crcResult = testCrc();
await zone.broadcast("testCrc()");
// Execute in Node with 1 thread.
let start = process.hrtime();
assert(testCrc() === crcResult);
let nodeTime = formatTimeDiff(process.hrtime(start));
let executeTime = {};
let scalabilityTest = function(workers: number): Promise<void> {
let finished = 0;
let start = process.hrtime();
return new Promise<void>((resolve, reject) => {
for (let i = 0; i < workers; ++i) {
zone.execute("", "testCrc", []).then((result: napa.zone.Result) => {
assert(crcResult === result.value);
++finished;
if (finished === workers) {
executeTime[workers] = formatTimeDiff(process.hrtime(start))
resolve();
}
});
}
})
};
// Execute from 1 worker to 8 workers.
await scalabilityTest(1);
await scalabilityTest(2);
await scalabilityTest(4);
await scalabilityTest(8);
console.log("## Execute scalability\n")
console.log(mdTable([
["node", "napa - 1 worker", "napa - 2 workers", "napa - 4 workers", "napa - 8 workers"],
[nodeTime, executeTime[1], executeTime[2], executeTime[4], executeTime[8]]
]));
console.log('');
}
================================================
FILE: benchmark/node-napa-perf-comparison.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as mdTable from 'markdown-table';
import { formatTimeDiff } from './bench-utils';
export function timeIt(func: () => void): [number, number] {
let start = process.hrtime();
func();
return process.hrtime(start);
}
export function test1(): [number, number] {
return timeIt(() => {
const REPEAT = 1000000000;
let sum = 0;
for (let i = 0; i < REPEAT; ++i) {
sum += i;
}
});
}
export async function bench(zone: napa.zone.Zone): Promise<void> {
zone.broadcast(timeIt.toString());
zone.broadcast(test1.toString());
// Warm up.
test1();
await zone.execute('', 'test1', []);
// Actual test.
let table = [];
table.push(["node time", "napa time"]);
let nodeTime = formatTimeDiff(test1());
let napaTime = formatTimeDiff((await zone.execute('', 'test1', [])).value);
table.push([nodeTime, napaTime]);
console.log("## Node vs Napa JavaScript execution performance\n");
console.log(mdTable(table));
console.log('');
}
================================================
FILE: benchmark/store-overhead.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as assert from 'assert';
import * as mdTable from 'markdown-table';
import { generateObject, formatTimeDiff } from './bench-utils';
type BenchmarkSettings = [
string, // label
number, // # of keys per level
number, // # of levels
string, // value type
number // value length for string.
];
export function bench() {
console.log("Benchmarking store overhead...");
let settings: BenchmarkSettings[] = [
// Number
["1 level - 1 integers", 1, 1, "number", 0],
["1 level - 10 integers", 10, 1, "number", 0],
["1 level - 100 integers", 100, 1, "number", 0],
["10 level - 2 integers", 2, 10, "number", 0],
["2 level - 10 integers", 10, 2, "number", 0],
["3 level - 5 integers", 5, 3, "number", 0],
// String
["1 level - 10 strings - length 10", 10, 1, "string", 10],
["1 level - 100 strings - length 10", 100, 1, "string", 10],
["2 level - 10 strings - length 10", 10, 2, "string", 10],
["3 level - 5 strings - length 10", 5, 3, "string", 10],
["1 level - 10 strings - length 100", 10, 1, "string", 100],
["1 level - 100 strings - length 100", 100, 1, "string", 100],
["2 level - 10 strings - length 100", 10, 2, "string", 100],
["3 level - 5 integers", 5, 3, "string", 100],
// Boolean
["1 level - 10 booleans", 10, 1, "boolean", 0],
["1 level - 100 booleans", 100, 1, "boolean", 0],
["2 level - 10 booleans", 10, 2, "boolean", 0],
["3 level - 5 booleans", 5, 3, "boolean", 0],
];
let store = napa.store.create('store');
let table = [];
table.push(["payload type", "size", "transport.marshall (ms)", "store.save (ms)", "transport.unmarshall (ms)", "store.get (ms)"]);
for (let s of settings) {
const REPEAT = 1000;
let object = generateObject(s[1], s[2], s[3], s[4])
let payload = JSON.stringify(object);
let size = payload.length;
// transport.marshall
let start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
napa.transport.marshall(object, null);
}
let marshallTime = formatTimeDiff(process.hrtime(start));
// store.set
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
store.set('key', object);
}
let storeSetTime = formatTimeDiff(process.hrtime(start));
assert.deepEqual(object, store.get('key'));
// transport.unmarshall
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
napa.transport.unmarshall(payload, null);
}
let unmarshallTime = formatTimeDiff(process.hrtime(start));
// store.get
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
store.get('key');
}
let storeGetTime = formatTimeDiff(process.hrtime(start));
table.push([s[0], size, marshallTime, storeSetTime, unmarshallTime, storeGetTime]);
}
console.log("## Store access overhead\n");
console.log(mdTable(table));
console.log('');
}
================================================
FILE: benchmark/transport-overhead.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as napa from '../lib/index';
import * as assert from 'assert';
import * as mdTable from 'markdown-table';
import { generateObject, timeDiffInMs, formatTimeDiff, formatRatio } from './bench-utils';
type BenchmarkSettings = [
string, // label
number, // # of keys per level
number, // # of levels
string, // value type
number // value length for string.
];
export function bench() {
console.log("Benchmarking transport overhead...");
let settings: BenchmarkSettings[] = [
// Number
["1 level - 10 integers", 10, 1, "number", 0],
["1 level - 100 integers", 100, 1, "number", 0],
["10 level - 2 integers", 2, 10, "number", 0],
["2 level - 10 integers", 10, 2, "number", 0],
["3 level - 5 integers", 5, 3, "number", 0],
// String
["1 level - 10 strings - length 10", 10, 1, "string", 10],
["1 level - 100 strings - length 10", 100, 1, "string", 10],
["2 level - 10 strings - length 10", 10, 2, "string", 10],
["3 level - 5 strings - length 10", 5, 3, "string", 10],
["1 level - 10 strings - length 100", 10, 1, "string", 100],
["1 level - 100 strings - length 100", 100, 1, "string", 100],
["2 level - 10 strings - length 100", 10, 2, "string", 100],
["3 level - 5 integers", 5, 3, "string", 100],
// Boolean
["1 level - 10 booleans", 10, 1, "boolean", 0],
["1 level - 100 booleans", 100, 1, "boolean", 0],
["2 level - 10 booleans", 10, 2, "boolean", 0],
["3 level - 5 booleans", 5, 3, "boolean", 0],
];
let table = [];
table.push(["payload type", "size", "JSON.stringify (ms)", "transport.marshall (ms)", "JSON.parse (ms)", "transport.unmarshall (ms)"]);
for (let s of settings) {
const REPEAT = 1000;
let object = generateObject(s[1], s[2], s[3], s[4])
let payload = JSON.stringify(object);
let size = payload.length;
// JSON.stringify
let start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
JSON.stringify(object);
}
let stringifyTime = timeDiffInMs(process.hrtime(start));
let stringifyTimeText = formatTimeDiff(stringifyTime);
// transport.marshall
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
napa.transport.marshall(object, null);
}
let marshallTime = timeDiffInMs(process.hrtime(start));
let marshallTimeText = formatTimeDiff(marshallTime) + " " + formatRatio(marshallTime, stringifyTime);
let marshalled = napa.transport.marshall(object, null);
assert.deepEqual(payload, marshalled);
// JSON.parse
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
JSON.parse(payload);
}
let parseTime = timeDiffInMs(process.hrtime(start));
let parseTimeText = formatTimeDiff(parseTime);
start = process.hrtime();
for (let i = 0; i < REPEAT; ++i) {
napa.transport.unmarshall(payload, null);
}
let unmarshallTime = timeDiffInMs(process.hrtime(start));
let unmarshallTimeText = formatTimeDiff(unmarshallTime) + " " + formatRatio(unmarshallTime, parseTime);
table.push([s[0], size, stringifyTimeText, marshallTimeText, parseTimeText, unmarshallTimeText]);
}
console.log("## Transport overhead\n");
console.log(mdTable(table));
console.log('');
}
================================================
FILE: benchmark/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": false,
"declaration": false,
"sourceMap": false,
"lib": ["es2015"]
}
}
================================================
FILE: build.bat
================================================
:: Copyright (c) Microsoft Corporation. All rights reserved.
:: Licensed under the MIT license.
@echo off
set NODE_EXE=%~dp0\node.exe
if not exist "%NODE_EXE%" (
set NODE_EXE=node
)
%NODE_EXE% %~dp0\build.js %*
================================================
FILE: build.js
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// Distinguish between running this file as a script or loading it as a module.
if (module.parent) {
// Loaded as a module - 'require('./build.js')
exports.paths = require('./scripts/paths');
}
else {
// Loaded as a script - 'node build.js'
// Remove first two parameters which are node executable and this javascript file.
// Transform all parameters to lowercase for easier handling.
let params = process.argv.slice(2).map((item) => item.toLowerCase());
// Specify wheater cleanup is needed.
if (params.indexOf('clean') != -1) {
require('./scripts/clean').clean();
}
// Only build if embed was specified as a parameter.
if (params.indexOf('embed') != -1) {
let embedded = require('./scripts/embedded');
if (params.indexOf('debug') != -1) {
embedded.build('debug');
}
else {
embedded.build('release');
}
}
}
================================================
FILE: docs/api/index.md
================================================
# API References
## Core modules
- Napa.js specific [`global`](./napa-globals.md) variables
- Namespace [`zone`](./zone.md): Multi-thread JavaScript runtime
- Namespace [`transport`](./transport.md): Passing JavaScript values across threads
- Namespace [`store`](./store.md): Sharing JavaScript values by global storage
- Namespace [`sync`](./sync.md): Handling synchronization between threads
- Namespace [`memory`](./memory.md): Handling native objects and memory
- Namespace [`metric`](./metric.md): Pluggable metrics.
- Function [`log`](./log.md): Pluggable logging.
## Node compatibility
- [List of supported Node APIs](./node-api.md)
## API for creating modules
- [Writing Napa.js modules](./module.md)
================================================
FILE: docs/api/log.md
================================================
# Function `log`
## Table of Contents
- [Introduction](#intro)
- [C++ API](#cpp-api)
- [JavaScript API](#js-api)
- [`log(message: string): void`](#log)
- [`log(section: string, message: string): void`](#log-with-section)
- [`log(section: string, traceId: string, message: string): void`](#log-with-traceid)
- [`log.err(...)`](#log-err)
- [`log.warn(...)`](#log-warn)
- [`log.info(...)`](#log-info)
- [`log.debug(...)`](#log-debug)
- [Using custom logging providers](#use-custom-providers)
- [Developing custom logging providers](#develop-custom-providers)
## <a name="intro"></a> Introduction
Logging is a basic requirement for building services. `napajs` logging API enables developers to integrate their own logging capabilities in both JavaScript and C++ (addon) world.
A log row may contain the following information:
- (Optional) Section: Useful field to filter log rows. Treatment is defined by logging providers.
- (Optional) Trace ID: Useful field to join logs in the same transaction or request.
- (Required) Message: Log message.
- (Required) Logging level:
- Error: for application error.
- Warn: for warning information.
- Info: for notification.
- Debug: for debugging purpose.
## <a name="cpp-api"></a> C++ API
Include header: `<napa.h>`
Macros:
- LOG_ERROR(section, format, ...)
- LOG_ERROR_WITH_TRACEID(section, traceId, format, ...)
- LOG_WARNING(section, format, ...)
- LOG_WARNING_WITH_TRACEID(section, traceId, format, ...)
- LOG_INFO(section, format, ...)
- LOG_INFO_WITH_TRACEID(section, traceId, format, ...)
- LOG_DEBUG(section, format, ...)
- LOG_DEBUG_WITH_TRACEID(section, traceId, format, ...)
```cpp
#include <napa.h>
void MyFunction() {
// ...
LOG_ERROR("init", "error: %s", errorMessage.c_str());
}
```
## <a name="js-api"></a> JavaScript API
### <a name="log"></a> log(message: string): void
It logs a message. Using info level.
* A `log` is a shortcut for `log.info`.*
Example:
```js
var napa = require('napajs');
napa.log('program started');
```
### <a name="log-with-section"></a> log(section: string, message: string): void
It logs a message with a section. Using info level.
Example:
```js
napa.log('init', 'program started');
```
### <a name="log-with-traceid"></a> log(section: string, traceId: string, message: string): void
It logs a message with a section, associating it with a traceId. Using info level.
Example:
```js
napa.log('request', 'A1B2C3D4', 'request received');
```
### <a name="log-err"></a> log.err(...)
It logs an error message. Three variations of arguments are the same with the `log`.
### <a name="log-warn"></a> log.warn(...)
It logs a warning message. Three variations of arguments are the same with the `log`.
### <a name="log-info"></a>log.info(...)
It logs an info message. Three variations of arguments are the same with the `log`.
### <a name="log-debug"></a> log.debug(...)
It logs a debug message. Three combinations of arguments are the same with the `log`.
## <a name="use-custom-providers"></a> Using custom logging providers
Developers can hook up custom logging provider by calling the following before creation of any zones:
```js
napa.runtime.setPlatformSettings({
"loggingProvider": "<custom-logging-provider-module-name>"
}
```
## <a name="develop-custom-providers"></a> Developing custom logging providers
TBD
================================================
FILE: docs/api/memory.md
================================================
# Namespace `memory`
## Table of Contents
- [API](#api)
- Type [`Handle`](#handle)
- Interface [`Shareable`](#shareable)
- Interface [`Allocator`](#allocator)
- [`allocator.allocate(size: number): Handle`](#allocator-allocate)
- [`allocator.deallocate(handle: Handle, sizeHint: number): void`](#allocator-deallocate)
- [`allocator.type: string`](#allocator-type)
- Interface [`AllocatorDebugger`](#allocatordebugger)
- [`allocatorDebugger.getDebugInfo(): string`](#allocatordebugger-getdebuginfo)
- Function [`debugAllocator(allocator: Allocator): AllocatorDebugger`](#debugallocator)
- Object [`crtAllocator`](#crtallocator)
- Object [`defaultAllocator`](#defaultallocator)
- [Memory allocation in C++ addon](#memory-allocation-in-cpp-addon)
## <a name="api"></a> API
## <a name="handle"></a> Type `Handle`
Handle is defined in TypeScript as below:
```ts
type Handle = [number, number]
```
It is a standard way to represent a 64-bit pointer in Napa.
## <a name="shareable"></a> Interface `Shareable`
Interface for native object wrap that can be shared across multiple JavaScript threads.
## <a name="allocator"></a> Interface `Allocator`
Interface for memory allocator that allocates memory for native objects.
### <a name="allocator-allocate"></a> allocator.allocate(size: number): Handle
It allocates memory of requested size.
```js
var handle = allocator.allocate(10);
```
### <a name="allocator-deallocate"></a> allocator.deallocate(handle: Handle, sizeHint: number): void
It deallocates memory from a input handle, with a size hint which is helpful for some C++ allocator implementations for deallocating memory.
```js
allocator.deallocate(handle, 10);
```
### <a name="allocator-type"></a> allocator.type: string
It gets a string type identifier for the allocator, which will be useful during debugging purpose.
## <a name="allocatordebugger"></a> Interface `AllocatorDebugger`
`AllocatorDebugger` extends interface `Allocator`, with a member function `getDebugInfo` to expose debug information. Basically an allocator debugger will use a pass-in allocator for memory allocation, meanwhile intercepting it to keep track of allocation count and size.
### <a name="allocatordebugger-getdebuginfo"></a> allocatorDebugger.getDebugInfo(): string
It gets the debug information for allocation. Implementations of interface `AllocatorDebugger` can have different schema on debug info.
## <a name="debugallocator"></a> debugAllocator(allocator: Allocator): AllocatorDebugger
It returns a simple allocator debugger, which returns debug information like below:
```json
{
"allocate": 10,
"allocateSize": 1024,
"deallocate": 8,
"deallocateSize": 912
}
```
## <a name="crtallocator"></a> Object `crtAllocator`
It returns a C-runtime allocator from Napa.js shared library. Its corresponding C++ part is `napa::memory::GetCrtAllocator()`.
## <a name="defaultallocator"></a> Object `defaultAllocator`
It returns the default allocator from Napa.js shared library. Its corresponding C++ part is `napa::memory::GetDefaultAllocator()`.
Users can set default allocation/deallocation callback in `napa_allocator_set` API.
## <a name="memory-allocation-in-cpp-addon"></a> Memory allocation in C++ addon
Memory allocation in C++ addon is tricky. A common pitfall is to allocate memory in one dll, but deallocate in another. This can cause issue if C-runtime in these 2 dlls are not compiled the same way.
There are also advanced scenarios that user want to customize memory allocation. Napa.js provides APIs for customizing memory allocator as well.
### Recommended way of allocate memory
TBD
### Customize memory allocation
TBD
================================================
FILE: docs/api/metric.md
================================================
# Namespace `metric`
## Table of Contents
- [Introduction](#intro)
- [C++ API](#cpp-api)
- Interface [`Metric`](#cpp-metric)
- Interface [`MetricProvider`](#cpp-metricprovider)
- Function [`MetricProvider& GetMetricProvider()`](#cpp-getmetricprovider)
- [JavaScript API](#js-api)
- Enum [`MetricType`](#metrictype)
- Class [`Metric`](#metric)
- [`set(value: number, dimensions?: string[]): void`](#metric-set)
- [`increment(dimensions?: string[]): void`](#metric-increment);
- [`decrement(dimensions?: string[]): void`](#metric-decrement);
- Function [`get(section: string, name: string, type: MetricType, dimensionNames: string[])`](#get)
- [Using custom metric providers](#use-custom-providers)
- [Developing custom metric providers](#develop-custom-providers)
## <a name="intro"></a> Introduction
Similar as logging, metric is a basic requirement for creating monitorable services. Metric API enables developers to use their own metric system in both JavaScript and C++ (addon) world.
A metric has its identity containing following information:
- **Section**: The group or category of the metric.
- **Name**: Name of the metric. Section/Name combination should be unique in the system.
- **Type**: Type of the metric, which can be
- *Number*: An absolute number, e.g: PrivateBytes.
- *Rate*: A flowing volume in number, e.g: QueryPerSecond.
- *Percentile*: An absolute number that needs to be sampled by percentiles, e.g: SuccessLatency.
- **Dimensions**: A metric can have multiple dimensions, each dimension can bind with a string value at runtime. e.g: IncomingRequestRate can have 2 dimensions: ['client-id', 'request-type'].
Metrics are process-wise objects, which can be used across [zones](./zone.md#intro).
## <a name="cpp-api"></a> C++ API
### <a name="cpp-metric"></a> Interface Metric
```cpp
/// <summary> Enumeration of metric type. </summary>
enum class MetricType {
Number = 0,
Rate,
Percentile,
};
/// <summary> Interface to represent a multi-dimensional metric with a maximum dimensionality of 64. </summary>
class Metric {
public:
/// <summary> Sets a metric value with variadic dimension arguments. </summary>
/// <param name="value"> Int64 value. </param>
/// <param name="numberOfDimensions"> Number of dimensions being set. </param>
/// <param name="dimensionValues"> Array of dimension value names. </param>
/// <returns> Success/Fail. </returns>
/// <remarks>
/// The number of dimension values must exactly match the number of dimensions provided when
/// creating this metric.
/// </remarks>
virtual bool Set(int64_t value, size_t numberOfDimensions, const char* dimensionValues[]) = 0;
/// <summary>
/// Increments a metric value with variadic dimension arguments.
/// Use mainly to simplify rate counters.
/// </summary>
/// <param name="value"> UInt64 value to increment. </param>
/// <param name="numberOfDimensions"> Number of dimensions being set. </param>
/// <param name="dimensionValues"> Array of dimension value names. </param>
/// <returns> Success/Fail. </returns>
/// <remarks>
/// The number of dimension values must exactly match the number of dimensions
/// provided when creating this metric.
/// </remarks>
virtual bool Increment(uint64_t value, size_t numberOfDimensions, const char* dimensionValues[]) = 0;
/// <summary>
/// Decrements metric value with variadic dimension arguments.
/// Use mainly to simplify rate counters.
/// </summary>
/// <param name="value"> UInt64 value to decrement. </param>
/// <param name="numberOfDimensions"> Number of dimensions being set. </param>
/// <param name="dimensionValues"> Array of dimension value names. </param>
/// <returns> Success/Fail. </returns>
/// <remarks>
/// The number of dimension values must exactly match the number of dimensions
/// provided when creating this metric.
/// </remarks>
virtual bool Decrement(uint64_t value, size_t numberOfDimensions, const char* dimensionValues[]) = 0;
/// <summary> Explicitly destroys the Metric. </summary>
/// <remarks>
/// Consumers are not required to call this.
/// The MetricProvider owns this class and will automatically perform cleanup on shutdown.
/// </remarks>
virtual void Destroy() = 0;
protected:
///<summary> Prevent calling delete on the interface. Must use Destroy! </summary>
virtual ~Metric() = default;
};
```
### <a name="cpp-metricprovider"></a> Interface MetricProvider
```cpp
/// <summary> Interface for a generic metric provider. </summary>
/// <remarks>
/// Ownership of this metric provider belongs to the shared library which created it. Hence the explicit
/// Destroy method in this class. To simplify memory management across multiple shared libraries, this class
/// can only be created via a factory method provided by the shared library. When it is no longer needed,
/// the caller may call Destroy() which will tell the shared library which created it to dispose of the object.
/// </remarks>
class MetricProvider {
public:
/// <summary>
/// Gets or creates a N-dimensional metric. Metric objects are owned and cached by this class.
/// Up to 64 dimensions may be used.</summary>
/// <param name="section"> Section of the metric.</param>
/// <param name="name"> Name of the metric.</param>
/// <param name="type"> Type of the metric.</param>
/// <param name="dimensions">
/// Number of dimensions requested for this metric.
/// Represents the size of the array passed in for p_dimensionNames.
/// </param>
/// <param name="dimensionNames"> Array of dimension names being requested for this metric.</param>
/// <remarks>
/// The IMetric class returned is owned and cached by this class.
/// Callers are not required to call destroy() on the Metric.
/// </remarks>
virtual Metric* GetMetric(
const char* section,
const char* name,
MetricType type,
size_t dimensions,
const char* dimensionNames[]) = 0;
///<summary> Explicitly destroys the metric provider. </summary>
virtual void Destroy() = 0;
protected:
///<summary> Prevent calling delete on the interface. Must use Destroy! </summary>
virtual ~MetricProvider() = default;
};
```
### <a name="cpp-getmetricprovider"></a> function `MetricProvider& GetMetricProvider()`
```cpp
/// <summary> Exports a getter function for retrieves the configured metric provider. </summary>
NAPA_API MetricProvider& GetMetricProvider();
```
## <a name="js-api"></a> JavaScript API
### <a name="metrictype"></a> enum `MetricType`
```ts
export enum MetricType {
Number = 0,
Rate,
Percentile,
}
```
### <a name="metric"></a> Class `Metric`
Class to manipulate metrics in JavaScript.
### <a name="metric-set"></a> `set(value: number, dimensions?: string[]): void`
Set absolute value on an instance of the metric constrained by dimension values.
Example:
```js
// Create a percentile metric to measure end-to-end latency, with 1 dimension of client-id.
latency = napa.metric.get(
'app1',
'end-to-end-latency',
napa.metric.MetricType.Percentile,
['client-id']);
// Set end-to-end latency of current request to 100, with client-id 'client1'.
latency.set(100, ['client1']);
```
#### <a name="metric-increment"></a> `increment(dimensions?: string[]): void`
Increment the value of an instance of the metric constrained by dimension values.
Example:
```js
// Create a percentile metric to measure end-to-end latency, with 1 dimension of client-id.
latency = napa.metric.get(
'app1',
'qps',
napa.metric.MetricType.Rate,
['client-id']);
// Increment QPS of client-id 'client1'.
latency.increment(['client1']);
```
#### <a name="metric-decrement"></a> `decrement(dimensions?: string[]): void`
Decrement the value of an instance of the metric constrained by dimension values.
### <a name="get"></a> function `get(section: string, name: string, type: MetricType, dimensions: string[] = []): Metric`
Create a metric with an identity consisting of section, name, type and dimensions. If a metric already exists with given parameters, returns existing one.
Example:
```ts
import * as napa from 'napajs';
let metric = napa.metric.get(
'app1',
'counter1',
napa.metric.MetricType.Number,
[]);
metric.increment([]);
```
## <a name="use-custom-providers"></a> Using custom metric providers
Developers can hook up custom metric provider by calling the following before creation of any zones:
```ts
napa.runtime.setPlatformSettings({
"metricProvider": "<custom-metric-provider-module-name>"
}
```
## <a name="develop-custom-providers"></a> Developing custom metric providers
TBD
================================================
FILE: docs/api/module.md
================================================
# Napa.js Module
## Table of Contents
- [Introduction](#intro)
- [Developing modules](#develop-modules)
- [Module: JavaScript vs C++](#js-vs-cpp)
- [Quick reference](#quick-ref)
- [JavaScript module](#ref-js-module)
- [C++ module](#ref-cpp-module)
- [API](#api)
- [JavaScript API](#js-api)
- [C++ API](#cpp-api)
- [Exporting JavaScript class from C++ modules](#export-class)
- [V8 helpers](#v8helpers)
- [Using STL with custom allocators](#stl-with-allocator)
- [Special topics](#topics)
- [Topic #1: Make objects shareable across multiple JavaScript threads](#topic-shareable-objects)
- [Topic #2: Asynchronous functions](#topic-async-functions)
- [Topic #3: Memory management in C++ modules](#topic-memory-management)
## <a name="intro"></a> Introduction
Napa.js follows [Node.js' convention](https://nodejs.org/api/modules.html) to support modules, that means:
1) Both JavaScript modules and C++ modules are supported.
2) Module resolution follows the [same algorithm](https://nodejs.org/api/modules.html#modules_all_together), except instead of searching file extension `.node` for addons, Napa.JS searches `.napa`.
3) Supports NPM, with the [same way](https://docs.npmjs.com/getting-started/creating-node-modules) to create and publish modules.
4) API of creating C++ modules (addons) are similar. Napa.JS introduced macros that the same source code can be compiled to produce both Napa.js addon and Node.js addon.
But there are also differences:
1) C++ module that is designed/implemented for Napa.js can run on Node.JS (need different compile flags to produce '.napa' and '.node'). But not vice versa.
2) Napa.js doesn't support all Node.js API. Node API are supported [incrementally](./node-api.md) on the motivation of adding Node.js built-ins and core modules that are needed for computation heavy tasks. You can access full capabilities of Node exposed via [Node zone](./zone.md#node-zone).
3) Napa.js doesn't provide `uv` functionalities, thus built-ins and core modules have its own implementation. To write async function in addon, methods `DoAsyncWork`/`PostAsyncWork` are introduced to work for both Napa.js and Node.js.
4) Napa.js supports embed mode. C++ modules need separate compilation between Node mode and embed mode.
## <a name="develop-modules"></a> Developing modules
### <a name="js-vs-cpp"></a> Module: JavaScript vs. C++
A quick glance at NPM will reveal that most modules are pure JavaScript. These are only a few reasons that you may want to create a C++ module.
- You want to expose JavaScript API for existing C/C++ functionalities.
- Code includes considerably amount of computation that is performance critical.
- Objects need to be shared across multiple JavaScript threads, marshalling/unmarshalling cost on these objects is not trivial (big payload size, complex structure, etc.), but it's reasonable cheap to expose JavaScript APIs from underlying native objects.
- In embed mode, you want to communicate with host process with native objects.
[This post](https://docs.npmjs.com/getting-started/creating-node-modules) gives a good introduction on creating a JavaScript module. For creating a Napa.JS C++ module, please refer to the [API](#api) section or checkout examples in the [quick reference](#quick-reference) section.
## <a name="quick-ref"></a> Quick reference
### <a name="ref-js-module"></a> JavaScript module
| Description | Transportable | Example code |
| ------------------------------------------------------------ | ------------- | ------------ |
| Standard JavaScript module | | [Blog post](https://www.hacksparrow.com/how-to-write-node-js-modules.html) |
| Share JavaScript object across isolates | X | |
### <a name="ref-cpp-module"></a> C++ module
| Description | ObjectWrap | Transportable | Async function | Example code |
| ------------------------------------------------------------ | ---------- | ------------- | -------------- | ------------ |
| Export JavaScript function only | | | | hello-world [[.md](../../examples/modules/hello-world/README.md) [.cpp](../../examples/modules/hello-world/node/addon.cpp) [test](../../examples/modules/hello-world/test/test.ts)] |
| Export JavaScript object (ObjectWrap) | X | | | plus-number [[.md](../../examples/modules/plus-number/README.md) [.cpp](../../examples/modules/plus-number/node/addon.cpp) [test](../../examples/modules/plus-number/test/module-test/test.ts)] |
| Share C++ object across isolates | X | X | | allocator-wrap [[.h](../../src/module/core-modules/napa/allocator-wrap.h) [.cpp](../../src/module/core-modules/napa/allocator-wrap.cpp)] |
| Export asynchronous JavaScript function | X | | X | async-number [[.md](../../examples/modules/async-number/README.md) [.cpp](../../examples/modules/async-number/node/addon.cpp) [test](../../examples/modules/async-number/test/test.ts)] |
## <a name="api"></a> API
### <a name="js-api"></a> JavaScript
See [API reference](./index.md).
### <a name="cpp-api"></a> C++
#### <a name="export-class"></a> Exporting JavaScript classes from C++ modules
TBD
#### <a name="v8helpers"></a> V8 helpers
TBD
#### <a name="stl-with-allocator"></a> Using STL with custom allocators
TBD
## <a name="topics"></a> Special topics
### <a name="topic-shareable-objects"></a> Topic #1: Make objects shareable across multiple JavaScript threads
TBD
### <a name="topic-async-functions"></a> Topic #2: Asynchronous functions
TBD
### <a name="topic-memory-management"></a> Topic #3: Memory management in C++ modules
TBD
================================================
FILE: docs/api/napa-globals.md
================================================
# Napa.js specific global variables
This file describes Napa.js specific globals, please refer to [this documentation](./node-api.md#globals) for Node.js globals.
## `global.napa`
Shortcut to access `napajs` module in all Napa enabled isolates. This is helpful to avoid extra `require` when using `napajs` module in anonymous function during `broadcast` or `execute`.
Example:
```js
var napa = require('napajs');
var zone = napa.zone.create('zone1');
function test() {
global.napa.log('hi');
}
zone.execute(test);
```
================================================
FILE: docs/api/node-api.md
================================================
# Node.js Compatibility
Napa.js doesn't support full compatibility with node.js and necessary core modules will be added incrementally. Here are the list of what Napa.js currently supports. Please refer to https://nodejs.org/api/all.html for details.
## Assert
Since Napa doesn't support *Buffer* yet, assert is not working on *Buffer*.
* assert(value[, message])
* assert.deepEqual(actual, expected[, message])
* assert.doesNotThrow(block[, error][, message])
* assert.equal(actual, expected[, message])
* assert.fail(actual, expected, message, operator)
* assert.ifError(value)
* assert.notDeepEqual(actual, expected[, message])
* assert.notEqual(actual, expected[, message])
* assert.notStrictEqual(actual, expected[, message])
* assert.ok(value[, message])
* assert.strictEqual(actual, expected[, message])
* assert.throws(block[, error][, message])
## Console
* console.log([data][, ...args])
## Events
* Event: 'newListener'
* Event: 'removeListener'
* EventEmitter.listenerCount(emitter, eventName)
* EventEmitter.defaultMaxListeners
* emitter.addListener(eventName, listener)
* emitter.emit(eventName[, ...args])
* emitter.eventNames()
* emitter.getMaxListeners()
* emitter.listenerCount(eventName)
* emitter.listeners(eventName)
* emitter.on(eventName, listener)
* emitter.once(eventName, listener)
* emitter.prependListener(eventName, listener)
* emitter.prependOnceListener(eventName, listener)
* emitter.removeAllListeners([eventName])
* emitter.removeListener(eventName, listener)
* emitter.setMaxListeners(n)
## File system
* fs.readFileSync(path)
* fs.writeFileSync(file, data)
* fs.mkdirSync(path)
* fs.existsSync(path)
* fs.readdirSync(path)
## Globals
* __dirname
* __filename
* console
* exports
* global
* module
* module.exports
* module.id
* process
* require
## OS
* os.type
## Path
* path.basename(path[, ext])
* path.dirname(path)
* path.extname(path)
* path.format(pathObject)
* path.isAbsolute(path)
* path.join([...paths])
* path.normalize(path)
* path.relative(from, to)
* path.resolve([...paths])
* path.sep
## Process
* process.argv
* process.cwd()
* process.chdir(directory)
* process.env
* process.execPath
* process.exit(code)
* process.hrtime([time])
* process.pid
* process.platform
* process.umask([mask])
## TTY
* tty.isatty(fd)
## Util
* util.debuglog(section)
* util.format(format[, ...args])
* util.inherits(constructor, superConstructor)
* util.inspect(object[, options])
* util._extend(target, source)
================================================
FILE: docs/api/store.md
================================================
# Namespace `store`
## Table of Contents
- [Introduction](#intro)
- [API](#api)
- [`create(id: string): Store`](#create)
- [`get(id: string): Store`](#get)
- [`getOrCreate(id: string): Store`](#getorcreate)
- [`count: number`](#count)
- Interface [`Store`](#store)
- [`store.id: string`](#store-id)
- [`store.set(key: string, value: any): void`](#store-set)
- [`store.get(key: string): any`](#store-get)
- [`store.has(key: string): boolean`](#store-has)
- [`store.size: number`](#store-size)
## <a name="intro"></a> Introduction
Store API is a necessary complement of sharing [transportable](transport.md#transportable-types) objects across JavaScript threads, on top of passing objects via arguments. During [`store.set`](#store-set), values marshalled into JSON and stored in process heap, so all threads can access it, and unmarshalled while users retrieve them via [`store.get`](#store-get).
Though very convenient, it's not recommended to use store to pass values within a transaction or request, since its overhead is more than passing objects by arguments (there are extra locking, etc.). Besides, developers have the obligation to delete the key after usage, while it's automatically managed by reference counting in passing arguments.
## <a name="api"></a> API
Following APIs are exposed to create, get and operate upon stores.
### <a name="create"></a> create(id: string): Store
It creates a store by a string identifier that can be used to get the store later. When all references to the store from all JavaScript VMs are cleared, the store will be destroyed. Thus always keep a reference at global or module scope is usually a good practice using `Store`. Error will be thrown if the id already exists.
Example:
```js
var store = napa.store.create('store1');
```
### <a name="get"></a> get(id: string): Store
It gets a reference of store by a string identifier. `undefined` will be returned if the id doesn't exist.
Example:
```js
var store = napa.store.get('store1');
```
### <a name="getorcreate"></a> getOrCreate(id: string): Store
It gets a reference of store by a string identifier, or creates it if the id doesn't exist. This API is handy when you want to create a store in code that is executed by every worker of a zone, since it doesn't break symmetry.
Example:
```js
var store = napa.store.getOrCreate('store1');
```
### <a name="count"></a> count: number
It returns count of living stores.
### <a name="store"></a> Interface `Store`
Interface that let user to put and get objects across multiple JavaScript VMs.
### <a name="store-id"></a> store.id: string
It gets the string identifier for the store.
### <a name="store-set"></a> store.set(key: string, value: any): void
It puts a [transportable](transport.md#transportable-types) value into store with a string key. If key already exists, new value will override existing value.
Example:
```js
store.set('status', 1);
```
### <a name="store-get"></a> store.get(key: string): any
It gets a [transportable](transportable.md#transportable-types) value from the store by a string key. If key doesn't exist, `undefined` will be returned.
Example:
```js
var value = store.get('status');
assert(value === 1);
```
### <a name="store-has"></a> store.has(key: string): boolean
It tells if a key exists in current store.
Example:
```js
assert(store.has('status'))
```
### <a name="store-size"></a> store.size: number
It tells how many keys are stored in current store.
================================================
FILE: docs/api/sync.md
================================================
# Namespace `sync`
## Table of Contents
- class [`Lock`](#interface-lock)
- [`lock.guardSync(func: (...params: any[]) => any, params?: any[]): any`](#lock-guard-sync-func-any-any)
<!--
// Preserve this interface for async lock.
- [`lock.guard(func: () => Promise<any>): Promise<any>`](#lock-guard-func-promise-any-promise-any)
-->
<!--
- class [`ReadWriteLock`](#class-readwritelock)
- [`rwlock.guardRead(func: () => any): any`](#rwlock-guardread-func-any-any)
- [`rwlock.guardWrite(func: () => any): any`](#rwlock-guardwrite-func-any-any)
-->
## APIs
Namespace `sync` deal with synchronization between threads in Napa. `Lock` <!-- and `ReadWriteLock` are --> is provided for exclusive and shared mutex scenarios.
## <a name="interface-lock"></a> Interface `Lock`
Exclusive Lock, which is [transportable](transport.md#transportable) across JavaScript threads.
Use `napa.sync.createLock()` to create a lock.
```ts
var lock = napa.sync.createLock();
```
### <a name="lock-guard-sync-func-any-any"></a> lock.guardSync(func: (...params: any[]) => any, params?: any[]): any
Run input function synchronously and obtain the lock during its execution, returns what the function returns, or throws error if input function throws. Lock will be released once execution finishes.
```ts
try {
var value = lock.guardSync(() => {
// DoSomething may throw.
return DoSomething();
});
console.log(value);
}
catch(error) {
console.log(error);
}
```
An example [Synchronized Loading](./../../examples/tutorial/synchronized-loading) demonstrated how to implement a shared, lazy-loading phone book.
<!--
### <a name="lock-guard-func-promise-any-promise-any"></a> lock.guard(func: () => Promise\<any>): Promise\<any>
// TBD: this is a non-blocking guard function.
// It tries to obtain the lock and run the func.
// It will return regardless of whether it obtained the lock successfully.
-->
<!--
## Class `ReadWriteLock`
Read-write lock, which is [transportable](transport.md#transportable) across JavaScript threads.
// TBD: RWLock APIs may be redesign in future.
Example: Creating a read-write lock with operator `new`.
```ts
let lock = new napa.sync.ReadWriteLock();
```
### rwlock.guardRead(func: () => any): any
Run input function synchronously and obtain the read (shared) lock during its execution, returns what the function returns, or throws error if input function throws. Read lock will be released once execution finishes. Multiple guardRead across threads can enter simultaneously while no pending guardWrite.
```ts
try {
let value = lock.guardRead(() => {
// DoRead may throw.
return DoRead();
});
console.log(value);
}
catch(error) {
console.log(error);
}
```
### rwlock.guardWrite(func: () => any): any
Run input function synchronously and obtain the write (exclusive) lock during its execution, returns what the function returns, or throws error if input function throws. Write lock will be released once execution finishes. Multiple guardWrite across threads cannot entered simultaneously, and will always wait if there is any pending guardRead.
```ts
try {
let value = lock.guardWrite(() => {
// DoWrite may throw.
return DoWrite();
});
console.log(value);
}
catch(error) {
console.log(error);
}
-->
================================================
FILE: docs/api/transport.md
================================================
# Namespace `transport`
## Table of Contents
- [Introduction](#intro)
- [Transportable types](#transportable-types)
- [Constructor ID](#constructor-id)
- [Transport context](#transport-context)
- [Transporting functions](#transporting-functions)
- [Transporting JavaScript built-in objects](#transporting-built-in)
- API
- [`isTransportable(jsValue: any): boolean`](#istransportable)
- [`register(transportableClass: new(...args: any[]) => any): void`](#register)
- [`marshall(jsValue: any, context: TransportContext): string`](#marshall)
- [`unmarshall(json: string, context: TransporteContext): any`](#unmarshall)
- class [`TransportContext`](#transportcontext)
- [`context.saveShared(object: memory.Shareable): void`](transportcontext-saveshared)
- [`context.loadShared(handle: memory.Handle): memory.Shareable`](transportcontext-loadshared)
- [`context.sharedCount: number`](transportcontext-sharedcount)
- interface [`Transportable`](#transportable)
- [`transportable.cid: string`](#transportable-cid)
- [`transportable.marshall(context: TransportContext): object`](#transportable-marshall)
- [`transportable.unmarshall(payload: object, context: TransportContext): void`](#transportable-unmarshall)
- abstract class [`TransportableObject`](#transportableobject)
- [`transportableObject.cid: string`](#transportableobject-cid)
- [`transportableObject.marshall(context: TransportContext): object`](#transportableobject-marshall)
- [`transportableObject.unmarshall(payload: object, context: TransportContext): void`](#transportableobject-unmarshall)
- abstract [`transportableObject.save(payload: object, context: TransportContext): void`](#transportableobject-save)
- abstract [`transportableObject.load(payload: object, context: TransportContext): void`](#transportableobject-load)
- decorator [`cid`](#decorator-cid)
## <a name="intro"></a> Introduction
Existing JavaScript engines are not designed for running JavaScript across multiple VMs, which means every VM manages their own heap. Passing values from one VM to another has to be marshalled/unmarshalled. The size of payload and complexity of object will greatly impact communication efficiency. In Napa, we try to work out a design pattern for efficient object sharing, based on the fact that all JavaScript VMs (exposed as workers) reside in the same process, and native objects can be wrapped and exposed as JavaScripts objects.
Following concepts are introduced to implement this pattern:
### <a name="transportable-types"></a> Transportable types
Transportable types are JavaScript types that can be passed or shared transparently across Napa workers. They are used as value types for passing arguments in [`zone.broadcast`](zone.md#broadcast-function) / [`zone.execute`](zone.md#execute-anonymous-function), and sharing objects in key/value pairs via [`store.set`](store.md#store-set) / [`store.get`](store.md#store-get).
Transportable types are:
- JavaScript primitive types: undefined, null, boolean, number, string
- Object (TypeScript class) that implement [`Transportable`](#transportable) interface
- Function without referencing closures.
- <a name="built-in-whitelist"></a> JavaScript standard built-in objects in this whitelist.
* ArrayBuffer
* Float32Array
* Float64Array
* Int16Array
* Int32Array
* Int8Array
* SharedArrayBuffer
* Uint16Array
* Uint32Array
* Uint8Array
- Array or plain JavaScript object that is composite pattern of above.
### <a name="constructor-id"></a> Constructor ID (cid)
For user classes that implement the [`Transportable`](#transportable) interface, Napa uses Constructor ID (`cid`) to lookup constructors for creating a right object from a string payload. `cid` is marshalled as a part of the payload. During unmarshalling, the transport layer will extract the `cid`, create an object instance using the constructor associated with it, and then call unmarshall on the object.
It's the class developer's responsibility to choose the right `cid` for your class. To avoid conflict, we suggest to use the combination of module.id and class name as `cid`. Developer can use class decorator [`cid`](#decorator-cid) to register a user Transportable class automatically, when using TypeScript with decorator feature enabled. Or call [`transport.register`](#register) manually during module initialization.
### <a name="transport-context"></a> Transport context
There are states that cannot be saved or loaded in serialized form (like std::shared_ptr), or it's very inefficient to serialize (like JavaScript function). Transport context is introduced to help in these scenarios. TransportContext objects can be passed from one JavaScript VM to another, or stored in the native world, so lifecycle of shared native objects extended by using TransportContext. An example of the `Transportable` implementation using TransportContext is [`ShareableWrap`](./../../inc/napa/module/shareable-wrap.h).
### <a name="transporting-functions"></a> Transporting functions
JavaScript function is a special transportable type, through marshalling its definition into a [store](./store.md#intro), and generate a new function from its definition on target thread.
Highlights on transporting functions are:
- For the same function, marshall/unmarshall is an one-time cost on each JavaScript thread. Once a function is transported for the first time, later transportation of the same function to previous JavaScript thread can be regarded as free.
- Closure cannot be transported, but you won't get an error when transporting a function. Instead, you will get runtime error complaining a variable (from closure) is undefined when you can the function later.
- `__dirname` / `__filename` can be accessed in transported function, which is determined by `origin` property of the function. By default, `origin` property is set to the current working directory.
### <a name="transporting-built-in"></a> Transporting JavaScript built-in objects
JavaScript standard built-in objects in [the whitelist](#built-in-whitelist) can be transported among napa workers transparently. JavaScript Objects with properties in these types are also able to be transported. Please refer to [unit tests](./../../test/transport-test.ts) for detail.
An example [Parallel Quick Sort](./../../examples/tutorial/parallel-quick-sort) demonstrated transporting TypedArray (created from SharedArrayBuffer) among multiple Napa workers for efficient data sharing.
## <a name="api"></a> API
### <a name="istransportable"></a> isTransportable(jsValue: any): boolean
It tells whether a JavaScript value is transportable or not.
```ts
// JS primitives
assert(transport.isTransportable(undefined));
assert(transport.isTransportable(null));
assert(transport.isTransportable(1));
assert(transport.isTransportable('string'));
assert(transport.isTransportable(true));
// Transportable addon
assert(transport.isTransportable(napa.memory.crtAllocator));
// Composite of transportable types.
assert(transport.isTransportable([
1,
"string",
{ a: napa.memory.crtAllocator }
]));
class B {
field1: number;
field2: string;
}
// Not transportable JS class. (not registered with @cid).
assert(!transport.isTransportable(new B()));
```
### <a name="register"></a> register(transportableClass: new(...args: any[]) => any): void
Register a `Transportable` class before the transport layer can marshall/unmarshall its instances.
User can also use class decorator [`@cid`](#cid-decorator) for class registration.
Example:
```ts
class A extends transport.AutoTransportable {
field1: string,
method1(): string {
return this.field1;
}
}
// Explicitly register class A in transport.
transport.register(A);
```
### <a name="marshall"></a> marshall(jsValue: any, context: TransportContext): string
Marshall a [transportable](#transportable-types) JavaScript value into a JSON payload with a [`TransportContext`](#transport-context).An Error will be thrown if the value is not transportable.
Example:
```js
var context = transport.createTransportContext();
var jsonPayload = transport.marshall(
[1, 'string', napa.memory.crtAllocator],
context);
console.log(jsonPayload);
```
### <a name="unmarshall"></a> unmarshall(json: string, context: TransportContext): any
Unmarshall a [transportable](#transportable-types) JavaScript value from a JSON payload with a [`TransportContext`](#transport-context).An Error will be thrown if `cid` property is found and not registered with the transport layer.
Example:
```js
var value = transport.unmarshall(jsonPayload, context);
```
## <a name="transportcontext"></a> Class `TransportContext`
Class for [Transport Context](#transport-context), that stores shared pointers and functions during marshall/unmarshall.
### <a name="transportcontext-saveshared"></a> context.saveShared(object: memory.Shareable): void
Save a shareable object in context.
### <a name="transportcontext-loadshared"></a> context.loadShared(handle: memory.Handle): memory.Shareable
Load a shareable object from handle.
### <a name="transportcontext-sharedcount"></a> context.sharedCount: number
Count of shareable objects saved in the current context.
## <a name="transportable"></a> Interface `Transportable`
Interface for the Transportable object.
### <a name="transportable-cid"></a> transportable.cid: string
Get accessor for [Constructor ID](#constructor-id). It is used to lookup constructor for the payload of the current class.
### <a name="transportable-marshall"></a> transportable.marshall(context: TransportContext): object
Marshall transforms this object into a plain JavaScript object with the help of [TransportContext](#transport-context).
### <a name="transportable.unmarshall"></a> transportable.unmarshall(payload: object, context: TransportContext): void
Unmarshall transforms marshalled payload into current object.
## <a name="transportableobject"></a> Abstract class `TransportableObject`
TBD
### <a name="decorator-cid"></a> Decorator `cid`
TBD
================================================
FILE: docs/api/zone.md
================================================
# Namespace `zone`
## Table of Contents
- [Introduction](#intro)
- [Multiple workers vs Multiple zones](#worker-vs-zone)
- [Zone types](#zone-types)
- [Zone operations](#zone-operations)
- [API](#api)
- [`create(id: string, settings: ZoneSettings = DEFAULT_SETTINGS): Zone`](#create)
- [`get(id: string): Zone`](#get)
- [`current: Zone`](#current)
- [`node: Zone`](#node-zone)
- Interface [`ZoneSettings`](#zone-settings)
- [`settings.workers: number`](#zone-settings-workers)
- Object [`DEFAULT_SETTINGS: ZoneSettings`](#default-settings)
- Interface [`Zone`](#zone)
- [`zone.id: string`](#zone-id)
- [`zone.broadcast(code: string): Promise<void>`](#broadcast-code)
- [`zone.broadcast(function: (...args: any[]) => void, args?: any[]): Promise<void>`](#broadcast-function)
- [`zone.execute(moduleName: string, functionName: string, args?: any[], options?: CallOptions): Promise<Result>`](#execute-by-name)
- [`zone.execute(function: (...args[]) => any, args?: any[], options?: CallOptions): Promise<Result>`](#execute-anonymous-function)
- Interface [`CallOptions`](#call-options)
- [`options.timeout: number`](#call-options-timeout)
- Interface [`Result`](#result)
- [`result.value: any`](#result-value)
- [`result.payload: string`](#result-payload)
- [`result.transportContext: transport.TransportContext`](#result-transportcontext)
## <a name="intro"></a> Introduction
Zone is a key concept of napajs that exposes multi-thread capabilities in JavaScript world, which is a logical group of symmetric workers for specific tasks.
Please note that it's not the same `zone` concept of a context object for async calls in [Dart](https://www.dartlang.org/articles/libraries/zones), or [Angular](https://github.com/angular/zone.js), or a proposal in [TC39](https://github.com/domenic/zones).
### <a name="worker-vs-zone"></a> Multiple workers vs. Multiple zones
Zone consists of one or multiple JavaScript threads, we name each thread `worker`. Workers within a zone are symmetric, which means code executed on any worker from the zone should return the same result, and the internal state of every worker should be the same from a long-running point of view.
Multiple zones can co-exist in the same process, with each loading different code, bearing different states or applying different policies, like heap size, etc. The purpose of having multiple zone is to allow multiple roles for complex work, each role loads the minimum resources for its own usage.
### <a name="zone-types"></a> Zone types
There are two types of zone:
- **Napa zone** - zone consists of Napa.js managed JavaScript workers (V8 isolates). Can be multiple, each may contain multiple workers. Workers in Napa zone support partial Node.JS APIs.
- **Node zone** - a 'virtual' zone which exposes Node.js eventloop, has access to full Node.js capabilities.
### <a name="zone-operations"><a> Zone operations
There are two operations, designed to reinforce the symmetry of workers within a zone:
1) **Broadcast** - run code that changes worker state on all workers, returning a promise for the pending operation. Through the promise, we can only know if the operation succeeded or failed. Usually we use `broadcast` to bootstrap the application, pre-cache objects, or change application settings. Function `broadcastSync` is also offered as a synchronized version of broadcast operations.
2) **Execute** - run code that doesn't change worker state on an arbitrary worker, returning a promise of getting the result. Execute is designed for doing the real work.
Zone operations are on a basis of first-come-first-serve, while `broadcast` takes higher priority over `execute`.
## <a name="api"></a>API
### <a name="create"></a> create(id: string, settings: ZoneSettings): Zone
It creates a Napa zone with a string id. If a zone with the id is already created, an error will be thrown. [`ZoneSettings`](#zone-settings) can be specified for creating zones.
Example 1: Create a zone with id 'zone1', using default ZoneSettings.
```js
var napa = require('napajs');
var zone1 = napa.zone.create('zone1');
```
Example 2: Create a zone with id 'zone2', with 1 worker.
```js
var zone2 = napa.zone.create('zone2', {
workers: 1
});
```
### <a name="get"></a> get(id: string): Zone
It gets a reference of zone by an id. Error will be thrown if the zone doesn't exist.
Example:
```js
var zone = napa.zone.get('zone1');
```
### <a name="current"></a>current: Zone
It returns a reference of the zone of the currently running isolate. If it's under node, it returns the [node zone](#node-zone).
Example: Get current zone.
```js
var zone = napa.zone.current;
```
### <a name="node-zone"></a>node: Zone
It returns a reference to the node zone. It is equivalent to `napa.zone.get('node')`;
Example:
```js
var zone = napa.zone.node;
```
## <a name="zone-settings"></a> Interface `ZoneSettings`
Settings for zones, which will be specified during the creation of zones. If not specified, [DEFAULT_SETTINGS](#default-settings) will be used.
### <a name="zone-settings-workers"></a>settings.workers: number
Number of workers in the zone.
## <a name="default-settings"></a> Object `DEFAULT_SETTINGS`
Default settings for creating zones.
```js
{
workers: 2
}
```
## <a name="zone"></a> Interface `Zone`
Zone is the basic concept to execute JavaScript and apply policies in Napa. You can find its definition in [Introduction](#intro). Through the Zone API, developers can broadcast JavaScript code on all workers, or execute a function on one of them. When you program against a zone, it is the best practice to ensure all workers within a zone are symmetrical to each other, that is, you should not assume a worker may maintain its own states.
The two major sets of APIs are [`broadcast`](#broadcast-code) and [`execute`](#execute-by-name), which are asynchronous operations with a few variations on their inputs.
### <a name="zone-id"></a> zone.id: string
It gets the id of the zone.
### <a name="broadcast-code"></a> zone.broadcast(code: string): Promise\<void\>
It asynchronously broadcasts a snippet of JavaScript code in a string to all workers, which returns a Promise of void. If any of the workers failed to execute the code, the promise will be rejected with an error message.
Example:
```js
var napa = require('napajs');
var zone = napa.zone.get('zone1');
zone.broadcast('var state = 0;')
.then(() => {
console.log('broadcast succeeded.');
})
.catch((error) => {
console.log('broadcast failed.')
});
```
### <a name="broadcast-code-sync"></a> zone.broadcastSync(code: string): void
It synchronously broadcasts a snippet of JavaScript code in a string to all workers. If any of the workers failed to execute the code, an exception will be thrown with an error message.
Remarks:
- It's not allowed to call `broadcastSync` on current zone. It will cause a deadlock
Example:
```js
var napa = require('napajs');
var zone = napa.zone.get('zone1');
try {
zone.broadcastSync('var state = 0;');
console.log('broadcast succeeded.');
} catch (error) {
console.log('broadcast failed.')
}
```
### <a name="broadcast-function"></a> zone.broadcast(function: (...args: any[]) => void | Promise\<void\>, args?: any[]): Promise\<void\>
It asynchronously broadcasts an anonymous function with its arguments to all workers, which returns a Promise of void. If any of the workers failed to execute the code, the promise will be rejected with an error message.
Remarks:
- If the function returns a Promise object, its state will be adopted to `broadcast`'s return value
- The function object cannot access variables from closure
- Unless the function object has an `origin` property, it will use the current file as `origin`, which will be used to set `__filename` and `__dirname`. (See [transporting functions](./transport.md#transporting-functions))
- Transport context is not available in broadcast. All types that depend on [TransportContext](./transport.md#transport-context) (eg. [ShareableWrap](https://github.com/Microsoft/napajs/blob/master/inc/napa/module/shareable-wrap.h), [Transportable](./transport.md#-interface-transportable)) cannot be passed in arguments list.
Example:
```js
zone.broadcast((state) => {
require('some-module').setModuleState(state)
}, [{field1: 1}])
.then(() => {
console.log('broadcast succeeded.');
})
.catch((error) => {
console.log('broadcast failed:', error)
});
```
### <a name="broadcast-function-sync"></a> zone.broadcastSync(function: (...args: any[]) => void | Promise\<void\>, args?: any[]): void
It synchronously broadcasts an anonymous function with its arguments to all workers. If any of the workers failed to execute the code, an exception will be thrown with an error message.
Remarks:
- It's not allowed to call `broadcastSync` on current zone. It will cause a deadlock
- If the function returns a Promise object, its state will be adopted. Function `broadcastSync` will not return until that Promise resolved or rejected.
- The function object cannot access variables from closure
- Unless the function object has an `origin` property, it will use the current file as `origin`, which will be used to set `__filename` and `__dirname`. (See [transporting functions](./transport.md#transporting-functions))
- Transport context is not available in broadcast. All types that depend on [TransportContext](./transport.md#transport-context) (eg. [ShareableWrap](https://github.com/Microsoft/napajs/blob/master/inc/napa/module/shareable-wrap.h), [Transportable](./transport.md#-interface-transportable)) cannot be passed in arguments list.
Example:
```js
try {
zone.broadcastSync((state) => {
require('some-module').setModuleState(state)
}, [{field1: 1}]);
console.log('broadcast succeeded.');
} catch (error) {
console.log('broadcast failed:', error)
}
```
### <a name="execute-by-name"></a> zone.execute(moduleName: string, functionName: string, args?: any[], options?: CallOptions): Promise\<any\>
Execute a function asynchronously on an arbitrary worker via module name and function name. Arguments can be of any JavaScript type that is [transportable](transport.md#transportable-types). It returns a Promise of [`Result`](#result). If an error happens, either bad code, user exception, or timeout is reached, the promise will be rejected.
Example: Execute function `bar` in module `foo`, with arguments [1, 'hello', { field1: 1 }]. 300ms timeout is applied.
```js
zone.execute(
'foo',
'bar',
[1, "hello", {field1: 1}],
{ timeout: 300 })
.then((result) => {
console.log('execute succeeded:', result.value);
})
.catch((error) => {
console.log('execute failed:', error);
});
```
### <a name="execute-anonymous-function"></a> zone.execute(function: (...args: any[]) => any, args?: any[], options?: CallOptions): Promise\<any\>
Execute a function object asynchronously on an arbitrary worker. Arguments can be of any JavaScript type that is [transportable](transport.md#transportable-types). It returns a Promise of [`Result`](#result). If an error happens, either bad code, user exception, or timeout is reached, promise will be rejected.
Remarks:
- If the function returns a Promise object, it will be adopted
- The function object cannot access variables from closure
- Unless the function object has an `origin` property, it will use the current file as `origin`, which will be used to set `__filename` and `__dirname`. (See [transporting functions](./transport.md#transporting-functions))
Example:
```js
zone.execute((a: number, b: string, c: object) => {
return a + b + JSON.stringify(c);
}, [1, "hello", {field1: 1}])
.then((result) => {
console.log('execute succeeded:', result.value);
})
.catch((error) => {
console.log('execute failed:', error);
});
```
Output:
```
execute succeeded: 1hello{"field1":1}
```
Another example demonstrates accessing `__filename` when executing an anonymous function:
```js
// File: /usr/file1.js
zone.execute(() => { console.log(__filename);});
```
Output:
```
/usr/file1.js
```
## <a name="call-options"></a> Interface `CallOptions`
Interface for options to call functions in `zone.execute`.
### <a name="call-options-timeout"></a> options.timeout: number
Timeout in milliseconds. Default value 0 indicates no timeout.
## <a name="result"></a> Interface `Result`
Interface to access the return value of [`execute`](#execute-by-name).
### <a name="result-value"></a>result.value: any
JavaScript value returned from the function which is invoked from zone.execute/executeSync. Napa marshalls/unmarshalls [transportable values](transport.md#transportable-types) between different workers (V8 isolates). Unmarshalling will happen when the first `result.value` is queried.
Example:
```js
var value = result.value;
```
### <a name="result-payload"></a> result.payload: string
Marshalled payload (in JSON) from the returned value. This field is for users that want to pass results through to its caller, where the unmarshalled value is not required.
Example:
```js
var payload = result.payload;
```
### <a name="result-transportcontext"></a> result.transportContext: transport.TransportContext
[TransportContext](transport.md#transport-context) that is required to unmarshall [`result.payload`](#result-payload) into [`result.value`](#result-value).
Example:
```js
var napa = require('napajs');
var zone = napa.zone.create('zone1');
zone.execute(() => { return 0; }, [])
.then((result) => {
// Manually marshall.
var transportContext = result.transportContext;
var value = napa.transport.unmarshall(result.payload, result.transportContext);
// result.value and manual unmarshall from payload are the same.
assert.equal(value, result.value);
});
```
================================================
FILE: docs/design/transport-js-builtins.md
================================================
# Transport JavaScript standard built-in objects
## Incentives
The abstraction of 'Transportable' lies in the center of Napa.js to efficiently share objects between JavaScript VMs (Napa workers). Except JavaScript primitive types, an object needs to implement 'Transportable' interface to make it transportable. It means [JavaScript standard built-in objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) are not transportable unless wrappers or equivalent implementations for them are implemented by extending 'Transportable' interface. The development cost for these objects is not trivial, and new abstraction layer (wrappers or equivalent implementations) will create barriers for users to learn and adopt these new things. Moreover, developers also need to deal with the interaction between JavaScript standards objects and those wrappers or equivalent implementations.
The incentive of this design is to provide a solution to make JavaScript standard built-in objects transportable with requirements listed in the Goals section.
At the first stage, we will focus on an efficient solution to share data between Napa workers. Basically, it is about making *SharedArrayBuffer / TypedArray / DataView* transportable.
## Goals
Make Javascript standard built-in objects transportable with
- An efficient way to share structured data, like *SharedArrayBuffer*, among Napa workers
- Consistent APIs with ECMA standards
- No new abstraction layers for the simplest usage
- The least new concepts for advanced usage
- A scalable solution to make all JavaScript standard built-in objects transportable, avoiding to make them transportable one by one.
## Example
The below example shows how *SharedArrayBuffer* object is transported across multiple Napa workers. It will print the TypedArray 'ta' created from a *SharedArrayBuffer*, with all its elements set to 100 from different Napa workers.
```js
var napa = require("napajs");
var zone = napa.zone.create('zone', { workers: 4 });
function foo(sab, i) {
var ta = new Uint8Array(sab);
ta[i] = 100;
return i;
}
function run() {
var promises = [];
var sab = new SharedArrayBuffer(4);
for (var i = 0; i < 4; i++) {
promises[i] = zone.execute(foo, [sab, i]);
}
return Promise.all(promises).then(values => {
var ta = new Uint8Array(sab);
console.log(ta);
});
}
run();
```
## Solution
Here we just give a high-level description of the solution. Its API will go to [docs/api/transport](https://github.com/Microsoft/napajs/blob/master/docs/api/transport.md).
- V8 provides its value-serialization mechanism by ValueSerializer and ValueDeserializer, which is compatible with the HTML structured clone algorithm. It is a horizontal solution to serialize / deserialize JavaScript objects. ValueSerializer::Delegate and ValueDeserializer::Delegate are their inner class. They work as base classes from which developers can deprive to customize some special handling of external / shared resources, like memory used by a SharedArrayBuffer object.
- **napa::v8_extensions::ExternalizedContents**
- It holds the externalized contents (memory) of a SharedArrayBuffer instance once it is serialized via *napa::v8_extensions::Utils::SerializeValue()*.
- Only 1 instance of ExternalizedContents will be generated for each SharedArrayBuffer. If a SharedArrayBuffer had been externalized, it will reuse the ExternalizedContents instance created before in *napa::v8_extensions::Utils::SerializeValue()*.
- **napa::v8_extensions::SerializedData**
- It is generated by *napa::v8_extensions::Utils::SerializeValue()*. It holds the serialized data of a JavaScript object, which is required during its deserialization.
- **BuiltInObjectTransporter**
- **napa::v8_extensions::Serializer, derived from v8::ValueSerializer::Delegate**
- **napa::v8_extensions::Deserializer, derived from v8::ValueDeserializer::Delegate**
- **static std::shared_ptr\<SerializedData> v8_extensions::Utils::SerializeValue(Isolate\* isolate, Local\<Value> value);**
- Generate the *SerializedData* instance given an input value.
- If any *SharedArrayBuffer* instances exist in the input value, their *ExternalizedContents* instances will be generated and attached to the *ShareArrayBuffer* instances respectively.
- **static MaybeLocal\<Value> v8_extensions::Utils::DeserializeValue(Isolate\* isolate, std::shared_ptr\<SerializedData> data);**
- Restore a JavaScript value from its SerializedData instance generated by *v8_extensions::Utils::SerializeValue()* before.
- Currently, Napa relies on Transportable API and a registered constructor to make an object transportable. In [marshallTransform](https://github.com/Microsoft/napajs/blob/master/lib/transport/transport.ts), when a JavaScript object is detected to have a registered constructor, it will go with Napa way to marshall this object with the help of a **TransportContext** object, otherwise a non-transportable error is thrown.
- Instead of throwing an error when no registered constructor is detected, the **BuiltInObjectTransporter** can help handle this object. We can use a whitelist of object types to restrict this solution to those verified types at first.
```js
export function marshallTransform(jsValue: any, context: transportable.TransportContext): any {
if (jsValue != null && typeof jsValue === 'object' && !Array.isArray(jsValue)) {
let constructorName = Object.getPrototypeOf(jsValue).constructor.name;
if (constructorName !== 'Object') {
if (typeof jsValue['cid'] === 'function') {
return <transportable.Transportable>(jsValue).marshall(context);
} else if (_builtInTypeWhitelist.has(constructorName)) {
let serializedData = builtinObjectTransporter.serializeValue(jsValue);
if (serializedData) {
return { _serialized : serializedData };
} else {
throw new Error(`Failed to serialize object with type of \"${constructorName}\".`);
}
} else {
throw new Error(`Object type \"${constructorName}\" is not transportable.`);
}
}
}
return jsValue;
}
```
- The reverse process will be invoked in [unmarshallTransform](https://github.com/Microsoft/napajs/edit/master/lib/transport/transport.ts) if the payload is detected to have '_serialized' property.
```js
function unmarshallTransform(payload: any, context: transportable.TransportContext): any {
if (payload != null && payload._cid !== undefined) {
let cid = payload._cid;
if (cid === 'function') {
return functionTransporter.load(payload.hash);
}
let subClass = _registry.get(cid);
if (subClass == null) {
throw new Error(`Unrecognized Constructor ID (cid) "${cid}". Please ensure @cid is applied on the class or transport.register is called on the class.`);
}
let object = new subClass();
object.unmarshall(payload, context);
return object;
} else if (payload.hasOwnProperty('_serialized')) {
return builtinObjectTransporter.deserializeValue(payload['_serialized']);
}
return payload;
}
```
#### Lifecycle of SharedArrayBuffer (SAB)
- When a SAB participates transportation among Napa workers, its life cycle will be extended till the last reference this SAB. The reference of a SAB could be:
- SAB object in its original isolate.
- Received SAB transported from another Napa workers, including node zone of Napa.
- TypedArray or DataView created from the original SAB or a received SAB.
- The life cycle extension during transportation is achieved through the *ExternalizedContents* *SharedPtrWrap* of the SAB.
- When a SAB is transported for the first time, it will be externalized and its ExternalizedContents will be stored in its *SerializedData*. At the same time, the *SharedPtrWrap* of the *ExternalizedContents* will be set to the '_externalized' property of the original SAB.
- When a SAB is transported for the second time or later, it will skip externalization and find its *ExternalizedContents* from its '_externalized' property, and store it to its *SerializedData*.
- When a Napa worker tries to restore a transported SAB, it will find the pre-stored *ExternalizedContents*, and create a *SharedPtrWrap* for it, then set it to the to-be-restored SAB.
- The life cycle of the *SharedArrayBuffer* is extended by the *SharedPtrWrap* of its *ExternalizedContents*.
## Constraints
The above solution is based on the serialization / deserialization mechanism of V8. It may have the following constraints.
- Not all [JavaScripts standard built-in objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) are supported by Node (as a dependency of Napa in node mode) or V8 of a given version. We only provide transporting solution for those mature object types.
- Presently, Node does not explicitly support multiple V8 isolates. There may be inconsistencies in transporting objects between Node zones and Napa zones. Extra effort might be required to make it consistent.
================================================
FILE: examples/modules/README.md
================================================
## Napa module source tree
The source codes can be organized as the structure below.
```
+-- napa-module-example
+-- inc
| +-- example.h
+-- lib
| +-- example.ts
| +-- tsconfig.json
+-- napa
| +-- addon.cpp
| +-- CMakeLists.txt (cmake specific)
| +-- example-wrap.cpp
| +-- example-wrap.h
+-- src
| +-- CMakeLists.txt (cmake specific)
| +-- example.cpp
+-- test
| +-- test.ts
| +-- tsconfig.json
+-- binding.gyp (gyp specific)
+-- CMakeLists.txt (cmake specific)
+-- package.json
+-- README.md
```
## How to build and test ?
For the module examples, node-gyp or cmake-js build solution is provided for your reference.
Please make sure [node-gyp](https://github.com/nodejs/node-gyp#installation) or [cmake-js](https://github.com/cmake-js/cmake-js#installation) has been set up correctly at your client, then you could follow the steps below to build and test the module examples.
```
1. go to the directory of a module example
2. run "npm install" to build the module
3. run "npm test" to build and run the module test, as well as its unittest if any
```
================================================
FILE: examples/modules/async-number/.gitignore
================================================
bin
build
node_modules
types
# ignore all js files under lib
lib/*.js
# ignore all js files under test
test/*.js
package-lock.json
================================================
FILE: examples/modules/async-number/.npmignore
================================================
bin
build
# Exclude TypeScript source files.
lib/*.ts
lib/tsconfig.json
test/*.ts
test/tsconfig.json
================================================
FILE: examples/modules/async-number/README.md
================================================
# Asynchronous numbering
## APIs
Napa provides two functions to support asynchronous call and they work for both node.js and Napa.
```cpp
void napa::module::PostAsyncWork(v8::Local<v8::Function> jsCallback,
std::function<void*()> asyncWork,
std::function<void(v8::Local<v8::Function>, void*)> asyncCompleteCallback);
```
It fires asynchronous work onto separate thread.
* *jsCallback*: Javascript callback given at Javascript land.
* *asyncWork*: C++ function to run at separate thread asynchronously.
* *asyncCompleteCallback*: C++ callback function, which has isolate instance and *jsCallback* as arguments. It's called at the same isolate with caller's one after *asyncWork* completes.
```cpp
void napa::module::DoAsyncWork(v8::Local<v8::Function> jsCallback,
const std::function<void(std::function<void(void*)>)>& asyncWork,
std::function<void(v8::Local<v8::Function>, void*)> asyncCompleteCallback);
```
If you have a function already supporting async, use this API.
* *jsCallback*: Javascript callback given at Javascript land.
* *asyncWork*: Function to wrap C++ function supporting async, which callback must call Napa completion callback given as argument.
* *asyncCompleteCallback*: C++ callback function, which has isolate instance and *jsCallback* as arguments. It's called at the same isolate with caller's one after *asyncWork* completes.
### Diagram
This diagram shows how asynchronous call is working corresponding to the below example,
```diagram
|-------------------------| |------------------------| |------------------------------------| |-------------------|
(V8 thread)-----| Call *increase()* at JS |-----| Run the next statement |-------------------| Run *asyncCompleteCallback* at C++ |-----| Call *jsCallback* |
|-------------------------| |------------------------| |------------------------------------| |-------------------|
| +
| |
|----------| |
| |
+ |
|------------------| |--------------------------------------------| |
(thread)-----| Run *asyncWork* |-----| Post a task to run *asyncCompleteCallback* |---------|
|------------------| |--------------------------------------------|
```
## C++ module
This example shows how to create async module. It keeps one number and three APIs operating on it as follows,
* *Increase*: It increases a number by a given parameter in separate thread and post a completion to run Javascript callback at the next execution loop.
* *IncreaseSync*: It increases a number by a given parameter in the same thread and post a completion to run Javascript callback at the next execution loop.
* *Now*: It returns the current value of a number.
```cpp
#include <napa/module.h>
#include <atomic>
#include <functional>
namespace napa {
namespace demo {
using namespace v8;
namespace {
std::atomic<uint32_t> _now(0);
}
/// <summary> It increases a number by a given parameter asynchronously and runs a callback at the next execution loop. </summary>
void Increase(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
CHECK_ARG(isolate,
args.Length() == 2 && args[0]->IsUint32() && args[1]->IsFunction(),
"It requires unsigned integer and callback as arguments");
auto value = args[0]->Uint32Value();
napa::module::PostAsyncWork(Local<Function>::Cast(args[1]),
[value]() {
// This runs in a separate thread.
_now += value;
return reinterpret_cast<void*>(static_cast<uintptr_t>(_now.load()));
},
[](auto jsCallback, void* result) {
// This runs in the same thread as the one Increase() is called in.
auto isolate = Isolate::GetCurrent();
int32_t argc = 1;
Local<Value> argv[] =
{ Integer::NewFromUnsigned(isolate, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(result))) };
jsCallback->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
);
}
/// <summary> It increases a number by a given parameter synchronously and runs a callback at the next execution loop. </summary>
void IncreaseSync(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
CHECK_ARG(isolate,
args.Length() == 2 && args[0]->IsUint32() && args[1]->IsFunction(),
"It requires unsigned integer and callback as arguments");
auto value = args[0]->Uint32Value();
napa::module::DoAsyncWork(Local<Function>::Cast(args[1]),
[value](auto complete) {
// This runs in the same thread.
_now += value;
complete(reinterpret_cast<void*>(static_cast<uintptr_t>(_now.load())));
},
[](auto jsCallback, void* result) {
// This runs in the same thread as the one IncreaseSync() is called in.
auto isolate = Isolate::GetCurrent();
int32_t argc = 1;
Local<Value> argv[] =
{ Integer::NewFromUnsigned(isolate, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(result))) };
jsCallback->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
);
}
/// <summary> It returns the current value of a number. </summary>
void Now(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
args.GetReturnValue().Set(Integer::NewFromUnsigned(isolate, _now));
}
void Init(Local<Object> exports) {
NAPA_SET_METHOD(exports, "increase", Increase);
NAPA_SET_METHOD(exports, "increaseSync", IncreaseSync);
NAPA_SET_METHOD(exports, "now", Now);
}
NAPA_MODULE(addon, Init)
} // namespace demo
} // namespace napa
```
## Typescript
### async-number.ts
```ts
var addon = require('../bin/addon');
export function increase(value: number, callback: (now: number) => void) {
return addon.increase(value, callback);
}
export function increaseSync(value: number, callback: (now: number) => void) {
return addon.increaseSync(value, callback);
}
export function now(): string {
return addon.now();
}
```
### async-number.d.ts
```d.ts
export declare function increase(extra: number, callback: (now: number) => void): any;
export declare function increaseSync(extra: number, callback: (now: number) => void): any;
export declare function now(): string;
```
## Test
```ts
var assert = require('assert');
var asyncNumber = require('async-number');
describe('Test suite for async-number', function() {
it('change number asynchronously on separate thread', function(done) {
let now = asyncNumber.now();
assert.equal(now, 0);
asyncNumber.increase(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert(value == 3 || value == 6);
now = asyncNumber.now();
assert.equal(now, 6);
done();
});
asyncNumber.increaseSync(3, (value) => {} );
});
it('change number synchronously on current thread', function(done) {
let now = asyncNumber.now();
assert.equal(now, 0);
asyncNumber.increaseSync(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert.equal(value, 3);
now = asyncNumber.now();
assert.equal(now, 6);
done();
});
now = asyncNumber.now();
// 'now' should be 3.
assert.equal(now, 3);
asyncNumber.increaseSync(3, (value) => {} );
});
})
```
================================================
FILE: examples/modules/async-number/binding.gyp
================================================
{
"variables": {
"napajs_lib": "<!(node -e \"require('napajs/build').paths.lib\")",
"napajs_inc": "<!(node -e \"require('napajs/build').paths.inc\")"
},
"targets": [
{
"target_name": "addon.node",
"type": "<(library)",
"product_name": "addon",
"product_extension": "node",
"product_dir": "<(PRODUCT_DIR)/../../bin",
"sources": [ "napa/addon.cpp"],
"defines": [
"BUILDING_NODE_EXTENSION"
],
"include_dirs": ["<(napajs_inc)"]
},
{
"target_name": "addon.napa",
"type": "<(library)",
"product_name": "addon",
"product_extension": "napa",
"product_dir": "<(PRODUCT_DIR)/../../bin",
"sources": [ "napa/addon.cpp" ],
"defines": [
"BUILDING_NAPA_EXTENSION"
],
"include_dirs": ["<(napajs_inc)"],
"link_settings": {
"libraries": ["<(napajs_lib)"]
}
}
]
}
================================================
FILE: examples/modules/async-number/lib/async-number.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let addon = require('../bin/addon');
export function increase(value: number, callback: (now: number) => void) {
return addon.increase(value, callback);
}
export function increaseSync(value: number, callback: (now: number) => void) {
return addon.increaseSync(value, callback);
}
export function now(): string {
return addon.now();
}
================================================
FILE: examples/modules/async-number/lib/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": true,
"sourceMap": false,
"lib": ["es2015"],
"declarationDir": "../types"
}
}
================================================
FILE: examples/modules/async-number/napa/addon.cpp
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include <napa/module.h>
#include <napa/async.h>
#include <atomic>
#include <functional>
namespace napa {
namespace demo {
using namespace v8;
namespace {
std::atomic<uint32_t> _now(0);
}
/// <summary> It increases a number by a given parameter asynchronously and runs a callback at the next execution loop. </summary>
void Increase(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
CHECK_ARG(isolate,
args.Length() == 2 && args[0]->IsUint32() && args[1]->IsFunction(),
"It requires unsigned integer and callback as arguments");
auto value = args[0]->Uint32Value();
napa::zone::PostAsyncWork(Local<Function>::Cast(args[1]),
[value]() {
// This runs in a separate thread.
_now += value;
return reinterpret_cast<void*>(static_cast<uintptr_t>(_now.load()));
},
[](auto jsCallback, void* result) {
// This runs in the same thread as the one Increase() is called in.
auto isolate = Isolate::GetCurrent();
int32_t argc = 1;
Local<Value> argv[] =
{ Integer::NewFromUnsigned(isolate, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(result))) };
jsCallback->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
);
}
/// <summary> It increases a number by a given parameter synchronously and runs a callback at the next execution loop. </summary>
void IncreaseSync(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
CHECK_ARG(isolate,
args.Length() == 2 && args[0]->IsUint32() && args[1]->IsFunction(),
"It requires unsigned integer and callback as arguments");
auto value = args[0]->Uint32Value();
napa::zone::DoAsyncWork(Local<Function>::Cast(args[1]),
[value](auto complete) {
// This runs in the same thread.
_now += value;
complete(reinterpret_cast<void*>(static_cast<uintptr_t>(_now.load())));
},
[](auto jsCallback, void* result) {
// This runs in the same thread as the one IncreaseSync() is called in.
auto isolate = Isolate::GetCurrent();
int32_t argc = 1;
Local<Value> argv[] =
{ Integer::NewFromUnsigned(isolate, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(result))) };
jsCallback->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
);
}
/// <summary> It returns the current value of a number. </summary>
void Now(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
args.GetReturnValue().Set(Integer::NewFromUnsigned(isolate, _now));
}
void Init(Local<Object> exports) {
NAPA_SET_METHOD(exports, "increase", Increase);
NAPA_SET_METHOD(exports, "increaseSync", IncreaseSync);
NAPA_SET_METHOD(exports, "now", Now);
}
NAPA_MODULE(addon, Init)
} // namespace demo
} // namespace napa
================================================
FILE: examples/modules/async-number/package.json
================================================
{
"name": "async-number",
"version": "0.1.0",
"author": "napajs",
"description": "Example of an async napa module.",
"main": "./lib/async-number.js",
"types": "./types/async-number.d.ts",
"gypfile": true,
"license": "MIT",
"devDependencies": {
"mocha": ">= 3.4.2",
"typescript": ">= 2.2.1",
"@types/node": ">= 7.0.8",
"@types/mocha": ">= 2.2.0",
"markdown-table": "1.1.0"
},
"dependencies": {
"napajs": ">= 0.1.2"
},
"scripts": {
"install": "node-gyp configure && node-gyp build",
"prepare": "tsc -p lib",
"pretest": "tsc -p test",
"test": "mocha test --recursive"
}
}
================================================
FILE: examples/modules/async-number/test/test.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let assert = require('assert');
let asyncNumber = require('..');
let napa = require('napajs');
let zone = napa.zone.create('zone');
describe('Test suite for async-number', function() {
this.timeout(0);
it('change number asynchronously on separate thread', () => {
let now = asyncNumber.now();
assert.equal(now, 0);
asyncNumber.increase(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert(value == 3 || value == 6);
now = asyncNumber.now();
assert.equal(now, 6);
});
asyncNumber.increaseSync(3, (value: number) => {} );
});
it('change number synchronously on current thread', () => {
let now = asyncNumber.now();
assert.equal(now, 6);
asyncNumber.increaseSync(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert.equal(value, 9);
now = asyncNumber.now();
assert.equal(now, 12);
});
now = asyncNumber.now();
// 'now' should be 9.
assert.equal(now, 9);
asyncNumber.increaseSync(3, (value: number) => {} );
});
it('change number asynchronously on separate thread in napa zone', () => {
return zone.execute(() => {
let assert = require('assert');
let asyncNumber = require('..');
let now = asyncNumber.now();
assert.equal(now, 0);
asyncNumber.increase(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert(value == 3 || value == 6);
now = asyncNumber.now();
assert.equal(now, 6);
});
asyncNumber.increaseSync(3, (value: number) => {} );
});
});
it('change number synchronously on current thread in napa zone', () => {
return zone.execute(() => {
let assert = require('assert');
let asyncNumber = require('..');
let now = asyncNumber.now();
assert.equal(now, 6);
asyncNumber.increaseSync(3, (value: number) => {
// This must be called after the last statement of *it* block is executed.
assert.equal(value, 9);
now = asyncNumber.now();
assert.equal(now, 12);
});
now = asyncNumber.now();
// 'now' should be 9.
assert.equal(now, 9);
asyncNumber.increaseSync(3, (value: number) => {} );
return 1;
});
});
})
================================================
FILE: examples/modules/async-number/test/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": false,
"sourceMap": false,
"lib": ["es2015"]
}
}
================================================
FILE: examples/modules/hello-world/.gitignore
================================================
bin
build
node_modules
types
# ignore all js files under lib
lib/*.js
# ignore all js files under test
test/*.js
package-lock.json
================================================
FILE: examples/modules/hello-world/.npmignore
================================================
bin
build
# Exclude TypeScript source files.
lib/*.ts
lib/tsconfig.json
test/*.ts
test/tsconfig.json
================================================
FILE: examples/modules/hello-world/README.md
================================================
# Hello World
This example shows the simple napa module, which shows the basic difference between node.js module and napa module.
```cpp
#include <napa/module.h>
namespace napa {
namespace demo {
using namespace v8;
void Method(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
}
void Init(Local<Object> exports) {
NAPA_SET_METHOD(exports, "hello", Method);
}
NAPA_MODULE(addon, Init)
} // namespace demo
} // namespace napa
```
## Transition from node.js module
* *napa/module.h* is used instead of *node.h*. Depending on preprocessor definition, *NAPA_MODULE_EXTENSION* or
*BUILDING_NODE_EXTENSION* preprocessor definition, *napa/module.h* includes necessary napa or node header files
accordingly and build system creates either node.js module or napa module.
* *NAPA_SET_METHOD* is equivalent to *NODE_SET_METHOD*. This module will have *hello()* function.
* *NAPA_MODULE* is equivalent to *NODE_MODULE*, which exports an initialization function.
## Typescript
It's recommended that typescript or typescript definition is provided to let the user know the APIs without
the source codes and develop Typescript project easily.
### hello-world.ts
```ts
var addon = require('../bin/addon');
export function hello(): string {
return addon.hello();
}
```
### hello-world.d.ts
```d.ts
export declare function hello(): string;
```
## Mocha test
```js
var assert = require('assert');
var helloWorld = require('hello-world');
describe('Test suite for hello-word', function() {
it('prints the string "world"', function() {
var result = helloWorld.hello();
assert.equal(result, 'world');
});
})
```
================================================
FILE: examples/modules/hello-world/binding.gyp
================================================
{
"variables": {
"napajs_lib": "<!(node -e \"require('napajs/build').paths.lib\")",
"napajs_inc": "<!(node -e \"require('napajs/build').paths.inc\")"
},
"targets": [
{
"target_name": "addon.node",
"type": "<(library)",
"product_name": "addon",
"product_extension": "node",
"product_dir": "<(PRODUCT_DIR)/../../bin",
"sources": [ "napa/addon.cpp"],
"defines": [
"BUILDING_NODE_EXTENSION"
],
"include_dirs": ["<(napajs_inc)"]
},
{
"target_name": "addon.napa",
"type": "<(library)",
"product_name": "addon",
"product_extension": "napa",
"product_dir": "<(PRODUCT_DIR)/../../bin",
"sources": [ "napa/addon.cpp" ],
"defines": [
"BUILDING_NAPA_EXTENSION"
],
"include_dirs": ["<(napajs_inc)"],
"link_settings": {
"libraries": ["<(napajs_lib)"]
}
}
]
}
================================================
FILE: examples/modules/hello-world/lib/hello-world.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let addon = require('../bin/addon');
export function hello(): string {
return addon.hello();
}
================================================
FILE: examples/modules/hello-world/lib/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": true,
"sourceMap": false,
"lib": ["es2015"],
"declarationDir": "../types"
}
}
================================================
FILE: examples/modules/hello-world/napa/addon.cpp
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include <napa/module.h>
namespace napa {
namespace demo {
using namespace v8;
void Method(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
}
void Init(Local<Object> exports) {
NAPA_SET_METHOD(exports, "hello", Method);
}
NAPA_MODULE(addon, Init)
} // namespace demo
} // namespace napa
================================================
FILE: examples/modules/hello-world/package.json
================================================
{
"name": "hello-world",
"version": "0.1.0",
"author": "napajs",
"description": "Example of a simple napa module.",
"main": "./lib/hello-world.js",
"types": "./types/hello-world.d.ts",
"gypfile": true,
"license": "MIT",
"devDependencies": {
"mocha": ">= 3.4.2",
"typescript": ">= 2.2.1",
"@types/node": ">= 7.0.8",
"@types/mocha": ">= 2.2.0",
"markdown-table": "1.1.0"
},
"dependencies": {
"napajs": ">= 0.1.2"
},
"scripts": {
"install": "node-gyp configure && node-gyp build",
"prepare": "tsc -p lib",
"pretest": "tsc -p test",
"test": "mocha test --recursive"
}
}
================================================
FILE: examples/modules/hello-world/test/test.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let assert = require('assert');
let helloWorld = require('..');
let napa = require('napajs');
let zone = napa.zone.create('zone');
describe('Test suite for hello-word', function() {
this.timeout(0);
it('prints the string "world"', function() {
let result: string = helloWorld.hello();
assert.equal(result, 'world');
});
it('prints the string "world" in napa zone', function() {
return zone.execute(() => {
let helloWorld = require('..');
let result: string = helloWorld.hello();
return result;
}).then((result : any) => {
assert.equal(result.value, 'world');
});
});
})
================================================
FILE: examples/modules/hello-world/test/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": false,
"sourceMap": false,
"lib": ["es2015"]
}
}
================================================
FILE: examples/modules/plus-number/.gitignore
================================================
bin
build
node_modules
types
# ignore all js files under lib
lib/*.js
# ignore all js files under test
test/*.js
package-lock.json
================================================
FILE: examples/modules/plus-number/.npmignore
================================================
bin
build
unittest
# Exclude TypeScript source files.
lib/*.ts
lib/tsconfig.json
test/*.ts
test/tsconfig.json
================================================
FILE: examples/modules/plus-number/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project("addon")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
# Require Cxx14 features
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Build plus-number library
add_subdirectory(src)
# Build napa addon
add_subdirectory(napa)
================================================
FILE: examples/modules/plus-number/README.md
================================================
# Plus Number
This example shows the napa module, which wraps C++ objects/classes. Instead of using Javascript *new* operator,
it uses a factory pattern. i.e.
```
var obj = addon.createPlusNumber();
// instead of
// var obj = new addon.PlusNumber();
```
## Wrapped class
*plus-number.h* declares the class with one constructor and one method, *Add()*.
```h
namespace napa {
namespace demo {
/// <summary> Example class to show how to create Napa module using a wrapped C++ class. </summary>
class PlusNumber {
public:
/// <summary> Constructor with initial value. </summary>
explicit PlusNumber(double value = 0.0);
/// <summary> Add the given value and return the result. </summary>
double Add(double value);
private:
double _value;
};
} // namespace demo
} // namespace napa
```
## Wrapper class
*plus-number-wrap.h* declares the wrapper class inherited from *NAPA_OBJECTWRAP* as follows,
```h
#include <napa/module.h>
#include <plus-number.h>
namespace napa {
namespace demo {
/// <summary> Napa example module wrapping PlusNumber class. </summary>
class PlusNumberWrap : public NAPA_OBJECTWRAP {
public:
/// <summary> Register this class into V8. </summary>
static void Init();
/// <summary> Enable to create an instance by createPlusNumber() Javascript API. </summary>
/// <param name="args"> Addend as PlusNumber constructor parameter. </param>
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
/// <summary> Exported class name. </summary>
static const char* _exportName;
/// <summary> Constructor with initial value. </summary>
explicit PlusNumberWrap(double value = 0.0);
/// <summary> Create PlusNumber instance at V8. </summary>
/// <param name="args"> Addend as PlusNumber constructor parameter. </param>
static void NewCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
/// <summary> Add value. </summary>
/// <param name="args"> Addend. </param>
static void Add(const v8::FunctionCallbackInfo<v8::Value>& args);
/// <summary> Declare persistent constructor to create PlusNumber instance. </summary>
/// <remarks> Napa creates persistent constructor at each isolate while node.js creates the static instance. </remarks>
NAPA_DECLARE_PERSISTENT_CONSTRUCTOR();
PlusNumber _plusNumber;
};
} // namespace demo
} // namespace napa
```
*plus-number-wrap.cpp* implements each functions as follows,
```cpp
#include "plus-number-wrap.h"
using namespace napa::demo;
using namespace v8;
const char* PlusNumberWrap::_exportName = "PlusNumberWrap";
// Define persistent constructor.
NAPA_DEFINE_PERSISTENT_CONSTRUCTOR(PlusNumberWrap);
PlusNumberWrap::PlusNumberWrap(double value)
: _plusNumber(value) {
}
void PlusNumberWrap::Init() {
auto isolate = Isolate::GetCurrent();
// Prepare constructor template.
auto functionTemplate = FunctionTemplate::New(isolate, NewCallback);
functionTemplate->SetClassName(String::NewFromUtf8(isolate, _exportName));
functionTemplate->InstanceTemplate()->SetInternalFieldCount(1);
// Set prototype method.
NAPA_SET_PROTOTYPE_METHOD(functionTemplate, "add", Add);
// Set persistent constructor into V8.
NAPA_SET_PERSISTENT_CONSTRUCTOR(_exportName, functionTemplate->GetFunction());
}
void PlusNumberWrap::NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
const int argc = 1;
Local<Value> argv[argc] = { args[0] };
auto constructor = NAPA_GET_PERSISTENT_CONSTRUCTOR(_exportName, PlusNumberWrap);
auto context = isolate->GetCurrentContext();
auto instance = constructor->NewInstance(context, argc, argv).ToLocalChecked();
args.GetReturnValue().Set(instance);
}
void PlusNumberWrap::NewCallback(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
CHECK_ARG(isolate,
args.IsConstructCall(),
"PlusNumberWrap instance must be created by the factory.");
CHECK_ARG(isolate,
args.Length() == 0 || args.Length() == 1,
"Only one or no argument is allowed.");
if (args.Length() == 1) {
CHECK_ARG(isolate,
args[0]->IsNumber(),
"The first argument must be a number.");
}
double value = args[0]->IsUndefined() ? 0.0 : args[0]->NumberValue();
auto wrap = new PlusNumberWrap(value);
wrap->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
void PlusNumberWrap::Add(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
CHECK_ARG(isolate,
args.Length() == 1 && args[0]->IsNumber(),
"Number must be given as argument.");
auto wrap = NAPA_OBJECTWRAP::Unwrap<PlusNumberWrap>(args.Holder());
auto value = wrap->_plusNumber.Add(args[0]->NumberValue());
args.GetReturnValue().Set(Number::New(isolate, value));
}
```
*addon.cpp* implements the addon as below,
```cpp
#include "plus-number-wrap.h"
using namespace napa::demo;
using namespace v8;
void CreatePlusNumber(const FunctionCallbackInfo<Value>& args) {
PlusNumberWrap::NewInstance(args);
}
void InitAll(Local<Object> exports) {
PlusNumberWrap::Init();
NAPA_SET_METHOD(exports, "createPlusNumber", CreatePlusNumber);
}
NAPA_MODULE(addon, InitAll);
```
## Transition from node.js module
* *NAPA_OBJECTWRAP* is equivalent to *node::ObjectWrap*, so object's lifetime works as Javascript object.
* One big difference is how to handle the persistent constructor. While Node.js has only one thread for Javascript and
static constructor instance is fine, Napa should support one constructor instance per V8 isolate. These macros help
constructor instance creation.
* *NAPA_DECLARE_PERSISTENT_CONSTRUCTOR* declares constructor instance.
* *NAPA_DEFINE_PERSISTENT_CONSTRUCTOR* defines constructor instance.
* *NAPA_SET_PERSISTENT_CONSTRUCTOR* makes a local constructor as persistent. Napa stores it into thread local storage
to allow one instance per V8 isolate.
* *NAPA_GET_PERSISTENT_CONSTRUCTOR* return stored constructor instance.
* *NAPA_SET_PROTOTYPE_METHOD* is equivalent to *NODE_SET_PROTOTYPE_METHOD*, which add a prototype method to Javascript
object.
## Typescript
*plus-number.ts* doesn't need to fully implement *PlusNumber.add()* since the signature of *PlusNumber* instance returned by
*addon.createPlusNumber()* is the same.
### plus-number.ts
```ts
var addon = require('../bin/addon');
export declare class PlusNumber {
public add(value: number): number;
}
export function createPlusNumber(value: number = 0): PlusNumber {
return addon.createPlusNumber(value);
}
```
### plus-number.d.ts
```d.ts
export declare class PlusNumber {
add(value: number): number;
}
export declare function createPlusNumber(value?: number): PlusNumber;
```
## NPM Package
NPM package contains the additional binary *plus-number.dll*, which is the shared library for *PlusNumber* class. It's placed
at *bin* directory, so either Node.js or Napa can resolve the shared object path in the same way as it does for a module.
## Mocha test
```js
var assert = require('assert');
var plusNumber = require('plus-number');
describe('Test suite for plus-number', function () {
it('adds a given value', function () {
var po = plusNumber.createPlusNumber(3);
var result = po.add(4);
assert.equal(result, 7);
});
it('fails with constructor call', function () {
var failed = false;
try {
var po = new plusNumber.PlusNumber();
}
catch (error) {
failed = true;
}
assert.equal(failed, true);
});
});
```
================================================
FILE: examples/modules/plus-number/inc/plus-number.h
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#pragma once
#if defined(_WIN32) || defined(__WIN32__)
#ifdef NAPA_EXAMPLE_API
#define NAPA_EXAMPLE_EXPORT __declspec(dllexport)
#else
#define NAPA_EXAMPLE_EXPORT __declspec(dllimport)
#endif
#else
#define NAPA_EXAMPLE_EXPORT
#endif
namespace napa {
namespace demo {
/// <summary> Example class to show how to create Napa module using a wrapped C++ class. </summary>
class NAPA_EXAMPLE_EXPORT PlusNumber {
public:
/// <summary> Constructor with initial value. </summary>
explicit PlusNumber(double value = 0.0);
/// <summary> Add the given value and return the result. </summary>
double Add(double value);
private:
double _value;
};
} // napespace demo
} // namespace napa
================================================
FILE: examples/modules/plus-number/lib/plus-number.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let addon = require('../bin/addon');
export declare class PlusNumber {
public add(value: number): number;
}
export function createPlusNumber(value: number = 0.0): PlusNumber {
return addon.createPlusNumber(value);
}
================================================
FILE: examples/modules/plus-number/lib/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": true,
"sourceMap": false,
"lib": ["es2015"],
"declarationDir": "../types"
}
}
================================================
FILE: examples/modules/plus-number/napa/CMakeLists.txt
================================================
execute_process(COMMAND node -e "require('napajs/build').paths.inc" RESULT_VARIABLE ERR OUTPUT_VARIABLE NAPAJS_INC)
if(ERR)
message(FATAL_ERROR "Failed to resolve napa include directory")
endif(ERR)
execute_process(COMMAND node -e "require('napajs/build').paths.lib" RESULT_VARIABLE ERR OUTPUT_VARIABLE NAPAJS_LIB)
if(ERR)
message(FATAL_ERROR "Failed to resolve napa library path")
endif(ERR)
#######################################################################################
# Build napa addon.
set(NAPA_ADDON_TARGET_NAME "${PROJECT_NAME}.napa")
# The generated library
add_library(${NAPA_ADDON_TARGET_NAME} SHARED "addon.cpp" "plus-number-wrap.cpp")
set_target_properties(${NAPA_ADDON_TARGET_NAME} PROPERTIES PREFIX "" SUFFIX "")
# Include directories
target_include_directories(${NAPA_ADDON_TARGET_NAME} PRIVATE
../inc
${CMAKE_JS_INC}
${NAPAJS_INC})
# Compiler definitions
target_compile_definitions(${NAPA_ADDON_TARGET_NAME} PRIVATE
BUILDING_NAPA_EXTENSION)
# Link libraries
target_link_libraries(${NAPA_ADDON_TARGET_NAME} PRIVATE
plus-number
${CMAKE_JS_LIB}
${NAPAJS_LIB})
#######################################################################################
# Build napa addon for node.
set(NODE_ADDON_TARGET_NAME "${PROJECT_NAME}.node")
# The generated library
add_library(${NODE_ADDON_TARGET_NAME} SHARED "addon.cpp" "plus-number-wrap.cpp")
set_target_properties(${NODE_ADDON_TARGET_NAME} PROPERTIES PREFIX "" SUFFIX "")
# Include directories
target_include_directories(${NODE_ADDON_TARGET_NAME} PRIVATE
../inc
${CMAKE_JS_INC}
${NAPAJS_INC})
# Compiler definitions
target_compile_definitions(${NODE_ADDON_TARGET_NAME} PRIVATE
BUILDING_NODE_EXTENSION)
# Link libraries
target_link_libraries(${NODE_ADDON_TARGET_NAME} PRIVATE
plus-number
${CMAKE_JS_LIB})
================================================
FILE: examples/modules/plus-number/napa/addon.cpp
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include "plus-number-wrap.h"
using namespace napa::demo;
using namespace v8;
void CreatePlusNumber(const FunctionCallbackInfo<Value>& args) {
PlusNumberWrap::NewInstance(args);
}
void InitAll(Local<Object> exports) {
PlusNumberWrap::Init();
NAPA_SET_METHOD(exports, "createPlusNumber", CreatePlusNumber);
}
NAPA_MODULE(addon, InitAll);
================================================
FILE: examples/modules/plus-number/napa/plus-number-wrap.cpp
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include "plus-number-wrap.h"
using namespace napa::demo;
using namespace v8;
const char* PlusNumberWrap::_exportName = "PlusNumberWrap";
// Define persistent constructor.
NAPA_DEFINE_PERSISTENT_CONSTRUCTOR(PlusNumberWrap);
PlusNumberWrap::PlusNumberWrap(double value)
: _plusNumber(value) {
}
void PlusNumberWrap::Init() {
auto isolate = Isolate::GetCurrent();
// Prepare constructor template.
auto functionTemplate = FunctionTemplate::New(isolate, NewCallback);
functionTemplate->SetClassName(String::NewFromUtf8(isolate, _exportName));
functionTemplate->InstanceTemplate()->SetInternalFieldCount(1);
// Set prototype method.
NAPA_SET_PROTOTYPE_METHOD(functionTemplate, "add", Add);
// Set persistent constructor into V8.
NAPA_SET_PERSISTENT_CONSTRUCTOR(_exportName, functionTemplate->GetFunction());
}
void PlusNumberWrap::NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
const int argc = 1;
Local<Value> argv[argc] = { args[0] };
auto constructor = NAPA_GET_PERSISTENT_CONSTRUCTOR(_exportName, PlusNumberWrap);
auto context = isolate->GetCurrentContext();
auto instance = constructor->NewInstance(context, argc, argv).ToLocalChecked();
args.GetReturnValue().Set(instance);
}
void PlusNumberWrap::NewCallback(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
CHECK_ARG(isolate,
args.IsConstructCall(),
"PlusNumberWrap instance must be created by the factory.");
CHECK_ARG(isolate,
args.Length() == 0 || args.Length() == 1,
"Only one or no argument is allowed.");
if (args.Length() == 1) {
CHECK_ARG(isolate,
args[0]->IsNumber(),
"The first argument must be a number.");
}
double value = args[0]->IsUndefined() ? 0.0 : args[0]->NumberValue();
auto wrap = new PlusNumberWrap(value);
wrap->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
void PlusNumberWrap::Add(const FunctionCallbackInfo<Value>& args) {
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
CHECK_ARG(isolate,
args.Length() == 1 && args[0]->IsNumber(),
"Number must be given as argument.");
auto wrap = NAPA_OBJECTWRAP::Unwrap<PlusNumberWrap>(args.Holder());
auto value = wrap->_plusNumber.Add(args[0]->NumberValue());
args.GetReturnValue().Set(Number::New(isolate, value));
}
================================================
FILE: examples/modules/plus-number/napa/plus-number-wrap.h
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#pragma once
#include <napa/module.h>
#include <plus-number.h>
namespace napa {
namespace demo {
/// <summary> Napa example module wrapping PlusNumber class. </summary>
class PlusNumberWrap : public NAPA_OBJECTWRAP {
public:
/// <summary> Register this class into V8. </summary>
static void Init();
/// <summary> Enable to create an instance by createPlusNumber() Javascript API. </summary>
/// <param name="args"> Addend as PlusNumber constructor parameter. </param>
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
/// <summary> Exported class name. </summary>
static const char* _exportName;
/// <summary> Constructor with initial value. </summary>
explicit PlusNumberWrap(double value = 0.0);
/// <summary> Create PlusNumber instance at V8. </summary>
/// <param name="args"> Addend as PlusNumber constructor parameter. </param>
static void NewCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
/// <summary> Add value. </summary>
/// <param name="args"> Addend. </param>
static void Add(const v8::FunctionCallbackInfo<v8::Value>& args);
/// <summary> Declare persistent constructor to create PlusNumber instance. </summary>
/// <remarks> Napa creates persistent constructor at each isolate while node.js creates the static instance. </remarks>
NAPA_DECLARE_PERSISTENT_CONSTRUCTOR();
PlusNumber _plusNumber;
};
} // namespace demo
} // namespace napa
================================================
FILE: examples/modules/plus-number/package.json
================================================
{
"name": "plus-number",
"version": "0.1.0",
"author": "napajs",
"description": "Example of a napa module wrapping a class.",
"main": "./lib/plus-number.js",
"types": "./types/plus-number.d.ts",
"license": "MIT",
"devDependencies": {
"mocha": ">= 3.4.2",
"typescript": ">= 2.2.1",
"@types/node": ">= 7.0.8",
"@types/mocha": ">= 2.2.0",
"markdown-table": "1.1.0"
},
"dependencies": {
"napajs": ">= 0.1.2"
},
"scripts": {
"install": "cmake-js compile",
"pretest": "tsc -p lib && cmake-js compile -d unittest && tsc -p test",
"test": "node unittest/run.js && mocha test --recursive"
}
}
================================================
FILE: examples/modules/plus-number/src/CMakeLists.txt
================================================
# Build plus-number library.
set(TARGET_NAME "plus-number")
# The generated library
add_library(${TARGET_NAME} SHARED "plus-number.cpp")
# Include directories
target_include_directories(${TARGET_NAME} PRIVATE ../inc)
# Compiler definitions
target_compile_definitions(${TARGET_NAME} PRIVATE NAPA_EXAMPLE_API)
================================================
FILE: examples/modules/plus-number/src/plus-number.cpp
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include "plus-number.h"
using namespace napa::demo;
PlusNumber::PlusNumber(double value)
: _value(value) {
}
double PlusNumber::Add(double value) {
return _value + value;
}
================================================
FILE: examples/modules/plus-number/test/test.ts
================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
let assert = require('assert');
let plusNumber = require('..');
let napa = require('napajs');
let zone = napa.zone.create('zone');
describe('Test suite for plus-number', function() {
this.timeout(0);
it('adds a given value', function() {
let po = plusNumber.createPlusNumber(3);
let result: number = po.add(4);
assert.equal(result, 7);
});
it('fails with constructor call', function() {
let failed: boolean = false;
try {
let po = new plusNumber.PlusNumber();
} catch (error) {
failed = true;
}
assert.equal(failed, true);
});
it('adds a given value in napa zone', function() {
return zone.execute(() => {
let plusNumber = require('..');
let po = plusNumber.createPlusNumber(3);
let result: number = po.add(4);
return result;
})
.then((result: any) => {
assert.equal(result.value, 7);
});
});
it('adds a given value in node zone', function() {
return napa.zone.node.execute(() => {
let plusNumber = require('..');
let po = plusNumber.createPlusNumber(3);
let result: number = po.add(4);
return result;
})
.then((result: any) => {
assert.equal(result.value, 7);
});
});
})
================================================
FILE: examples/modules/plus-number/test/tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"declaration": false,
"sourceMap": false,
"lib": ["es2015"]
}
}
================================================
FILE: examples/modules/plus-number/unittest/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project("library-test")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
# Require Cxx14 features
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set symbol visibility to hidden by default.
# Napa shared library shares a few classes with napa-binding.node with different compile definition,
# exposing the same symbols from both shared libraries may cause improper behaviors under gcc.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN)
file(GLOB LIBRARY-FILES "../bin/*plus-number.*")
file(COPY ${LIBRARY-FILES} DESTINATION ${PROJECT_SOURCE_DIR}/bin/)
# Files to compile
file(GLOB SOURCE_FILES "main.cpp")
# The executable name
set(TARGET_NAME "library-test")
# The generated library
add_executable(${TARGET_NAME} ${SOURCE_FILES})
# Include directories
target_include_directories(${TARGET_NAME} PRIVATE ../inc)
find_library(PLUS_NUMBER_LIBRARY NAMES plus-number PATHS ${PROJECT_SOURCE_DIR}/bin)
# Link libraries
target_link_libraries(${TARGET_NAME} PRIVATE ${PLUS_NUMBER_LIBRARY})
================================================
FILE: examples/modules/plus-number/unittest/catch/LICENSE.txt
================================================
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: examples/modules/plus-number/unittest/catch/catch.hpp
================================================
/*
* Catch v1.6.1
* Generated: 2017-01-20 12:33:53.497767
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_HPP_INCLUDED
#ifdef __clang__
# pragma clang system_header
#elif defined __GNUC__
# pragma GCC system_header
#endif
// #included from: internal/catch_suppress_warnings.h
#ifdef __clang__
# ifdef __ICC // icpc defines the __clang__ macro
# pragma warning(push)
# pragma warning(disable: 161 1682)
# else // __ICC
# pragma clang diagnostic ignored "-Wglobal-constructors"
# pragma clang diagnostic ignored "-Wvariadic-macros"
# pragma clang diagnostic ignored "-Wc99-extensions"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc++98-compat"
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
# pragma clang diagnostic ignored "-Wswitch-enum"
# pragma clang diagnostic ignored "-Wcovered-switch-default"
# endif
#elif defined __GNUC__
# pragma GCC diagnostic ignored "-Wvariadic-macros"
# pragma GCC diagnostic ignored "-Wunused-variable"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpadded"
#endif
#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
# define CATCH_IMPL
#endif
#ifdef CATCH_IMPL
# ifndef CLARA_CONFIG_MAIN
# define CLARA_CONFIG_MAIN_NOT_DEFINED
# define CLARA_CONFIG_MAIN
# endif
#endif
// #included from: internal/catch_notimplemented_exception.h
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
// #included from: catch_common.h
#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
// #included from: catch_compiler_capabilities.h
#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
// The following features are defined:
//
// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported?
// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
// CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
// ****************
// Note to maintainers: if new toggles are added please document them
// in configuration.md, too
// ****************
// In general each macro has a _NO_<feature name> form
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __cplusplus
# if __cplusplus >= 201103L
# define CATCH_CPP11_OR_GREATER
# endif
# if __cplusplus >= 201402L
# define CATCH_CPP14_OR_GREATER
# endif
#endif
#ifdef __clang__
# if __has_feature(cxx_nullptr)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif
# if __has_feature(cxx_noexcept)
# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif
# if defined(CATCH_CPP11_OR_GREATER)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
# endif
#endif // __clang__
////////////////////////////////////////////////////////////////////////////////
// Borland
#ifdef __BORLANDC__
#endif // __BORLANDC__
////////////////////////////////////////////////////////////////////////////////
// EDG
#ifdef __EDG_VERSION__
#endif // __EDG_VERSION__
////////////////////////////////////////////////////////////////////////////////
// Digital Mars
#ifdef __DMC__
#endif // __DMC__
////////////////////////////////////////////////////////////////////////////////
// GCC
#ifdef __GNUC__
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif
# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
# endif
// - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below
#endif // __GNUC__
////////////////////////////////////////////////////////////////////////////////
// Visual C++
#ifdef _MSC_VER
#if (_MSC_VER >= 1600)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
#endif
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
#endif
#endif // _MSC_VER
////////////////////////////////////////////////////////////////////////////////
// Use variadic macros if the compiler supports them
#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
( defined __GNUC__ && __GNUC__ >= 3 ) || \
( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#endif
// Use __COUNTER__ if the compiler supports it
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
( defined __clang__ && __clang_major__ >= 3 )
#define CATCH_INTERNAL_CONFIG_COUNTER
#endif
////////////////////////////////////////////////////////////////////////////////
// C++ language feature support
// catch all support for C++11
#if defined(CATCH_CPP11_OR_GREATER)
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif
# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif
# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# endif
# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# endif
# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# endif
# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
# endif
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
# endif
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
# endif
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
# endif
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE)
# define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
# endif
#endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NULLPTR
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_IS_ENUM
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_TUPLE
#endif
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
# define CATCH_CONFIG_VARIADIC_MACROS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_LONG_LONG
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_OVERRIDE
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
#endif
// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
// This does not affect compilation
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
# define CATCH_CONFIG_COUNTER
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_SHUFFLE
#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
#endif
// noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
# define CATCH_NOEXCEPT noexcept
# define CATCH_NOEXCEPT_IS(x) noexcept(x)
#else
# define CATCH_NOEXCEPT throw()
# define CATCH_NOEXCEPT_IS(x)
#endif
// nullptr support
#ifdef CATCH_CONFIG_CPP11_NULLPTR
# define CATCH_NULL nullptr
#else
# define CATCH_NULL NULL
#endif
// override support
#ifdef CATCH_CONFIG_CPP11_OVERRIDE
# define CATCH_OVERRIDE override
#else
# define CATCH_OVERRIDE
#endif
// unique_ptr support
#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
# define CATCH_AUTO_PTR( T ) std::unique_ptr<T>
#else
# define CATCH_AUTO_PTR( T ) std::auto_ptr<T>
#endif
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
#ifdef CATCH_CONFIG_COUNTER
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
#else
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
#endif
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
#include <sstream>
#include <stdexcept>
#include <algorithm>
namespace Catch {
struct IConfig;
struct CaseSensitive { enum Choice {
Yes,
No
}; };
class NonCopyable {
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
NonCopyable( NonCopyable const& ) = delete;
NonCopyable( NonCopyable && ) = delete;
NonCopyable& operator = ( NonCopyable const& ) = delete;
NonCopyable& operator = ( NonCopyable && ) = delete;
#else
NonCopyable( NonCopyable const& info );
NonCopyable& operator = ( NonCopyable const& );
#endif
protected:
NonCopyable() {}
virtual ~NonCopyable();
};
class SafeBool {
public:
typedef void (SafeBool::*type)() const;
static type makeSafe( bool value ) {
return value ? &SafeBool::trueValue : 0;
}
private:
void trueValue() const {}
};
template<typename ContainerT>
inline void deleteAll( ContainerT& container ) {
typename ContainerT::const_iterator it = container.begin();
typename ContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it )
delete *it;
}
template<typename AssociativeContainerT>
inline void deleteAllValues( AssociativeContainerT& container ) {
typename AssociativeContainerT::const_iterator it = container.begin();
typename AssociativeContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it )
delete it->second;
}
bool startsWith( std::string const& s, std::string const& prefix );
bool endsWith( std::string const& s, std::string const& suffix );
bool contains( std::string const& s, std::string const& infix );
void toLowerInPlace( std::string& s );
std::string toLower( std::string const& s );
std::string trim( std::string const& str );
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
struct pluralise {
pluralise( std::size_t count, std::string const& label );
friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
std::size_t m_count;
std::string m_label;
};
struct SourceLineInfo {
SourceLineInfo();
SourceLineInfo( char const* _file, std::size_t _line );
SourceLineInfo( SourceLineInfo const& other );
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
SourceLineInfo( SourceLineInfo && ) = default;
SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
SourceLineInfo& operator = ( SourceLineInfo && ) = default;
# endif
bool empty() const;
bool operator == ( SourceLineInfo const& other ) const;
bool operator < ( SourceLineInfo const& other ) const;
std::string file;
std::size_t line;
};
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
// This is just here to avoid compiler warnings with macro constants and boolean literals
inline bool alwaysTrue( std::size_t = 0 ) { return true; }
inline bool alwaysFalse( std::size_t = 0 ) { return false; }
void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
void seedRng( IConfig const& config );
unsigned int rngSeed();
// Use this in variadic streaming macros to allow
// >> +StreamEndStop
// as well as
// >> stuff +StreamEndStop
struct StreamEndStop {
std::string operator+() {
return std::string();
}
};
template<typename T>
T const& operator + ( T const& value, StreamEndStop ) {
return value;
}
}
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
#include <ostream>
namespace Catch {
class NotImplementedException : public std::exception
{
public:
NotImplementedException( SourceLineInfo const& lineInfo );
NotImplementedException( NotImplementedException const& ) {}
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
virtual const char* what() const CATCH_NOEXCEPT;
private:
std::string m_what;
SourceLineInfo m_lineInfo;
};
} // end namespace Catch
///////////////////////////////////////////////////////////////////////////////
#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
// #included from: internal/catch_context.h
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
// #included from: catch_interfaces_generators.h
#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
#include <string>
namespace Catch {
struct IGeneratorInfo {
virtual ~IGeneratorInfo();
virtual bool moveNext() = 0;
virtual std::size_t getCurrentIndex() const = 0;
};
struct IGeneratorsForTest {
virtual ~IGeneratorsForTest();
virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
virtual bool moveNext() = 0;
};
IGeneratorsForTest* createGeneratorsForTest();
} // end namespace Catch
// #included from: catch_ptr.hpp
#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch {
// An intrusive reference counting smart pointer.
// T must implement addRef() and release() methods
// typically implementing the IShared interface
template<typename T>
class Ptr {
public:
Ptr() : m_p( CATCH_NULL ){}
Ptr( T* p ) : m_p( p ){
if( m_p )
m_p->addRef();
}
Ptr( Ptr const& other ) : m_p( other.m_p ){
if( m_p )
m_p->addRef();
}
~Ptr(){
if( m_p )
m_p->release();
}
void reset() {
if( m_p )
m_p->release();
m_p = CATCH_NULL;
}
Ptr& operator = ( T* p ){
Ptr temp( p );
swap( temp );
return *this;
}
Ptr& operator = ( Ptr const& other ){
Ptr temp( other );
swap( temp );
return *this;
}
void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
T* get() const{ return m_p; }
T& operator*() const { return *m_p; }
T* operator->() const { return m_p; }
bool operator !() const { return m_p == CATCH_NULL; }
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
private:
T* m_p;
};
struct IShared : NonCopyable {
virtual ~IShared();
virtual void addRef() const = 0;
virtual void release() const = 0;
};
template<typename T = IShared>
struct SharedImpl : T {
SharedImpl() : m_rc( 0 ){}
virtual void addRef() const {
++m_rc;
}
virtual void release() const {
if( --m_rc == 0 )
delete this;
}
mutable unsigned int m_rc;
};
} // end namespace Catch
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#include <memory>
#include <vector>
#include <stdlib.h>
namespace Catch {
class TestCase;
class Stream;
struct IResultCapture;
struct IRunner;
struct IGeneratorsForTest;
struct IConfig;
struct IContext
{
virtual ~IContext();
virtual IResultCapture* getResultCapture() = 0;
virtual IRunner* getRunner() = 0;
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
virtual bool advanceGeneratorsForCurrentTest() = 0;
virtual Ptr<IConfig const> getConfig() const = 0;
};
struct IMutableContext : IContext
{
virtual ~IMutableContext();
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
virtual void setRunner( IRunner* runner ) = 0;
virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
};
IContext& getCurrentContext();
IMutableContext& getCurrentMutableContext();
void cleanUpContext();
Stream createStream( std::string const& streamName );
}
// #included from: internal/catch_test_registry.hpp
#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
// #included from: catch_interfaces_testcase.h
#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
#include <vector>
namespace Catch {
class TestSpec;
struct ITestCase : IShared {
virtual void invoke () const = 0;
protected:
virtual ~ITestCase();
};
class TestCase;
struct IConfig;
struct ITestCaseRegistry {
virtual ~ITestCaseRegistry();
virtual std::vector<TestCase> const& getAllTests() const = 0;
virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
};
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
}
namespace Catch {
template<typename C>
class MethodTestCase : public SharedImpl<ITestCase> {
public:
MethodTestCase( void (C::*method)() ) : m_method( method ) {}
virtual void invoke() const {
C obj;
(obj.*m_method)();
}
private:
virtual ~MethodTestCase() {}
void (C::*m_method)();
};
typedef void(*TestFunction)();
struct NameAndDesc {
NameAndDesc( const char* _name = "", const char* _description= "" )
: name( _name ), description( _description )
{}
const char* name;
const char* description;
};
void registerTestCase
( ITestCase* testCase,
char const* className,
NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo );
struct AutoReg {
AutoReg
( TestFunction function,
SourceLineInfo const& lineInfo,
NameAndDesc const& nameAndDesc );
template<typename C>
AutoReg
( void (C::*method)(),
char const* className,
NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo ) {
registerTestCase
( new MethodTestCase<C>( method ),
className,
nameAndDesc,
lineInfo );
}
~AutoReg();
private:
AutoReg( AutoReg const& );
void operator= ( AutoReg const& );
};
void registerTestCaseFunction
( TestFunction function,
SourceLineInfo const& lineInfo,
NameAndDesc const& nameAndDesc );
} // end namespace Catch
#ifdef CATCH_CONFIG_VARIADIC_MACROS
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
static void TestName(); \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
static void TestName()
#define INTERNAL_CATCH_TESTCASE( ... ) \
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
namespace{ \
struct TestName : ClassName{ \
void test(); \
}; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
} \
void TestName::test()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
#else
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
static void TestName(); \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
static void TestName()
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
namespace{ \
struct TestCaseName : ClassName{ \
void test(); \
}; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
} \
void TestCaseName::test()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
#endif
// #included from: internal/catch_capture.hpp
#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
// #included from: catch_result_builder.h
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
// #included from: catch_result_type.h
#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
namespace Catch {
// ResultWas::OfType enum
struct ResultWas { enum OfType {
Unknown = -1,
Ok = 0,
Info = 1,
Warning = 2,
FailureBit = 0x10,
ExpressionFailed = FailureBit | 1,
ExplicitFailure = FailureBit | 2,
Exception = 0x100 | FailureBit,
ThrewException = Exception | 1,
DidntThrowException = Exception | 2,
FatalErrorCondition = 0x200 | FailureBit
}; };
inline bool isOk( ResultWas::OfType resultType ) {
return ( resultType & ResultWas::FailureBit ) == 0;
}
inline bool isJustInfo( int flags ) {
return flags == ResultWas::Info;
}
// ResultDisposition::Flags enum
struct ResultDisposition { enum Flags {
Normal = 0x01,
ContinueOnFailure = 0x02, // Failures fail test, but execution continues
FalseTest = 0x04, // Prefix expression with !
SuppressFail = 0x08 // Failures are reported but do not fail the test
}; };
inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
}
inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
} // end namespace Catch
// #included from: catch_assertionresult.h
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
#include <string>
namespace Catch {
struct AssertionInfo
{
AssertionInfo() {}
AssertionInfo( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
std::string const& _capturedExpression,
ResultDisposition::Flags _resultDisposition );
std::string macroName;
SourceLineInfo lineInfo;
std::string capturedExpression;
ResultDisposition::Flags resultDisposition;
};
struct AssertionResultData
{
AssertionResultData() : resultType( ResultWas::Unknown ) {}
std::string reconstructedExpression;
std::string message;
ResultWas::OfType resultType;
};
class AssertionResult {
public:
AssertionResult();
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
~AssertionResult();
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
AssertionResult( AssertionResult const& ) = default;
AssertionResult( AssertionResult && ) = default;
AssertionResult& operator = ( AssertionResult const& ) = default;
AssertionResult& operator = ( AssertionResult && ) = default;
# endif
bool isOk() const;
bool succeeded() const;
ResultWas::OfType getResultType() const;
bool hasExpression() const;
bool hasMessage() const;
std::string getExpression() const;
std::string getExpressionInMacro() const;
bool hasExpandedExpression() const;
std::string getExpandedExpression() const;
std::string getMessage() const;
SourceLineInfo getSourceInfo() const;
std::string getTestMacroName() const;
protected:
AssertionInfo m_info;
AssertionResultData m_resultData;
};
} // end namespace Catch
// #included from: catch_matchers.hpp
#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
namespace Catch {
namespace Matchers {
namespace Impl {
namespace Generic {
template<typename ExpressionT> class AllOf;
template<typename ExpressionT> class AnyOf;
template<typename ExpressionT> class Not;
}
template<typename ExpressionT>
struct Matcher : SharedImpl<IShared>
{
typedef ExpressionT ExpressionType;
virtual ~Matcher() {}
virtual Ptr<Matcher> clone() const = 0;
virtual bool match( ExpressionT const& expr ) const = 0;
virtual std::string toString() const = 0;
Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
Generic::Not<ExpressionT> operator ! () const;
};
template<typename DerivedT, typename ExpressionT>
struct MatcherImpl : Matcher<ExpressionT> {
virtual Ptr<Matcher<ExpressionT> > clone() const {
return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<DerivedT const&>( *this ) ) );
}
};
namespace Generic {
template<typename ExpressionT>
class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
public:
explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
Not( Not const& other ) : m_matcher( other.m_matcher ) {}
virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
return !m_matcher->match( expr );
}
virtual std::string toString() const CATCH_OVERRIDE {
return "not " + m_matcher->toString();
}
private:
Ptr< Matcher<ExpressionT> > m_matcher;
};
template<typename ExpressionT>
class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
public:
AllOf() {}
AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
AllOf& add( Matcher<ExpressionT> const& matcher ) {
m_matchers.push_back( matcher.clone() );
return *this;
}
virtual bool match( ExpressionT const& expr ) const
{
for( std::size_t i = 0; i < m_matchers.size(); ++i )
if( !m_matchers[i]->match( expr ) )
return false;
return true;
}
virtual std::string toString() const {
std::ostringstream oss;
oss << "( ";
for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
if( i != 0 )
oss << " and ";
oss << m_matchers[i]->toString();
}
oss << " )";
return oss.str();
}
AllOf operator && ( Matcher<ExpressionT> const& other ) const {
AllOf allOfExpr( *this );
allOfExpr.add( other );
return allOfExpr;
}
private:
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
};
template<typename ExpressionT>
class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
public:
AnyOf() {}
AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
AnyOf& add( Matcher<ExpressionT> const& matcher ) {
m_matchers.push_back( matcher.clone() );
return *this;
}
virtual bool match( ExpressionT const& expr ) const
{
for( std::size_t i = 0; i < m_matchers.size(); ++i )
if( m_matchers[i]->match( expr ) )
return true;
return false;
}
virtual std::string toString() const {
std::ostringstream oss;
oss << "( ";
for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
if( i != 0 )
oss << " or ";
oss << m_matchers[i]->toString();
}
oss << " )";
return oss.str();
}
AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
AnyOf anyOfExpr( *this );
anyOfExpr.add( other );
return anyOfExpr;
}
private:
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
};
} // namespace Generic
template<typename ExpressionT>
Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
Generic::AllOf<ExpressionT> allOfExpr;
allOfExpr.add( *this );
allOfExpr.add( other );
return allOfExpr;
}
template<typename ExpressionT>
Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
Generic::AnyOf<ExpressionT> anyOfExpr;
anyOfExpr.add( *this );
anyOfExpr.add( other );
return anyOfExpr;
}
template<typename ExpressionT>
Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
return Generic::Not<ExpressionT>( *this );
}
namespace StdString {
inline std::string makeString( std::string const& str ) { return str; }
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
struct CasedString
{
CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
: m_caseSensitivity( caseSensitivity ),
m_str( adjustString( str ) )
{}
std::string adjustString( std::string const& str ) const {
return m_caseSensitivity == CaseSensitive::No
? toLower( str )
: str;
}
std::string toStringSuffix() const
{
return m_caseSensitivity == CaseSensitive::No
? " (case insensitive)"
: "";
}
CaseSensitive::Choice m_caseSensitivity;
std::string m_str;
};
struct Equals : MatcherImpl<Equals, std::string> {
Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
: m_data( str, caseSensitivity )
{}
Equals( Equals const& other ) : m_data( other.m_data ){}
virtual ~Equals();
virtual bool match( std::string const& expr ) const {
return m_data.m_str == m_data.adjustString( expr );;
}
virtual std::string toString() const {
return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
}
CasedString m_data;
};
struct Contains : MatcherImpl<Contains, std::string> {
Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
: m_data( substr, caseSensitivity ){}
Contains( Contains const& other ) : m_data( other.m_data ){}
virtual ~Contains();
virtual bool match( std::string const& expr ) const {
return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
}
virtual std::string toString() const {
return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
}
CasedString m_data;
};
struct StartsWith : MatcherImpl<StartsWith, std::string> {
StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
: m_data( substr, caseSensitivity ){}
StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
virtual ~StartsWith();
virtual bool match( std::string const& expr ) const {
return startsWith( m_data.adjustString( expr ), m_data.m_str );
}
virtual std::string toString() const {
return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
}
CasedString m_data;
};
struct EndsWith : MatcherImpl<EndsWith, std::string> {
EndsWith( std
gitextract_sogveh4o/
├── .gitignore
├── .npmignore
├── .travis.yml
├── CMakeLists.txt
├── LICENSE.txt
├── README.md
├── appveyor.yml
├── benchmark/
│ ├── README.md
│ ├── bench-utils.ts
│ ├── bench.ts
│ ├── execute-overhead.ts
│ ├── execute-scalability.ts
│ ├── node-napa-perf-comparison.ts
│ ├── store-overhead.ts
│ ├── transport-overhead.ts
│ └── tsconfig.json
├── build.bat
├── build.js
├── docs/
│ ├── api/
│ │ ├── index.md
│ │ ├── log.md
│ │ ├── memory.md
│ │ ├── metric.md
│ │ ├── module.md
│ │ ├── napa-globals.md
│ │ ├── node-api.md
│ │ ├── store.md
│ │ ├── sync.md
│ │ ├── transport.md
│ │ └── zone.md
│ └── design/
│ └── transport-js-builtins.md
├── examples/
│ ├── modules/
│ │ ├── README.md
│ │ ├── async-number/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── binding.gyp
│ │ │ ├── lib/
│ │ │ │ ├── async-number.ts
│ │ │ │ └── tsconfig.json
│ │ │ ├── napa/
│ │ │ │ └── addon.cpp
│ │ │ ├── package.json
│ │ │ └── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ ├── hello-world/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── binding.gyp
│ │ │ ├── lib/
│ │ │ │ ├── hello-world.ts
│ │ │ │ └── tsconfig.json
│ │ │ ├── napa/
│ │ │ │ └── addon.cpp
│ │ │ ├── package.json
│ │ │ └── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ └── plus-number/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── inc/
│ │ │ └── plus-number.h
│ │ ├── lib/
│ │ │ ├── plus-number.ts
│ │ │ └── tsconfig.json
│ │ ├── napa/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── addon.cpp
│ │ │ ├── plus-number-wrap.cpp
│ │ │ └── plus-number-wrap.h
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── CMakeLists.txt
│ │ │ └── plus-number.cpp
│ │ ├── test/
│ │ │ ├── test.ts
│ │ │ └── tsconfig.json
│ │ └── unittest/
│ │ ├── CMakeLists.txt
│ │ ├── catch/
│ │ │ ├── LICENSE.txt
│ │ │ └── catch.hpp
│ │ ├── main.cpp
│ │ └── run.js
│ └── tutorial/
│ ├── estimate-pi-in-parallel/
│ │ ├── README.md
│ │ ├── estimate-pi-in-parallel.js
│ │ └── package.json
│ ├── max-square-sub-matrix/
│ │ ├── README.md
│ │ ├── max-square-sub-matrix.js
│ │ └── package.json
│ ├── napa-runner/
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── estimate-PI.js
│ │ ├── main.cpp
│ │ └── package.json
│ ├── parallel-quick-sort/
│ │ ├── README.md
│ │ ├── package.json
│ │ └── parallel-quick-sort.js
│ ├── recursive-fibonacci/
│ │ ├── README.md
│ │ ├── package.json
│ │ └── recursive-fibonacci.js
│ └── synchronized-loading/
│ ├── README.md
│ ├── package.json
│ ├── phone-book-data.json
│ ├── phone-book.js
│ └── synchronized-loading.js
├── inc/
│ ├── napa/
│ │ ├── assert.h
│ │ ├── async.h
│ │ ├── capi.h
│ │ ├── exports.h
│ │ ├── log.h
│ │ ├── memory/
│ │ │ ├── allocator-debugger.h
│ │ │ ├── allocator.h
│ │ │ └── common.h
│ │ ├── memory.h
│ │ ├── module/
│ │ │ ├── binding/
│ │ │ │ ├── basic-wraps.h
│ │ │ │ └── wraps.h
│ │ │ ├── binding.h
│ │ │ ├── common.h
│ │ │ ├── module-internal.h
│ │ │ ├── module-node-compat.h
│ │ │ ├── object-wrap.h
│ │ │ ├── shareable-wrap.h
│ │ │ └── transport-context-wrap.h
│ │ ├── module.h
│ │ ├── providers/
│ │ │ ├── logging.h
│ │ │ └── metric.h
│ │ ├── result-codes.inc
│ │ ├── stl/
│ │ │ ├── allocator.h
│ │ │ ├── deque.h
│ │ │ ├── list.h
│ │ │ ├── map.h
│ │ │ ├── queue.h
│ │ │ ├── set.h
│ │ │ ├── stack.h
│ │ │ ├── string.h
│ │ │ ├── unordered_map.h
│ │ │ ├── unordered_set.h
│ │ │ └── vector.h
│ │ ├── transport/
│ │ │ ├── transport-context.h
│ │ │ ├── transport.h
│ │ │ └── transportable.h
│ │ ├── transport.h
│ │ ├── types.h
│ │ ├── utils.h
│ │ ├── v8-helpers/
│ │ │ ├── array.h
│ │ │ ├── console.h
│ │ │ ├── conversion.h
│ │ │ ├── flow.h
│ │ │ ├── function.h
│ │ │ ├── json.h
│ │ │ ├── maybe.h
│ │ │ ├── object.h
│ │ │ ├── ptr.h
│ │ │ ├── string.h
│ │ │ └── time.h
│ │ ├── v8-helpers.h
│ │ ├── version.h
│ │ ├── zone/
│ │ │ ├── napa-async-runner.h
│ │ │ └── node-async-runner.h
│ │ └── zone.h
│ └── napa.h
├── lib/
│ ├── binding.js
│ ├── core/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── README.md
│ │ ├── core-modules.json
│ │ ├── timers/
│ │ │ ├── timer-api.ts
│ │ │ └── timer.ts
│ │ └── timers.ts
│ ├── index.ts
│ ├── log.ts
│ ├── memory/
│ │ ├── allocator.ts
│ │ ├── handle.ts
│ │ └── shareable.ts
│ ├── memory.ts
│ ├── metric.ts
│ ├── runtime/
│ │ └── platform.ts
│ ├── runtime.ts
│ ├── store/
│ │ ├── store-api.ts
│ │ └── store.ts
│ ├── store.ts
│ ├── sync/
│ │ └── lock.ts
│ ├── sync.ts
│ ├── transport/
│ │ ├── builtin-object-transporter.ts
│ │ ├── function-transporter.ts
│ │ ├── transport.ts
│ │ └── transportable.ts
│ ├── transport.ts
│ ├── tsconfig.json
│ ├── v8/
│ │ └── stack-trace.ts
│ ├── v8.ts
│ ├── zone/
│ │ ├── function-call.ts
│ │ ├── zone-impl.ts
│ │ └── zone.ts
│ └── zone.ts
├── node/
│ ├── CMakeLists.txt
│ ├── addon.cpp
│ ├── node-zone-delegates.cpp
│ └── node-zone-delegates.h
├── package.json
├── scripts/
│ ├── clean.js
│ ├── embedded.js
│ ├── install.js
│ └── paths.js
├── src/
│ ├── CMakeLists.txt
│ ├── api/
│ │ └── capi.cpp
│ ├── memory/
│ │ └── built-in-allocators.cpp
│ ├── module/
│ │ ├── core-modules/
│ │ │ ├── core-modules.h
│ │ │ ├── napa/
│ │ │ │ ├── allocator-debugger-wrap.cpp
│ │ │ │ ├── allocator-debugger-wrap.h
│ │ │ │ ├── allocator-wrap.cpp
│ │ │ │ ├── allocator-wrap.h
│ │ │ │ ├── call-context-wrap.cpp
│ │ │ │ ├── call-context-wrap.h
│ │ │ │ ├── lock-wrap.cpp
│ │ │ │ ├── lock-wrap.h
│ │ │ │ ├── metric-wrap.cpp
│ │ │ │ ├── metric-wrap.h
│ │ │ │ ├── napa-binding.cpp
│ │ │ │ ├── napa-binding.h
│ │ │ │ ├── shared-ptr-wrap.cpp
│ │ │ │ ├── shared-ptr-wrap.h
│ │ │ │ ├── store-wrap.cpp
│ │ │ │ ├── store-wrap.h
│ │ │ │ ├── timer-wrap.cpp
│ │ │ │ ├── timer-wrap.h
│ │ │ │ ├── transport-context-wrap-impl.cpp
│ │ │ │ ├── transport-context-wrap-impl.h
│ │ │ │ ├── zone-wrap.cpp
│ │ │ │ └── zone-wrap.h
│ │ │ └── node/
│ │ │ ├── console.cpp
│ │ │ ├── console.h
│ │ │ ├── file-system-helpers.cpp
│ │ │ ├── file-system-helpers.h
│ │ │ ├── file-system.cpp
│ │ │ ├── file-system.h
│ │ │ ├── os.cpp
│ │ │ ├── os.h
│ │ │ ├── path.cpp
│ │ │ ├── path.h
│ │ │ ├── process.cpp
│ │ │ ├── process.h
│ │ │ ├── tty-wrap.cpp
│ │ │ └── tty-wrap.h
│ │ ├── loader/
│ │ │ ├── binary-module-loader.cpp
│ │ │ ├── binary-module-loader.h
│ │ │ ├── core-module-loader.cpp
│ │ │ ├── core-module-loader.h
│ │ │ ├── javascript-module-loader.cpp
│ │ │ ├── javascript-module-loader.h
│ │ │ ├── json-module-loader.cpp
│ │ │ ├── json-module-loader.h
│ │ │ ├── module-cache.cpp
│ │ │ ├── module-cache.h
│ │ │ ├── module-file-loader.h
│ │ │ ├── module-loader-helpers.cpp
│ │ │ ├── module-loader-helpers.h
│ │ │ ├── module-loader.cpp
│ │ │ ├── module-loader.h
│ │ │ ├── module-resolver-cache.cpp
│ │ │ ├── module-resolver-cache.h
│ │ │ ├── module-resolver.cpp
│ │ │ └── module-resolver.h
│ │ └── module.cpp
│ ├── platform/
│ │ ├── dll.cpp
│ │ ├── dll.h
│ │ ├── filesystem.cpp
│ │ ├── filesystem.h
│ │ ├── os.cpp
│ │ ├── os.h
│ │ ├── platform.h
│ │ ├── process.cpp
│ │ ├── process.h
│ │ └── thread-local.h
│ ├── providers/
│ │ ├── console-logging-provider.h
│ │ ├── nop-logging-provider.h
│ │ ├── nop-metric-provider.h
│ │ ├── providers.cpp
│ │ └── providers.h
│ ├── settings/
│ │ ├── settings-parser.cpp
│ │ ├── settings-parser.h
│ │ └── settings.h
│ ├── store/
│ │ ├── store.cpp
│ │ └── store.h
│ ├── utils/
│ │ └── string.h
│ ├── v8-extensions/
│ │ ├── CMakeLists.txt
│ │ ├── array-buffer-allocator.cpp
│ │ ├── array-buffer-allocator.h
│ │ ├── deserializer.cpp
│ │ ├── deserializer.h
│ │ ├── externalized-contents.cpp
│ │ ├── externalized-contents.h
│ │ ├── serialized-data.cpp
│ │ ├── serialized-data.h
│ │ ├── serializer.cpp
│ │ ├── serializer.h
│ │ ├── v8-common.cpp
│ │ ├── v8-common.h
│ │ ├── v8-extensions-macros.h
│ │ ├── v8-extensions.cpp
│ │ └── v8-extensions.h
│ └── zone/
│ ├── async-complete-task.cpp
│ ├── async-complete-task.h
│ ├── async-context.h
│ ├── async-runner.cpp
│ ├── call-context.cpp
│ ├── call-context.h
│ ├── call-task.cpp
│ ├── call-task.h
│ ├── eval-task.cpp
│ ├── eval-task.h
│ ├── napa-zone.cpp
│ ├── napa-zone.h
│ ├── node-zone.cpp
│ ├── node-zone.h
│ ├── schedule-phase.h
│ ├── scheduler.cpp
│ ├── scheduler.h
│ ├── simple-thread-pool.cpp
│ ├── simple-thread-pool.h
│ ├── task-decorators.h
│ ├── task.h
│ ├── terminable-task.cpp
│ ├── terminable-task.h
│ ├── timer.cpp
│ ├── timer.h
│ ├── worker-context.cpp
│ ├── worker-context.h
│ ├── worker.cpp
│ ├── worker.h
│ └── zone.h
├── test/
│ ├── memory-test.ts
│ ├── module/
│ │ ├── addon/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── addon.cpp
│ │ │ ├── simple-object-wrap.cpp
│ │ │ └── simple-object-wrap.h
│ │ ├── cycle-a.js
│ │ ├── cycle-b.js
│ │ ├── jsmodule.js
│ │ ├── node_modules/
│ │ │ └── file.js
│ │ ├── resolution-tests.js
│ │ ├── sub-folder/
│ │ │ ├── addon/
│ │ │ │ └── mock-addon.napa
│ │ │ └── file.js
│ │ └── test.json
│ ├── module-test.ts
│ ├── napa-zone/
│ │ ├── function-as-module.ts
│ │ ├── test-main.ts
│ │ └── test.ts
│ ├── store-test.ts
│ ├── sync-test.ts
│ ├── timer-test.ts
│ ├── transport-test.ts
│ ├── tsconfig.json
│ └── zone-test.ts
├── third-party/
│ ├── args/
│ │ ├── LICENSE
│ │ └── args.hxx
│ ├── catch/
│ │ ├── LICENSE.txt
│ │ └── catch.hpp
│ └── rapidjson/
│ ├── LICENSE.txt
│ ├── allocators.h
│ ├── document.h
│ ├── encodedstream.h
│ ├── encodings.h
│ ├── error/
│ │ ├── en.h
│ │ └── error.h
│ ├── filereadstream.h
│ ├── filewritestream.h
│ ├── fwd.h
│ ├── internal/
│ │ ├── biginteger.h
│ │ ├── diyfp.h
│ │ ├── dtoa.h
│ │ ├── ieee754.h
│ │ ├── itoa.h
│ │ ├── meta.h
│ │ ├── pow10.h
│ │ ├── regex.h
│ │ ├── stack.h
│ │ ├── strfunc.h
│ │ ├── strtod.h
│ │ └── swap.h
│ ├── istreamwrapper.h
│ ├── memorybuffer.h
│ ├── memorystream.h
│ ├── msinttypes/
│ │ ├── inttypes.h
│ │ └── stdint.h
│ ├── ostreamwrapper.h
│ ├── pointer.h
│ ├── prettywriter.h
│ ├── rapidjson.h
│ ├── reader.h
│ ├── schema.h
│ ├── stream.h
│ ├── stringbuffer.h
│ └── writer.h
└── unittest/
├── CMakeLists.txt
├── main.cpp
├── module/
│ ├── file-system-helpers-tests.cpp
│ ├── module-resolver-cache-tests.cpp
│ ├── module-resolver-tests.cpp
│ └── test-files/
│ ├── node_modules/
│ │ ├── resolve-nm-file
│ │ ├── resolve-nm-file-js.js
│ │ ├── resolve-nm-file-js.json
│ │ ├── resolve-nm-file-js.napa
│ │ ├── resolve-nm-file-json.json
│ │ ├── resolve-nm-file-json.napa
│ │ ├── resolve-nm-file-napa.napa
│ │ ├── resolve-nm-file.js
│ │ ├── resolve-nm-file.json
│ │ ├── resolve-nm-file.napa
│ │ ├── resolver-nm/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-nm-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-nm-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-nm-napa/
│ │ └── index.napa
│ ├── resolve-directory/
│ │ ├── resolver/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-napa/
│ │ └── index.napa
│ ├── resolve-env/
│ │ ├── resolve-env-file
│ │ ├── resolve-env-file-js.js
│ │ ├── resolve-env-file-js.json
│ │ ├── resolve-env-file-js.napa
│ │ ├── resolve-env-file-json.json
│ │ ├── resolve-env-file-json.napa
│ │ ├── resolve-env-file-napa.napa
│ │ ├── resolve-env-file.js
│ │ ├── resolve-env-file.json
│ │ ├── resolve-env-file.napa
│ │ ├── resolver-env/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.napa
│ │ │ ├── package.json
│ │ │ └── resolve-file
│ │ ├── resolver-env-js/
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ ├── resolver-env-json/
│ │ │ ├── index.json
│ │ │ └── index.napa
│ │ └── resolver-env-napa/
│ │ └── index.napa
│ ├── resolve-file
│ ├── resolve-file-js.js
│ ├── resolve-file-js.json
│ ├── resolve-file-js.napa
│ ├── resolve-file-json.json
│ ├── resolve-file-json.napa
│ ├── resolve-file-napa.napa
│ ├── resolve-file-no.js
│ ├── resolve-file.js
│ ├── resolve-file.json
│ └── resolve-file.napa
├── platform/
│ └── filesystem-tests.cpp
├── run.js
├── settings/
│ └── parser-tests.cpp
├── utils/
│ └── string-tests.cpp
└── zone/
├── scheduler-tests.cpp
└── timer-tests.cpp
Copy disabled (too large)
Download .txt
Showing preview only (20,645K chars total). Download the full file to get everything.
SYMBOL INDEX (3840 symbols across 240 files)
FILE: benchmark/bench-utils.ts
function generateString (line 6) | function generateString(length: number): string {
function generateObject (line 10) | function generateObject(keys: number, depth: number, valueType: string =...
function timeDiffInMs (line 33) | function timeDiffInMs(diff: [number, number]): number {
function formatTimeDiff (line 37) | function formatTimeDiff(diff: number | [number, number], printUnit: bool...
function formatRatio (line 48) | function formatRatio(dividend: number, divider: number): string {
FILE: benchmark/bench.ts
function bench (line 11) | function bench(): Promise<void> {
FILE: benchmark/execute-overhead.ts
function batchExecuteOnNamedFunction (line 8) | function batchExecuteOnNamedFunction(
function batchExecuteOnAnonymousFunction (line 27) | function batchExecuteOnAnonymousFunction(
function bench (line 46) | async function bench(zone: napa.zone.Zone): Promise<void> {
FILE: benchmark/execute-scalability.ts
function makeCRCTable (line 9) | function makeCRCTable(){
function crc32 (line 23) | function crc32(str: string) {
function testCrc (line 32) | function testCrc() {
function bench (line 43) | async function bench(zone: napa.zone.Zone): Promise<void> {
FILE: benchmark/node-napa-perf-comparison.ts
function timeIt (line 8) | function timeIt(func: () => void): [number, number] {
function test1 (line 14) | function test1(): [number, number] {
function bench (line 24) | async function bench(zone: napa.zone.Zone): Promise<void> {
FILE: benchmark/store-overhead.ts
type BenchmarkSettings (line 9) | type BenchmarkSettings = [
function bench (line 17) | function bench() {
FILE: benchmark/transport-overhead.ts
type BenchmarkSettings (line 9) | type BenchmarkSettings = [
function bench (line 17) | function bench() {
FILE: examples/modules/async-number/lib/async-number.ts
function increase (line 6) | function increase(value: number, callback: (now: number) => void) {
function increaseSync (line 10) | function increaseSync(value: number, callback: (now: number) => void) {
function now (line 14) | function now(): string {
FILE: examples/modules/async-number/napa/addon.cpp
type napa (line 10) | namespace napa {
type demo (line 11) | namespace demo {
function Increase (line 20) | void Increase(const FunctionCallbackInfo<Value>& args) {
function IncreaseSync (line 49) | void IncreaseSync(const FunctionCallbackInfo<Value>& args) {
function Now (line 78) | void Now(const FunctionCallbackInfo<Value>& args) {
function Init (line 85) | void Init(Local<Object> exports) {
FILE: examples/modules/hello-world/lib/hello-world.ts
function hello (line 6) | function hello(): string {
FILE: examples/modules/hello-world/napa/addon.cpp
type napa (line 6) | namespace napa {
type demo (line 7) | namespace demo {
function Method (line 11) | void Method(const FunctionCallbackInfo<Value>& args) {
function Init (line 16) | void Init(Local<Object> exports) {
FILE: examples/modules/plus-number/inc/plus-number.h
function namespace (line 16) | namespace napa {
FILE: examples/modules/plus-number/lib/plus-number.ts
class PlusNumber (line 6) | class PlusNumber {
function createPlusNumber (line 10) | function createPlusNumber(value: number = 0.0): PlusNumber {
FILE: examples/modules/plus-number/napa/addon.cpp
function CreatePlusNumber (line 9) | void CreatePlusNumber(const FunctionCallbackInfo<Value>& args) {
function InitAll (line 13) | void InitAll(Local<Object> exports) {
FILE: examples/modules/plus-number/napa/plus-number-wrap.h
function namespace (line 9) | namespace napa {
FILE: examples/modules/plus-number/unittest/catch/catch.hpp
type Catch (line 328) | namespace Catch {
type IConfig (line 330) | struct IConfig
type CaseSensitive (line 332) | struct CaseSensitive { enum Choice {
type Choice (line 332) | enum Choice {
class NonCopyable (line 337) | class NonCopyable {
method NonCopyable (line 339) | NonCopyable( NonCopyable const& ) = delete;
method NonCopyable (line 340) | NonCopyable( NonCopyable && ) = delete;
method NonCopyable (line 341) | NonCopyable& operator = ( NonCopyable const& ) = delete;
method NonCopyable (line 342) | NonCopyable& operator = ( NonCopyable && ) = delete;
method NonCopyable (line 349) | NonCopyable() {}
class SafeBool (line 353) | class SafeBool {
method type (line 357) | static type makeSafe( bool value ) {
method trueValue (line 361) | void trueValue() const {}
function deleteAll (line 365) | inline void deleteAll( ContainerT& container ) {
function deleteAllValues (line 372) | inline void deleteAllValues( AssociativeContainerT& container ) {
type pluralise (line 387) | struct pluralise {
type SourceLineInfo (line 396) | struct SourceLineInfo {
method SourceLineInfo (line 402) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 403) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 404) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
function alwaysTrue (line 417) | inline bool alwaysTrue( std::size_t = 0 ) { return true; }
function alwaysFalse (line 418) | inline bool alwaysFalse( std::size_t = 0 ) { return false; }
type StreamEndStop (line 429) | struct StreamEndStop {
function T (line 435) | T const& operator + ( T const& value, StreamEndStop ) {
class NotImplementedException (line 447) | class NotImplementedException : public std::exception
method NotImplementedException (line 451) | NotImplementedException( NotImplementedException const& ) {}
type IGeneratorInfo (line 477) | struct IGeneratorInfo {
type IGeneratorsForTest (line 483) | struct IGeneratorsForTest {
class Ptr (line 508) | class Ptr {
method Ptr (line 510) | Ptr() : m_p( CATCH_NULL ){}
method Ptr (line 511) | Ptr( T* p ) : m_p( p ){
method Ptr (line 515) | Ptr( Ptr const& other ) : m_p( other.m_p ){
method reset (line 523) | void reset() {
method Ptr (line 528) | Ptr& operator = ( T* p ){
method Ptr (line 533) | Ptr& operator = ( Ptr const& other ){
method swap (line 538) | void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
method T (line 539) | T* get() const{ return m_p; }
method T (line 540) | T& operator*() const { return *m_p; }
method T (line 541) | T* operator->() const { return m_p; }
type IShared (line 549) | struct IShared : NonCopyable {
type SharedImpl (line 556) | struct SharedImpl : T {
method SharedImpl (line 558) | SharedImpl() : m_rc( 0 ){}
method addRef (line 560) | virtual void addRef() const {
method release (line 563) | virtual void release() const {
class TestCase (line 583) | class TestCase
class Stream (line 584) | class Stream
type IResultCapture (line 585) | struct IResultCapture
type IRunner (line 586) | struct IRunner
type IGeneratorsForTest (line 587) | struct IGeneratorsForTest
type IConfig (line 588) | struct IConfig
type IContext (line 590) | struct IContext
type IMutableContext (line 601) | struct IMutableContext : IContext
class TestSpec (line 626) | class TestSpec
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type ITestCase (line 628) | struct ITestCase : IShared {
class TestCase (line 634) | class TestCase
type IConfig (line 635) | struct IConfig
type ITestCaseRegistry (line 637) | struct ITestCaseRegistry {
class MethodTestCase (line 652) | class MethodTestCase : public SharedImpl<ITestCase> {
method MethodTestCase (line 655) | MethodTestCase( void (C::*method)() ) : m_method( method ) {}
method invoke (line 657) | virtual void invoke() const {
type NameAndDesc (line 670) | struct NameAndDesc {
method NameAndDesc (line 671) | NameAndDesc( const char* _name = "", const char* _description= "" )
type AutoReg (line 685) | struct AutoReg {
method AutoReg (line 693) | AutoReg
type ResultWas (line 791) | struct ResultWas { enum OfType {
type OfType (line 791) | enum OfType {
function isOk (line 811) | inline bool isOk( ResultWas::OfType resultType ) {
function isJustInfo (line 814) | inline bool isJustInfo( int flags ) {
type ResultDisposition (line 819) | struct ResultDisposition { enum Flags {
type Flags (line 819) | enum Flags {
function shouldContinueOnFailure (line 831) | inline bool shouldContinueOnFailure( int flags ) { return ( flags &...
function isFalseTest (line 832) | inline bool isFalseTest( int flags ) { return ( flags &...
function shouldSuppressFailure (line 833) | inline bool shouldSuppressFailure( int flags ) { return ( flags &...
type AssertionInfo (line 844) | struct AssertionInfo
method AssertionInfo (line 846) | AssertionInfo() {}
type AssertionResultData (line 858) | struct AssertionResultData
method AssertionResultData (line 860) | AssertionResultData() : resultType( ResultWas::Unknown ) {}
class AssertionResult (line 867) | class AssertionResult {
method AssertionResult (line 873) | AssertionResult( AssertionResult const& ) = default;
method AssertionResult (line 874) | AssertionResult( AssertionResult && ) = default;
method AssertionResult (line 875) | AssertionResult& operator = ( AssertionResult const& ) = default;
method AssertionResult (line 876) | AssertionResult& operator = ( AssertionResult && ) = default;
type Matchers (line 903) | namespace Matchers {
type Impl (line 904) | namespace Impl {
type Generic (line 906) | namespace Generic {
class AllOf (line 907) | class AllOf
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 908) | class AnyOf
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
class Not (line 909) | class Not
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class Not (line 937) | class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class AllOf (line 954) | class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 994) | class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
type Matcher (line 913) | struct Matcher : SharedImpl<IShared>
type MatcherImpl (line 928) | struct MatcherImpl : Matcher<ExpressionT> {
method clone (line 930) | virtual Ptr<Matcher<ExpressionT> > clone() const {
type Generic (line 935) | namespace Generic {
class AllOf (line 907) | class AllOf
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 908) | class AnyOf
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
class Not (line 909) | class Not
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class Not (line 937) | class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class AllOf (line 954) | class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 994) | class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
type StdString (line 1056) | namespace StdString {
function makeString (line 1058) | inline std::string makeString( std::string const& str ) { return...
function makeString (line 1059) | inline std::string makeString( const char* str ) { return str ? ...
type CasedString (line 1061) | struct CasedString
method CasedString (line 1063) | CasedString( std::string const& str, CaseSensitive::Choice cas...
method adjustString (line 1067) | std::string adjustString( std::string const& str ) const {
method toStringSuffix (line 1073) | std::string toStringSuffix() const
type Equals (line 1083) | struct Equals : MatcherImpl<Equals, std::string> {
method Equals (line 1084) | Equals( std::string const& str, CaseSensitive::Choice caseSens...
method Equals (line 1087) | Equals( Equals const& other ) : m_data( other.m_data ){}
method match (line 1091) | virtual bool match( std::string const& expr ) const {
method toString (line 1094) | virtual std::string toString() const {
type Contains (line 1101) | struct Contains : MatcherImpl<Contains, std::string> {
method Contains (line 1102) | Contains( std::string const& substr, CaseSensitive::Choice cas...
method Contains (line 1104) | Contains( Contains const& other ) : m_data( other.m_data ){}
method match (line 1108) | virtual bool match( std::string const& expr ) const {
method toString (line 1111) | virtual std::string toString() const {
type StartsWith (line 1118) | struct StartsWith : MatcherImpl<StartsWith, std::string> {
method StartsWith (line 1119) | StartsWith( std::string const& substr, CaseSensitive::Choice c...
method StartsWith (line 1122) | StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
method match (line 1126) | virtual bool match( std::string const& expr ) const {
method toString (line 1129) | virtual std::string toString() const {
type EndsWith (line 1136) | struct EndsWith : MatcherImpl<EndsWith, std::string> {
method EndsWith (line 1137) | EndsWith( std::string const& substr, CaseSensitive::Choice cas...
method EndsWith (line 1139) | EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
method match (line 1143) | virtual bool match( std::string const& expr ) const {
method toString (line 1146) | virtual std::string toString() const {
function Not (line 1158) | inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<Expression...
function AllOf (line 1163) | inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<Expres...
function AllOf (line 1168) | inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<Expres...
function AnyOf (line 1174) | inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<Expres...
function AnyOf (line 1179) | inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<Expres...
function Equals (line 1185) | inline Impl::StdString::Equals Equals( std::string const& str, ...
function Equals (line 1188) | inline Impl::StdString::Equals Equals( const char* str, CaseSen...
function Contains (line 1191) | inline Impl::StdString::Contains Contains( std::string const& sub...
function Contains (line 1194) | inline Impl::StdString::Contains Contains( const char* substr, Ca...
function StartsWith (line 1197) | inline Impl::StdString::StartsWith StartsWith( std::string const& s...
function StartsWith (line 1200) | inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
function EndsWith (line 1203) | inline Impl::StdString::EndsWith EndsWith( std::string const& sub...
function EndsWith (line 1206) | inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
type TestFailureException (line 1218) | struct TestFailureException{}
class ExpressionLhs (line 1220) | class ExpressionLhs
method ExpressionLhs (line 1814) | ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
method ExpressionLhs (line 1818) | ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
method ExpressionLhs (line 1820) | ExpressionLhs( ExpressionLhs const& ) = default;
method ExpressionLhs (line 1821) | ExpressionLhs( ExpressionLhs && ) = default;
method ResultBuilder (line 1825) | ResultBuilder& operator == ( RhsT const& rhs ) {
method ResultBuilder (line 1830) | ResultBuilder& operator != ( RhsT const& rhs ) {
method ResultBuilder (line 1835) | ResultBuilder& operator < ( RhsT const& rhs ) {
method ResultBuilder (line 1840) | ResultBuilder& operator > ( RhsT const& rhs ) {
method ResultBuilder (line 1845) | ResultBuilder& operator <= ( RhsT const& rhs ) {
method ResultBuilder (line 1850) | ResultBuilder& operator >= ( RhsT const& rhs ) {
method ResultBuilder (line 1854) | ResultBuilder& operator == ( bool rhs ) {
method ResultBuilder (line 1858) | ResultBuilder& operator != ( bool rhs ) {
method endExpression (line 1862) | void endExpression() {
method ResultBuilder (line 1881) | ResultBuilder& captureExpression( RhsT const& rhs ) {
type STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison (line 1222) | struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_C...
type CopyableStream (line 1224) | struct CopyableStream {
method CopyableStream (line 1225) | CopyableStream() {}
method CopyableStream (line 1226) | CopyableStream( CopyableStream const& other ) {
method CopyableStream (line 1229) | CopyableStream& operator=( CopyableStream const& other ) {
class ResultBuilder (line 1237) | class ResultBuilder {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
type Internal (line 1310) | namespace Internal {
type Operator (line 1312) | enum Operator {
type OperatorTraits (line 1321) | struct OperatorTraits { static const char* getName(){ re...
type OperatorTraits<IsEqualTo> (line 1322) | struct OperatorTraits<IsEqualTo> { static const char* ge...
type OperatorTraits<IsNotEqualTo> (line 1323) | struct OperatorTraits<IsNotEqualTo> { static const char* ge...
type OperatorTraits<IsLessThan> (line 1324) | struct OperatorTraits<IsLessThan> { static const char* ge...
type OperatorTraits<IsGreaterThan> (line 1325) | struct OperatorTraits<IsGreaterThan> { static const char* ge...
type OperatorTraits<IsLessThanOrEqualTo> (line 1326) | struct OperatorTraits<IsLessThanOrEqualTo> { static const char* ge...
type OperatorTraits<IsGreaterThanOrEqualTo> (line 1327) | struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* ge...
function T (line 1330) | inline T& opCast(T const& t) { return const_cast<T&>(t); }
function opCast (line 1334) | inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
class Evaluator (line 1340) | class Evaluator{}
type Evaluator<T1, T2, IsEqualTo> (line 1343) | struct Evaluator<T1, T2, IsEqualTo> {
method evaluate (line 1344) | static bool evaluate( T1 const& lhs, T2 const& rhs) {
type Evaluator<T1, T2, IsNotEqualTo> (line 1349) | struct Evaluator<T1, T2, IsNotEqualTo> {
method evaluate (line 1350) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsLessThan> (line 1355) | struct Evaluator<T1, T2, IsLessThan> {
method evaluate (line 1356) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsGreaterThan> (line 1361) | struct Evaluator<T1, T2, IsGreaterThan> {
method evaluate (line 1362) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsGreaterThanOrEqualTo> (line 1367) | struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
method evaluate (line 1368) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsLessThanOrEqualTo> (line 1373) | struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
method evaluate (line 1374) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
function applyEvaluator (line 1380) | bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
function compare (line 1389) | bool compare( T1 const& lhs, T2 const& rhs ) {
function compare (line 1394) | bool compare( unsigned int lhs, int rhs ) {
function compare (line 1397) | bool compare( unsigned long lhs, int rhs ) {
function compare (line 1400) | bool compare( unsigned char lhs, int rhs ) {
function compare (line 1405) | bool compare( unsigned int lhs, long rhs ) {
function compare (line 1408) | bool compare( unsigned long lhs, long rhs ) {
function compare (line 1411) | bool compare( unsigned char lhs, long rhs ) {
function compare (line 1416) | bool compare( int lhs, unsigned int rhs ) {
function compare (line 1419) | bool compare( int lhs, unsigned long rhs ) {
function compare (line 1422) | bool compare( int lhs, unsigned char rhs ) {
function compare (line 1427) | bool compare( long lhs, unsigned int rhs ) {
function compare (line 1430) | bool compare( long lhs, unsigned long rhs ) {
function compare (line 1433) | bool compare( long lhs, unsigned char rhs ) {
function compare (line 1438) | bool compare( long lhs, T* rhs ) {
function compare (line 1441) | bool compare( T* lhs, long rhs ) {
function compare (line 1446) | bool compare( int lhs, T* rhs ) {
function compare (line 1449) | bool compare( T* lhs, int rhs ) {
function compare (line 1455) | bool compare( long long lhs, unsigned int rhs ) {
function compare (line 1458) | bool compare( long long lhs, unsigned long rhs ) {
function compare (line 1461) | bool compare( long long lhs, unsigned long long rhs ) {
function compare (line 1464) | bool compare( long long lhs, unsigned char rhs ) {
function compare (line 1469) | bool compare( unsigned long long lhs, int rhs ) {
function compare (line 1472) | bool compare( unsigned long long lhs, long rhs ) {
function compare (line 1475) | bool compare( unsigned long long lhs, long long rhs ) {
function compare (line 1478) | bool compare( unsigned long long lhs, char rhs ) {
function compare (line 1483) | bool compare( long long lhs, T* rhs ) {
function compare (line 1486) | bool compare( T* lhs, long long rhs ) {
function compare (line 1493) | bool compare( std::nullptr_t, T* rhs ) {
function compare (line 1496) | bool compare( T* lhs, std::nullptr_t ) {
type Detail (line 1610) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
type StringMaker (line 1687) | struct StringMaker :
type StringMaker<T*> (line 1691) | struct StringMaker<T*> {
method convert (line 1693) | static std::string convert( U* p ) {
type StringMaker<R C::*> (line 1702) | struct StringMaker<R C::*> {
method convert (line 1703) | static std::string convert( R C::* p ) {
type Detail (line 1711) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
function toString (line 1724) | std::string toString( std::vector<T,Allocator> const& v ) {
type TupleDetail (line 1731) | namespace TupleDetail {
type ElementPrinter (line 1737) | struct ElementPrinter {
method print (line 1738) | static void print( const Tuple& tuple, std::ostream& os )
type ElementPrinter<Tuple,N,false> (line 1750) | struct ElementPrinter<Tuple,N,false> {
method print (line 1751) | static void print( const Tuple&, std::ostream& ) {}
type Detail (line 1770) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
function toString (line 1785) | std::string toString( T const& value ) {
type Detail (line 1789) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
class ExpressionLhs (line 1811) | class ExpressionLhs {
method ExpressionLhs (line 1814) | ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
method ExpressionLhs (line 1818) | ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
method ExpressionLhs (line 1820) | ExpressionLhs( ExpressionLhs const& ) = default;
method ExpressionLhs (line 1821) | ExpressionLhs( ExpressionLhs && ) = default;
method ResultBuilder (line 1825) | ResultBuilder& operator == ( RhsT const& rhs ) {
method ResultBuilder (line 1830) | ResultBuilder& operator != ( RhsT const& rhs ) {
method ResultBuilder (line 1835) | ResultBuilder& operator < ( RhsT const& rhs ) {
method ResultBuilder (line 1840) | ResultBuilder& operator > ( RhsT const& rhs ) {
method ResultBuilder (line 1845) | ResultBuilder& operator <= ( RhsT const& rhs ) {
method ResultBuilder (line 1850) | ResultBuilder& operator >= ( RhsT const& rhs ) {
method ResultBuilder (line 1854) | ResultBuilder& operator == ( bool rhs ) {
method ResultBuilder (line 1858) | ResultBuilder& operator != ( bool rhs ) {
method endExpression (line 1862) | void endExpression() {
method ResultBuilder (line 1881) | ResultBuilder& captureExpression( RhsT const& rhs ) {
type MessageInfo (line 1917) | struct MessageInfo {
type MessageBuilder (line 1938) | struct MessageBuilder {
method MessageBuilder (line 1939) | MessageBuilder( std::string const& macroName,
method MessageBuilder (line 1946) | MessageBuilder& operator << ( T const& value ) {
class ScopedMessage (line 1955) | class ScopedMessage {
class TestCase (line 1973) | class TestCase
class AssertionResult (line 1974) | class AssertionResult
method AssertionResult (line 873) | AssertionResult( AssertionResult const& ) = default;
method AssertionResult (line 874) | AssertionResult( AssertionResult && ) = default;
method AssertionResult (line 875) | AssertionResult& operator = ( AssertionResult const& ) = default;
method AssertionResult (line 876) | AssertionResult& operator = ( AssertionResult && ) = default;
type AssertionInfo (line 1975) | struct AssertionInfo
method AssertionInfo (line 846) | AssertionInfo() {}
type SectionInfo (line 1976) | struct SectionInfo
type SectionEndInfo (line 1977) | struct SectionEndInfo
method SectionEndInfo (line 2298) | SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prev...
type MessageInfo (line 1978) | struct MessageInfo
class ScopedMessageBuilder (line 1979) | class ScopedMessageBuilder
type Counts (line 1980) | struct Counts
method Counts (line 2222) | Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
method Counts (line 2224) | Counts operator - ( Counts const& other ) const {
method Counts (line 2231) | Counts& operator += ( Counts const& other ) {
method total (line 2238) | std::size_t total() const {
method allPassed (line 2241) | bool allPassed() const {
method allOk (line 2244) | bool allOk() const {
type IResultCapture (line 1982) | struct IResultCapture {
class TestCase (line 2075) | class TestCase
type IRunner (line 2077) | struct IRunner {
type Counts (line 2221) | struct Counts {
method Counts (line 2222) | Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
method Counts (line 2224) | Counts operator - ( Counts const& other ) const {
method Counts (line 2231) | Counts& operator += ( Counts const& other ) {
method total (line 2238) | std::size_t total() const {
method allPassed (line 2241) | bool allPassed() const {
method allOk (line 2244) | bool allOk() const {
type Totals (line 2253) | struct Totals {
method Totals (line 2255) | Totals operator - ( Totals const& other ) const {
method Totals (line 2262) | Totals delta( Totals const& prevTotals ) const {
method Totals (line 2273) | Totals& operator += ( Totals const& other ) {
type SectionInfo (line 2286) | struct SectionInfo {
type SectionEndInfo (line 2297) | struct SectionEndInfo {
method SectionEndInfo (line 2298) | SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prev...
class Timer (line 2320) | class Timer {
method Timer (line 2322) | Timer() : m_ticks( 0 ) {}
class Section (line 2338) | class Section : NonCopyable {
type IGenerator (line 2376) | struct IGenerator {
class BetweenGenerator (line 2383) | class BetweenGenerator : public IGenerator<T> {
method BetweenGenerator (line 2385) | BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
method T (line 2387) | virtual T getValue( std::size_t index ) const {
method size (line 2391) | virtual std::size_t size() const {
class ValuesGenerator (line 2402) | class ValuesGenerator : public IGenerator<T> {
method ValuesGenerator (line 2404) | ValuesGenerator(){}
method add (line 2406) | void add( T value ) {
method T (line 2410) | virtual T getValue( std::size_t index ) const {
method size (line 2414) | virtual std::size_t size() const {
class CompositeGenerator (line 2423) | class CompositeGenerator {
method CompositeGenerator (line 2425) | CompositeGenerator() : m_totalSize( 0 ) {}
method CompositeGenerator (line 2428) | CompositeGenerator( CompositeGenerator& other )
method CompositeGenerator (line 2435) | CompositeGenerator& setFileInfo( const char* fileInfo ) {
method add (line 2462) | void add( const IGenerator<T>* generator ) {
method CompositeGenerator (line 2467) | CompositeGenerator& then( CompositeGenerator& other ) {
method CompositeGenerator (line 2472) | CompositeGenerator& then( T value ) {
method move (line 2481) | void move( CompositeGenerator& other ) {
type Generators (line 2492) | namespace Generators
function between (line 2495) | CompositeGenerator<T> between( T from, T to ) {
function values (line 2502) | CompositeGenerator<T> values( T val1, T val2 ) {
function values (line 2512) | CompositeGenerator<T> values( T val1, T val2, T val3 ){
function values (line 2523) | CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
class TestCase (line 2558) | class TestCase
type ITestCaseRegistry (line 2559) | struct ITestCaseRegistry
type IExceptionTranslatorRegistry (line 2560) | struct IExceptionTranslatorRegistry
type IExceptionTranslator (line 2561) | struct IExceptionTranslator
type IReporterRegistry (line 2562) | struct IReporterRegistry
type IReporterFactory (line 2563) | struct IReporterFactory
type IRegistryHub (line 2565) | struct IRegistryHub {
type IMutableRegistryHub (line 2573) | struct IMutableRegistryHub {
type IExceptionTranslator (line 2592) | struct IExceptionTranslator
type IExceptionTranslator (line 2595) | struct IExceptionTranslator {
type IExceptionTranslatorRegistry (line 2600) | struct IExceptionTranslatorRegistry {
class ExceptionTranslatorRegistrar (line 2606) | class ExceptionTranslatorRegistrar {
class ExceptionTranslator (line 2608) | class ExceptionTranslator : public IExceptionTranslator {
method ExceptionTranslator (line 2611) | ExceptionTranslator( std::string(*translateFunction)( T& ) )
method translate (line 2615) | virtual std::string translate( ExceptionTranslators::const_iterato...
method ExceptionTranslatorRegistrar (line 2633) | ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
type Detail (line 2655) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
type TagAlias (line 2759) | struct TagAlias {
method TagAlias (line 2760) | TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag )...
type RegistrarForTagAliases (line 2766) | struct RegistrarForTagAliases {
class Option (line 2780) | class Option {
method Option (line 2782) | Option() : nullableValue( CATCH_NULL ) {}
method Option (line 2783) | Option( T const& _value )
method Option (line 2786) | Option( Option const& _other )
method Option (line 2794) | Option& operator= ( Option const& _other ) {
method Option (line 2802) | Option& operator = ( T const& _value ) {
method reset (line 2808) | void reset() {
method T (line 2814) | T& operator*() { return *nullableValue; }
method T (line 2815) | T const& operator*() const { return *nullableValue; }
method T (line 2816) | T* operator->() { return nullableValue; }
method T (line 2817) | const T* operator->() const { return nullableValue; }
method T (line 2819) | T valueOr( T const& defaultValue ) const {
method some (line 2823) | bool some() const { return nullableValue != CATCH_NULL; }
method none (line 2824) | bool none() const { return nullableValue == CATCH_NULL; }
type ITagAliasRegistry (line 2840) | struct ITagAliasRegistry {
type ITestCase (line 2865) | struct ITestCase
type TestCaseInfo (line 2867) | struct TestCaseInfo {
type SpecialProperties (line 2868) | enum SpecialProperties{
class TestCase (line 2901) | class TestCase : public TestCaseInfo {
class WildcardPattern (line 3170) | class WildcardPattern {
type WildcardPosition (line 3171) | enum WildcardPosition {
method WildcardPattern (line 3180) | WildcardPattern( std::string const& pattern, CaseSensitive::Choice c...
method matches (line 3195) | virtual bool matches( std::string const& str ) const {
method adjustCase (line 3217) | std::string adjustCase( std::string const& str ) const {
class TestSpec (line 3231) | class TestSpec {
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
class TestSpecParser (line 3307) | class TestSpecParser {
type Mode (line 3308) | enum Mode{ None, Name, QuotedName, Tag, EscapedName }
method TestSpecParser (line 3319) | TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases...
method TestSpecParser (line 3321) | TestSpecParser& parse( std::string const& arg ) {
method TestSpec (line 3333) | TestSpec testSpec() {
method visitChar (line 3338) | void visitChar( char c ) {
method startNewMode (line 3371) | void startNewMode( Mode mode, std::size_t start ) {
method escape (line 3375) | void escape() {
method subString (line 3379) | std::string subString() const { return m_arg.substr( m_start, m_pos ...
method addPattern (line 3381) | void addPattern() {
method addFilter (line 3399) | void addFilter() {
function TestSpec (line 3406) | inline TestSpec parseTestSpec( std::string const& arg ) {
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type Verbosity (line 3425) | struct Verbosity { enum Level {
type Level (line 3425) | enum Level {
type WarnAbout (line 3431) | struct WarnAbout { enum What {
type What (line 3431) | enum What {
type ShowDurations (line 3436) | struct ShowDurations { enum OrNot {
type OrNot (line 3436) | enum OrNot {
type RunTests (line 3441) | struct RunTests { enum InWhatOrder {
type InWhatOrder (line 3441) | enum InWhatOrder {
type UseColour (line 3446) | struct UseColour { enum YesOrNo {
type YesOrNo (line 3446) | enum YesOrNo {
class TestSpec (line 3452) | class TestSpec
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type IConfig (line 3454) | struct IConfig : IShared {
class StreamBufBase (line 3484) | class StreamBufBase : public std::streambuf {
type IStream (line 3500) | struct IStream {
class FileStream (line 3505) | class FileStream : public IStream {
class CoutStream (line 3514) | class CoutStream : public IStream {
class DebugOutStream (line 3524) | class DebugOutStream : public IStream {
type ConfigData (line 3548) | struct ConfigData {
method ConfigData (line 3550) | ConfigData()
class Config (line 3599) | class Config : public SharedImpl<IConfig> {
method Config (line 3606) | Config()
method Config (line 3609) | Config( ConfigData const& data )
method listTests (line 3628) | bool listTests() const { return m_data.listTests; }
method listTestNamesOnly (line 3629) | bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
method listTags (line 3630) | bool listTags() const { return m_data.listTags; }
method listReporters (line 3631) | bool listReporters() const { return m_data.listReporters; }
method getProcessName (line 3633) | std::string getProcessName() const { return m_data.processName; }
method shouldDebugBreak (line 3635) | bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
method getReporterNames (line 3637) | std::vector<std::string> getReporterNames() const { return m_data.re...
method abortAfter (line 3639) | int abortAfter() const { return m_data.abortAfter; }
method TestSpec (line 3641) | TestSpec const& testSpec() const { return m_testSpec; }
method showHelp (line 3643) | bool showHelp() const { return m_data.showHelp; }
method showInvisibles (line 3644) | bool showInvisibles() const { return m_data.showInvisibles; }
method allowThrows (line 3647) | virtual bool allowThrows() const { return !m_data.noThrow; }
method name (line 3649) | virtual std::string name() const { return m_data.name.empty()...
method includeSuccessfulResults (line 3650) | virtual bool includeSuccessfulResults() const { return m_data.show...
method warnAboutMissingAssertions (line 3651) | virtual bool warnAboutMissingAssertions() const { return m_data.warn...
method showDurations (line 3652) | virtual ShowDurations::OrNot showDurations() const { return m_data.s...
method runOrder (line 3653) | virtual RunTests::InWhatOrder runOrder() const { return m_data.runO...
method rngSeed (line 3654) | virtual unsigned int rngSeed() const { return m_data.rngSeed; }
method useColour (line 3655) | virtual UseColour::YesOrNo useColour() const { return m_data.useColo...
method IStream (line 3659) | IStream const* openStream() {
function abortAfterFirst (line 4720) | inline void abortAfterFirst( ConfigData& config ) { config.abortAfter ...
function abortAfterX (line 4721) | inline void abortAfterX( ConfigData& config, int x ) {
function addTestOrTags (line 4726) | inline void addTestOrTags( ConfigData& config, std::string const& _tes...
function addReporterName (line 4727) | inline void addReporterName( ConfigData& config, std::string const& _r...
function addWarning (line 4729) | inline void addWarning( ConfigData& config, std::string const& _warnin...
function setOrder (line 4735) | inline void setOrder( ConfigData& config, std::string const& order ) {
function setRngSeed (line 4745) | inline void setRngSeed( ConfigData& config, std::string const& seed ) {
function setVerbosity (line 4757) | inline void setVerbosity( ConfigData& config, int level ) {
function setShowDurations (line 4761) | inline void setShowDurations( ConfigData& config, bool _showDurations ) {
function setUseColour (line 4766) | inline void setUseColour( ConfigData& config, std::string const& value...
function forceColour (line 4778) | inline void forceColour( ConfigData& config ) {
function loadTestNamesFromFile (line 4781) | inline void loadTestNamesFromFile( ConfigData& config, std::string con...
function makeCommandLineParser (line 4797) | inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
type Colour (line 5078) | struct Colour {
type Code (line 5079) | enum Code {
type ReporterConfig (line 5140) | struct ReporterConfig {
method ReporterConfig (line 5141) | explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
method ReporterConfig (line 5144) | ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream&...
method fullConfig (line 5148) | Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
type ReporterPreferences (line 5155) | struct ReporterPreferences {
method ReporterPreferences (line 5156) | ReporterPreferences()
type LazyStat (line 5164) | struct LazyStat : Option<T> {
method LazyStat (line 5165) | LazyStat() : used( false ) {}
method LazyStat (line 5166) | LazyStat& operator=( T const& _value ) {
method reset (line 5171) | void reset() {
type TestRunInfo (line 5178) | struct TestRunInfo {
method TestRunInfo (line 5179) | TestRunInfo( std::string const& _name ) : name( _name ) {}
type GroupInfo (line 5182) | struct GroupInfo {
method GroupInfo (line 5183) | GroupInfo( std::string const& _name,
type AssertionStats (line 5196) | struct AssertionStats {
method AssertionStats (line 5197) | AssertionStats( AssertionResult const& _assertionResult,
method AssertionStats (line 5217) | AssertionStats( AssertionStats const& ) = default;
method AssertionStats (line 5218) | AssertionStats( AssertionStats && ) = default;
method AssertionStats (line 5219) | AssertionStats& operator = ( AssertionStats const& ) = default;
method AssertionStats (line 5220) | AssertionStats& operator = ( AssertionStats && ) = default;
type SectionStats (line 5228) | struct SectionStats {
method SectionStats (line 5229) | SectionStats( SectionInfo const& _sectionInfo,
method SectionStats (line 5240) | SectionStats( SectionStats const& ) = default;
method SectionStats (line 5241) | SectionStats( SectionStats && ) = default;
method SectionStats (line 5242) | SectionStats& operator = ( SectionStats const& ) = default;
method SectionStats (line 5243) | SectionStats& operator = ( SectionStats && ) = default;
type TestCaseStats (line 5252) | struct TestCaseStats {
method TestCaseStats (line 5253) | TestCaseStats( TestCaseInfo const& _testInfo,
method TestCaseStats (line 5267) | TestCaseStats( TestCaseStats const& ) = default;
method TestCaseStats (line 5268) | TestCaseStats( TestCaseStats && ) = default;
method TestCaseStats (line 5269) | TestCaseStats& operator = ( TestCaseStats const& ) = default;
method TestCaseStats (line 5270) | TestCaseStats& operator = ( TestCaseStats && ) = default;
type TestGroupStats (line 5280) | struct TestGroupStats {
method TestGroupStats (line 5281) | TestGroupStats( GroupInfo const& _groupInfo,
method TestGroupStats (line 5288) | TestGroupStats( GroupInfo const& _groupInfo )
method TestGroupStats (line 5295) | TestGroupStats( TestGroupStats const& ) = default;
method TestGroupStats (line 5296) | TestGroupStats( TestGroupStats && ) = default;
method TestGroupStats (line 5297) | TestGroupStats& operator = ( TestGroupStats const& ) = default;
method TestGroupStats (line 5298) | TestGroupStats& operator = ( TestGroupStats && ) = default;
type TestRunStats (line 5306) | struct TestRunStats {
method TestRunStats (line 5307) | TestRunStats( TestRunInfo const& _runInfo,
method TestRunStats (line 5317) | TestRunStats( TestRunStats const& _other )
method TestRunStats (line 5323) | TestRunStats( TestRunStats const& ) = default;
method TestRunStats (line 5324) | TestRunStats( TestRunStats && ) = default;
method TestRunStats (line 5325) | TestRunStats& operator = ( TestRunStats const& ) = default;
method TestRunStats (line 5326) | TestRunStats& operator = ( TestRunStats && ) = default;
class MultipleReporters (line 5334) | class MultipleReporters
method add (line 8574) | void add( Ptr<IStreamingReporter> const& reporter ) {
method ReporterPreferences (line 8580) | virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
method noMatchingTestCases (line 8584) | virtual void noMatchingTestCases( std::string const& spec ) CATCH_OV...
method testRunStarting (line 8591) | virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH...
method testGroupStarting (line 8598) | virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_O...
method testCaseStarting (line 8605) | virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_...
method sectionStarting (line 8612) | virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH...
method assertionStarting (line 8619) | virtual void assertionStarting( AssertionInfo const& assertionInfo )...
method assertionEnded (line 8627) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method sectionEnded (line 8636) | virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_...
method testCaseEnded (line 8643) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 8650) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEnded (line 8657) | virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_...
method skipTest (line 8664) | virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
method MultipleReporters (line 8671) | virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
type IStreamingReporter (line 5336) | struct IStreamingReporter : IShared {
method MultipleReporters (line 5364) | virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
type IReporterFactory (line 5367) | struct IReporterFactory : IShared {
type IReporterRegistry (line 5373) | struct IReporterRegistry {
function listTests (line 5392) | inline std::size_t listTests( Config const& config ) {
function listTestsNamesOnly (line 5430) | inline std::size_t listTestsNamesOnly( Config const& config ) {
type TagInfo (line 5449) | struct TagInfo {
method TagInfo (line 5450) | TagInfo() : count ( 0 ) {}
method add (line 5451) | void add( std::string const& spelling ) {
method all (line 5455) | std::string all() const {
function listTags (line 5467) | inline std::size_t listTags( Config const& config ) {
function listReporters (line 5511) | inline std::size_t listReporters( Config const& /*config*/ ) {
function list (line 5534) | inline Option<std::size_t> list( Config const& config ) {
type TestCaseTracking (line 5561) | namespace TestCaseTracking {
type ITracker (line 5563) | struct ITracker : SharedImpl<> {
class TrackerContext (line 5591) | class TrackerContext {
type RunState (line 5593) | enum RunState {
method TrackerContext (line 5605) | static TrackerContext& instance() {
method TrackerContext (line 5610) | TrackerContext()
method endRun (line 5617) | void endRun() {
method startCycle (line 5623) | void startCycle() {
method completeCycle (line 5627) | void completeCycle() {
method completedCycle (line 5631) | bool completedCycle() const {
method ITracker (line 5634) | ITracker& currentTracker() {
method setCurrentTracker (line 5637) | void setCurrentTracker( ITracker* tracker ) {
class TrackerBase (line 5642) | class TrackerBase : public ITracker {
type CycleState (line 5644) | enum CycleState {
class TrackerHasName (line 5652) | class TrackerHasName {
method TrackerHasName (line 5655) | TrackerHasName( std::string const& name ) : m_name( name ) {}
method TrackerBase (line 5667) | TrackerBase( std::string const& name, TrackerContext& ctx, ITracke...
method isComplete (line 5678) | virtual bool isComplete() const CATCH_OVERRIDE {
method isSuccessfullyCompleted (line 5681) | virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
method isOpen (line 5684) | virtual bool isOpen() const CATCH_OVERRIDE {
method hasChildren (line 5687) | virtual bool hasChildren() const CATCH_OVERRIDE {
method addChild (line 5691) | virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
method ITracker (line 5695) | virtual ITracker* findChild( std::string const& name ) CATCH_OVERR...
method ITracker (line 5701) | virtual ITracker& parent() CATCH_OVERRIDE {
method isSectionTracker (line 5714) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return fals...
method isIndexTracker (line 5715) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
method open (line 5717) | void open() {
method markAsNeedingAnotherRun (line 5760) | virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
method moveToParent (line 5764) | void moveToParent() {
method moveToThis (line 5768) | void moveToThis() {
class SectionTracker (line 5773) | class SectionTracker : public TrackerBase {
method SectionTracker (line 5775) | SectionTracker( std::string const& name, TrackerContext& ctx, ITra...
method isSectionTracker (line 5780) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
method SectionTracker (line 5782) | static SectionTracker& acquire( TrackerContext& ctx, std::string c...
class IndexTracker (line 5803) | class IndexTracker : public TrackerBase {
method IndexTracker (line 5807) | IndexTracker( std::string const& name, TrackerContext& ctx, ITrack...
method isIndexTracker (line 5814) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
method IndexTracker (line 5816) | static IndexTracker& acquire( TrackerContext& ctx, std::string con...
method index (line 5839) | int index() const { return m_index; }
method moveNext (line 5841) | void moveNext() {
function ITracker (line 5853) | inline ITracker& TrackerContext::startRun() {
function fatal (line 5875) | inline void fatal( std::string const& message, int exitCode ) {
type FatalConditionHandler (line 5890) | struct FatalConditionHandler {
method reset (line 5891) | void reset() {}
method handleSignal (line 5915) | static void handleSignal( int sig ) {
method FatalConditionHandler (line 5922) | FatalConditionHandler() : m_isSet( true ) {
method reset (line 5929) | void reset() {
type SignalDefs (line 5902) | struct SignalDefs { int id; const char* name; }
type FatalConditionHandler (line 5913) | struct FatalConditionHandler {
method reset (line 5891) | void reset() {}
method handleSignal (line 5915) | static void handleSignal( int sig ) {
method FatalConditionHandler (line 5922) | FatalConditionHandler() : m_isSet( true ) {
method reset (line 5929) | void reset() {
class StreamRedirect (line 5949) | class StreamRedirect {
method StreamRedirect (line 5952) | StreamRedirect( std::ostream& stream, std::string& targetString )
class RunContext (line 5974) | class RunContext : public IResultCapture, public IRunner {
method RunContext (line 5981) | explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreami...
method testGroupStarting (line 5998) | void testGroupStarting( std::string const& testSpec, std::size_t gro...
method testGroupEnded (line 6001) | void testGroupEnded( std::string const& testSpec, Totals const& tota...
method Totals (line 6005) | Totals runTest( TestCase const& testCase ) {
method config (line 6048) | Ptr<IConfig const> config() const {
method assertionEnded (line 6054) | virtual void assertionEnded( AssertionResult const& result ) {
method sectionStarted (line 6070) | virtual bool sectionStarted (
method testForMissingAssertions (line 6091) | bool testForMissingAssertions( Counts& assertions ) {
method sectionEnded (line 6103) | virtual void sectionEnded( SectionEndInfo const& endInfo ) {
method sectionEndedEarly (line 6116) | virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) {
method pushScopedMessage (line 6126) | virtual void pushScopedMessage( MessageInfo const& message ) {
method popScopedMessage (line 6130) | virtual void popScopedMessage( MessageInfo const& message ) {
method getCurrentTestName (line 6134) | virtual std::string getCurrentTestName() const {
method AssertionResult (line 6140) | virtual const AssertionResult* getLastResult() const {
method handleFatalErrorCondition (line 6144) | virtual void handleFatalErrorCondition( std::string const& message ) {
method aborting (line 6177) | bool aborting() const {
method runCurrentTest (line 6183) | void runCurrentTest( std::string& redirectedCout, std::string& redir...
method invokeActiveTestCase (line 6229) | void invokeActiveTestCase() {
method ResultBuilder (line 6237) | ResultBuilder makeUnexpectedResultBuilder() const {
method handleUnfinishedSections (line 6244) | void handleUnfinishedSections() {
function IResultCapture (line 6272) | IResultCapture& getResultCapture() {
type Version (line 6287) | struct Version {
function createReporter (line 6317) | Ptr<IStreamingReporter> createReporter( std::string const& reporterNam...
function makeReporter (line 6327) | Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
function addListeners (line 6339) | Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config...
function Totals (line 6348) | Totals runTests( Ptr<Config> const& config ) {
method Totals (line 2255) | Totals operator - ( Totals const& other ) const {
method Totals (line 2262) | Totals delta( Totals const& prevTotals ) const {
method Totals (line 2273) | Totals& operator += ( Totals const& other ) {
function applyFilenamesAsTags (line 6379) | void applyFilenamesAsTags( IConfig const& config ) {
class Session (line 6399) | class Session : NonCopyable {
type OnUnusedOptions (line 6404) | struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }
type DoWhat (line 6404) | enum DoWhat { Ignore, Fail }
method Session (line 6406) | Session()
method showHelp (line 6419) | void showHelp( std::string const& processName ) {
method applyCommandLine (line 6426) | int applyCommandLine( int argc, char const* const* const argv, OnUnu...
method useConfigData (line 6448) | void useConfigData( ConfigData const& _configData ) {
method run (line 6453) | int run( int argc, char const* const* const argv ) {
method run (line 6461) | int run() {
method ConfigData (line 6492) | ConfigData& configData() {
method Config (line 6495) | Config& config() {
type RandomNumberGenerator (line 6525) | struct RandomNumberGenerator {
method result_type (line 6528) | result_type operator()( result_type n ) const { return std::rand() %...
method result_type (line 6531) | static constexpr result_type min() { return 0; }
method result_type (line 6532) | static constexpr result_type max() { return 1000000; }
method result_type (line 6533) | result_type operator()() const { return std::rand() % max(); }
method shuffle (line 6536) | static void shuffle( V& vector ) {
function sortTests (line 6546) | inline std::vector<TestCase> sortTests( IConfig const& config, std::ve...
function matchTest (line 6566) | bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IC...
function enforceNoDuplicateTestCases (line 6570) | void enforceNoDuplicateTestCases( std::vector<TestCase> const& functio...
function filterTests (line 6589) | std::vector<TestCase> filterTests( std::vector<TestCase> const& testCa...
class TestRegistry (line 6603) | class TestRegistry : public ITestCaseRegistry {
method TestRegistry (line 6605) | TestRegistry()
method registerTest (line 6611) | virtual void registerTest( TestCase const& testCase ) {
class FreeFunctionTestCase (line 6645) | class FreeFunctionTestCase : public SharedImpl<ITestCase> {
method FreeFunctionTestCase (line 6648) | FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
method invoke (line 6650) | virtual void invoke() const {
function extractClassName (line 6660) | inline std::string extractClassName( std::string const& classOrQualifi...
function registerTestCase (line 6673) | void registerTestCase
function registerTestCaseFunction (line 6687) | void registerTestCaseFunction
class ReporterRegistry (line 6714) | class ReporterRegistry : public IReporterRegistry {
method IStreamingReporter (line 6720) | virtual IStreamingReporter* create( std::string const& name, Ptr<ICo...
method registerReporter (line 6727) | void registerReporter( std::string const& name, Ptr<IReporterFactory...
method registerListener (line 6730) | void registerListener( Ptr<IReporterFactory> const& factory ) {
method FactoryMap (line 6734) | virtual FactoryMap const& getFactories() const CATCH_OVERRIDE {
method Listeners (line 6737) | virtual Listeners const& getListeners() const CATCH_OVERRIDE {
class ExceptionTranslatorRegistry (line 6756) | class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
method registerTranslator (line 6762) | virtual void registerTranslator( const IExceptionTranslator* transla...
method translateActiveException (line 6766) | virtual std::string translateActiveException() const {
method tryTranslators (line 6797) | std::string tryTranslators() const {
class RegistryHub (line 6813) | class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
method RegistryHub (line 6819) | RegistryHub() {
method IReporterRegistry (line 6821) | virtual IReporterRegistry const& getReporterRegistry() const CATCH_O...
method ITestCaseRegistry (line 6824) | virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_O...
method IExceptionTranslatorRegistry (line 6827) | virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry...
method registerReporter (line 6832) | virtual void registerReporter( std::string const& name, Ptr<IReporte...
method registerListener (line 6835) | virtual void registerListener( Ptr<IReporterFactory> const& factory ...
method registerTest (line 6838) | virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
method registerTranslator (line 6841) | virtual void registerTranslator( const IExceptionTranslator* transla...
function RegistryHub (line 6852) | inline RegistryHub*& getTheRegistryHub() {
method RegistryHub (line 6819) | RegistryHub() {
method IReporterRegistry (line 6821) | virtual IReporterRegistry const& getReporterRegistry() const CATCH_O...
method ITestCaseRegistry (line 6824) | virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_O...
method IExceptionTranslatorRegistry (line 6827) | virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry...
method registerReporter (line 6832) | virtual void registerReporter( std::string const& name, Ptr<IReporte...
method registerListener (line 6835) | virtual void registerListener( Ptr<IReporterFactory> const& factory ...
method registerTest (line 6838) | virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
method registerTranslator (line 6841) | virtual void registerTranslator( const IExceptionTranslator* transla...
function IRegistryHub (line 6860) | IRegistryHub& getRegistryHub() {
function IMutableRegistryHub (line 6863) | IMutableRegistryHub& getMutableRegistryHub() {
function cleanUp (line 6866) | void cleanUp() {
function translateActiveException (line 6871) | std::string translateActiveException() {
class StreamBufImpl (line 6911) | class StreamBufImpl : public StreamBufBase {
method StreamBufImpl (line 6916) | StreamBufImpl() {
method overflow (line 6925) | int overflow( int c ) {
method sync (line 6937) | int sync() {
type OutputDebugWriter (line 6961) | struct OutputDebugWriter {
class Context (line 6999) | class Context : public IMutableContext {
method Context (line 7001) | Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_result...
method IResultCapture (line 7011) | virtual IResultCapture* getResultCapture() {
method IRunner (line 7014) | virtual IRunner* getRunner() {
method getGeneratorIndex (line 7017) | virtual size_t getGeneratorIndex( std::string const& fileInfo, size_...
method advanceGeneratorsForCurrentTest (line 7022) | virtual bool advanceGeneratorsForCurrentTest() {
method getConfig (line 7027) | virtual Ptr<IConfig const> getConfig() const {
method setResultCapture (line 7032) | virtual void setResultCapture( IResultCapture* resultCapture ) {
method setRunner (line 7035) | virtual void setRunner( IRunner* runner ) {
method setConfig (line 7038) | virtual void setConfig( Ptr<IConfig const> const& config ) {
method IGeneratorsForTest (line 7045) | IGeneratorsForTest* findGeneratorsForCurrentTest() {
method IGeneratorsForTest (line 7055) | IGeneratorsForTest& getGeneratorsForCurrentTest() {
function IMutableContext (line 7075) | IMutableContext& getCurrentMutableContext() {
function IContext (line 7080) | IContext& getCurrentContext() {
function cleanUpContext (line 7084) | void cleanUpContext() {
type IColourImpl (line 7096) | struct IColourImpl {
type NoColourImpl (line 7101) | struct NoColourImpl : IColourImpl {
method use (line 7102) | void use( Colour::Code ) {}
method IColourImpl (line 7104) | static IColourImpl* instance() {
class Win32ColourImpl (line 7150) | class Win32ColourImpl : public IColourImpl {
method Win32ColourImpl (line 7152) | Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
method use (line 7160) | virtual void use( Colour::Code _colourCode ) {
method setTextAttribute (line 7181) | void setTextAttribute( WORD _textAttribute ) {
function IColourImpl (line 7189) | IColourImpl* platformColourInstance() {
class PosixColourImpl (line 7219) | class PosixColourImpl : public IColourImpl {
method use (line 7221) | virtual void use( Colour::Code _colourCode ) {
method IColourImpl (line 7240) | static IColourImpl* instance() {
method setColour (line 7246) | void setColour( const char* _escapeCode ) {
function IColourImpl (line 7251) | IColourImpl* platformColourInstance() {
function IColourImpl (line 7272) | static IColourImpl* platformColourInstance() { return NoColourImpl::in...
type GeneratorInfo (line 7300) | struct GeneratorInfo : IGeneratorInfo {
method GeneratorInfo (line 7302) | GeneratorInfo( std::size_t size )
method moveNext (line 7307) | bool moveNext() {
method getCurrentIndex (line 7315) | std::size_t getCurrentIndex() const {
class GeneratorsForTest (line 7325) | class GeneratorsForTest : public IGeneratorsForTest {
method IGeneratorInfo (line 7332) | IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::...
method moveNext (line 7343) | bool moveNext() {
function IGeneratorsForTest (line 7358) | IGeneratorsForTest* createGeneratorsForTest()
function SourceLineInfo (line 7435) | SourceLineInfo AssertionResult::getSourceInfo() const {
method SourceLineInfo (line 402) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 403) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 404) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
function parseSpecialTag (line 7450) | inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string co...
function isReservedTag (line 7464) | inline bool isReservedTag( std::string const& tag ) {
function enforceNotReservedTag (line 7467) | inline void enforceNotReservedTag( std::string const& tag, SourceLineI...
function TestCase (line 7483) | TestCase makeTestCase( ITestCase* _testCase,
function setTags (line 7528) | void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const&...
function TestCase (line 7588) | TestCase TestCase::withName( std::string const& _newName ) const {
function TestCase (line 7619) | TestCase& TestCase::operator = ( TestCase const& other ) {
function TestCaseInfo (line 7625) | TestCaseInfo const& TestCase::getTestCaseInfo() const
type SpecialProperties (line 2868) | enum SpecialProperties{
type IReporter (line 7710) | struct IReporter : IShared {
class LegacyReporterAdapter (line 7729) | class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
function ReporterPreferences (line 7761) | ReporterPreferences LegacyReporterAdapter::getPreferences() const {
method ReporterPreferences (line 5156) | ReporterPreferences()
function getCurrentTicks (line 7841) | uint64_t getCurrentTicks() {
function getCurrentTicks (line 7852) | uint64_t getCurrentTicks() {
function startsWith (line 7883) | bool startsWith( std::string const& s, std::string const& prefix ) {
function endsWith (line 7886) | bool endsWith( std::string const& s, std::string const& suffix ) {
function contains (line 7889) | bool contains( std::string const& s, std::string const& infix ) {
function toLowerCh (line 7892) | char toLowerCh(char c) {
function toLowerInPlace (line 7895) | void toLowerInPlace( std::string& s ) {
function toLower (line 7898) | std::string toLower( std::string const& s ) {
function trim (line 7903) | std::string trim( std::string const& str ) {
function replaceInPlace (line 7911) | bool replaceInPlace( std::string& str, std::string const& replaceThis,...
function seedRng (line 7956) | void seedRng( IConfig const& config ) {
function rngSeed (line 7960) | unsigned int rngSeed() {
function throwLogicError (line 7973) | void throwLogicError( std::string const& message, SourceLineInfo const...
function isDebuggerActive (line 8039) | bool isDebuggerActive(){
function isDebuggerActive (line 8084) | bool isDebuggerActive(){
function isDebuggerActive (line 8102) | bool isDebuggerActive() {
function isDebuggerActive (line 8109) | bool isDebuggerActive() {
function isDebuggerActive (line 8115) | inline bool isDebuggerActive() { return false; }
function writeToDebugConsole (line 8122) | void writeToDebugConsole( std::string const& text ) {
function writeToDebugConsole (line 8128) | void writeToDebugConsole( std::string const& text ) {
type Detail (line 8140) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
function toString (line 8180) | std::string toString( std::string const& value ) {
function toString (line 8198) | std::string toString( std::wstring const& value ) {
function toString (line 8207) | std::string toString( const char* const value ) {
function toString (line 8211) | std::string toString( char* const value ) {
function toString (line 8215) | std::string toString( const wchar_t* const value )
function toString (line 8220) | std::string toString( wchar_t* const value )
function toString (line 8225) | std::string toString( int value ) {
function toString (line 8233) | std::string toString( unsigned long value ) {
function toString (line 8241) | std::string toString( unsigned int value ) {
function fpToString (line 8246) | std::string fpToString( T value, int precision ) {
function toString (line 8261) | std::string toString( const double value ) {
function toString (line 8264) | std::string toString( const float value ) {
function toString (line 8268) | std::string toString( bool value ) {
function toString (line 8272) | std::string toString( char value ) {
function toString (line 8278) | std::string toString( signed char value ) {
function toString (line 8282) | std::string toString( unsigned char value ) {
function toString (line 8287) | std::string toString( long long value ) {
function toString (line 8294) | std::string toString( unsigned long long value ) {
function toString (line 8304) | std::string toString( std::nullptr_t ) {
function toString (line 8310) | std::string toString( NSString const * const& nsstring ) {
function toString (line 8320) | std::string toString( NSObject* const& nsObject ) {
function capturedExpressionWithSecondArgument (line 8332) | std::string capturedExpressionWithSecondArgument( std::string const& c...
function ResultBuilder (line 8347) | ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
function ResultBuilder (line 8351) | ResultBuilder& ResultBuilder::setResultType( bool result ) {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
function ResultBuilder (line 8355) | ResultBuilder& ResultBuilder::setLhs( std::string const& lhs ) {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
function ResultBuilder (line 8359) | ResultBuilder& ResultBuilder::setRhs( std::string const& rhs ) {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
function ResultBuilder (line 8363) | ResultBuilder& ResultBuilder::setOp( std::string const& op ) {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
function AssertionResult (line 8429) | AssertionResult ResultBuilder::build() const
method AssertionResult (line 873) | AssertionResult( AssertionResult const& ) = default;
method AssertionResult (line 874) | AssertionResult( AssertionResult && ) = default;
method AssertionResult (line 875) | AssertionResult& operator = ( AssertionResult const& ) = default;
method AssertionResult (line 876) | AssertionResult& operator = ( AssertionResult && ) = default;
class TagAliasRegistry (line 8482) | class TagAliasRegistry : public ITagAliasRegistry {
function TagAliasRegistry (line 8542) | TagAliasRegistry& TagAliasRegistry::get() {
function ITagAliasRegistry (line 8549) | ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasReg...
class MultipleReporters (line 8569) | class MultipleReporters : public SharedImpl<IStreamingReporter> {
method add (line 8574) | void add( Ptr<IStreamingReporter> const& reporter ) {
method ReporterPreferences (line 8580) | virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
method noMatchingTestCases (line 8584) | virtual void noMatchingTestCases( std::string const& spec ) CATCH_OV...
method testRunStarting (line 8591) | virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH...
method testGroupStarting (line 8598) | virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_O...
method testCaseStarting (line 8605) | virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_...
method sectionStarting (line 8612) | virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH...
method assertionStarting (line 8619) | virtual void assertionStarting( AssertionInfo const& assertionInfo )...
method assertionEnded (line 8627) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method sectionEnded (line 8636) | virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_...
method testCaseEnded (line 8643) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 8650) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEnded (line 8657) | virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_...
method skipTest (line 8664) | virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
method MultipleReporters (line 8671) | virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
function addReporter (line 8677) | Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& ex...
type StreamingReporterBase (line 8710) | struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
method StreamingReporterBase (line 8712) | StreamingReporterBase( ReporterConfig const& _config )
method ReporterPreferences (line 8719) | virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
method noMatchingTestCases (line 8725) | virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRID...
method testRunStarting (line 8727) | virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATC...
method testGroupStarting (line 8730) | virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_...
method testCaseStarting (line 8734) | virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH...
method sectionStarting (line 8737) | virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATC...
method sectionEnded (line 8741) | virtual void sectionEnded( SectionStats const& /* _sectionStats */ )...
method testCaseEnded (line 8744) | virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats *...
method testGroupEnded (line 8747) | virtual void testGroupEnded( TestGroupStats const& /* _testGroupStat...
method testRunEnded (line 8750) | virtual void testRunEnded( TestRunStats const& /* _testRunStats */ )...
method skipTest (line 8756) | virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {
type CumulativeReporterBase (line 8772) | struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
type Node (line 8774) | struct Node : SharedImpl<> {
method Node (line 8775) | explicit Node( T const& _value ) : value( _value ) {}
type SectionNode (line 8782) | struct SectionNode : SharedImpl<> {
method SectionNode (line 8783) | explicit SectionNode( SectionStats const& _stats ) : stats( _stats...
type BySectionInfo (line 8802) | struct BySectionInfo {
method BySectionInfo (line 8803) | BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
method BySectionInfo (line 8804) | BySectionInfo( BySectionInfo const& other ) : m_other( other.m_oth...
method CumulativeReporterBase (line 8817) | CumulativeReporterBase( ReporterConfig const& _config )
method ReporterPreferences (line 8825) | virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
method testRunStarting (line 8829) | virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {}
method testGroupStarting (line 8830) | virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {}
method testCaseStarting (line 8832) | virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {}
method sectionStarting (line 8834) | virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH...
method assertionStarting (line 8859) | virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRID...
method assertionEnded (line 8861) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method sectionEnded (line 8867) | virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_...
method testCaseEnded (line 8873) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 8884) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEnded (line 8889) | virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_...
method skipTest (line 8897) | virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
type TestEventListenerBase (line 8925) | struct TestEventListenerBase : StreamingReporterBase {
method TestEventListenerBase (line 8926) | TestEventListenerBase( ReporterConfig const& _config )
method assertionStarting (line 8930) | virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRID...
method assertionEnded (line 8931) | virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE {
class LegacyReporterRegistrar (line 8944) | class LegacyReporterRegistrar {
class ReporterFactory (line 8946) | class ReporterFactory : public IReporterFactory {
method IStreamingReporter (line 8947) | virtual IStreamingReporter* create( ReporterConfig const& config )...
method getDescription (line 8951) | virtual std::string getDescription() const {
method LegacyReporterRegistrar (line 8958) | LegacyReporterRegistrar( std::string const& name ) {
class ReporterRegistrar (line 8964) | class ReporterRegistrar {
class ReporterFactory (line 8966) | class ReporterFactory : public SharedImpl<IReporterFactory> {
method IStreamingReporter (line 8979) | virtual IStreamingReporter* create( ReporterConfig const& config )...
method getDescription (line 8983) | virtual std::string getDescription() const {
method ReporterRegistrar (line 8990) | ReporterRegistrar( std::string const& name ) {
class ListenerRegistrar (line 8996) | class ListenerRegistrar {
class ListenerFactory (line 8998) | class ListenerFactory : public SharedImpl<IReporterFactory> {
method IStreamingReporter (line 9000) | virtual IStreamingReporter* create( ReporterConfig const& config )...
method getDescription (line 9003) | virtual std::string getDescription() const {
method ListenerRegistrar (line 9010) | ListenerRegistrar() {
class XmlEncode (line 9035) | class XmlEncode {
type ForWhat (line 9037) | enum ForWhat { ForTextNodes, ForAttributes }
method XmlEncode (line 9039) | XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
method encodeTo (line 9044) | void encodeTo( std::ostream& os ) const {
class XmlWriter (line 9091) | class XmlWriter {
class ScopedElement (line 9094) | class ScopedElement {
method ScopedElement (line 9096) | ScopedElement( XmlWriter* writer )
method ScopedElement (line 9100) | ScopedElement( ScopedElement const& other )
method ScopedElement (line 9110) | ScopedElement& writeText( std::string const& text, bool indent = t...
method ScopedElement (line 9116) | ScopedElement& writeAttribute( std::string const& name, T const& a...
method XmlWriter (line 9125) | XmlWriter()
method XmlWriter (line 9136) | XmlWriter( std::ostream& os )
method XmlWriter (line 9149) | XmlWriter& startElement( std::string const& name ) {
method ScopedElement (line 9159) | ScopedElement scopedElement( std::string const& name ) {
method ScopedElement (line 9096) | ScopedElement( XmlWriter* writer )
method ScopedElement (line 9100) | ScopedElement( ScopedElement const& other )
method ScopedElement (line 9110) | ScopedElement& writeText( std::string const& text, bool indent = t...
method ScopedElement (line 9116) | ScopedElement& writeAttribute( std::string const& name, T const& a...
method XmlWriter (line 9165) | XmlWriter& endElement() {
method XmlWriter (line 9179) | XmlWriter& writeAttribute( std::string const& name, std::string cons...
method XmlWriter (line 9185) | XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
method XmlWriter (line 9191) | XmlWriter& writeAttribute( std::string const& name, T const& attribu...
method XmlWriter (line 9197) | XmlWriter& writeText( std::string const& text, bool indent = true ) {
method XmlWriter (line 9209) | XmlWriter& writeComment( std::string const& text ) {
method XmlWriter (line 9216) | XmlWriter& writeBlankLine() {
method setStream (line 9222) | void setStream( std::ostream& os ) {
method ensureTagClosed (line 9234) | void ensureTagClosed() {
method newlineIfNecessary (line 9241) | void newlineIfNecessary() {
class XmlReporter (line 9272) | class XmlReporter : public StreamingReporterBase {
method XmlReporter (line 9274) | XmlReporter( ReporterConfig const& _config )
method getDescription (line 9284) | static std::string getDescription() {
method noMatchingTestCases (line 9290) | virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERR...
method testRunStarting (line 9294) | virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OV...
method testGroupStarting (line 9301) | virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_O...
method testCaseStarting (line 9307) | virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_...
method sectionStarting (line 9315) | virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH...
method assertionStarting (line 9324) | virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRID...
method assertionEnded (line 9326) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method sectionEnded (line 9397) | virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_...
method testCaseEnded (line 9412) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 9423) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEnded (line 9433) | virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_...
function getCurrentTimestamp (line 9460) | std::string getCurrentTimestamp() {
class JunitReporter (line 9488) | class JunitReporter : public CumulativeReporterBase {
method JunitReporter (line 9490) | JunitReporter( ReporterConfig const& _config )
method getDescription (line 9499) | static std::string getDescription() {
method noMatchingTestCases (line 9503) | virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATC...
method testRunStarting (line 9505) | virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVE...
method testGroupStarting (line 9510) | virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_O...
method assertionEnded (line 9518) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method testCaseEnded (line 9524) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 9530) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEndedCumulative (line 9536) | virtual void testRunEndedCumulative() CATCH_OVERRIDE {
method writeGroup (line 9540) | void writeGroup( TestGroupNode const& groupNode, double suiteTime ) {
method writeTestCase (line 9565) | void writeTestCase( TestCaseNode const& testCaseNode ) {
method writeSection (line 9582) | void writeSection( std::string const& className,
method writeAssertions (line 9621) | void writeAssertions( SectionNode const& sectionNode ) {
method writeAssertion (line 9628) | void writeAssertion( AssertionStats const& stats ) {
type ConsoleReporter (line 9695) | struct ConsoleReporter : StreamingReporterBase {
method ConsoleReporter (line 9696) | ConsoleReporter( ReporterConfig const& _config )
method getDescription (line 9702) | static std::string getDescription() {
method noMatchingTestCases (line 9706) | virtual void noMatchingTestCases( std::string const& spec ) CATCH_OV...
method assertionStarting (line 9710) | virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
method assertionEnded (line 9713) | virtual bool assertionEnded( AssertionStats const& _assertionStats )...
method sectionStarting (line 9733) | virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATC...
method sectionEnded (line 9737) | virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH...
method testCaseEnded (line 9759) | virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CA...
method testGroupEnded (line 9763) | virtual void testGroupEnded( TestGroupStats const& _testGroupStats )...
method testRunEnded (line 9772) | virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH...
class AssertionPrinter (line 9781) | class AssertionPrinter {
method AssertionPrinter (line 9784) | AssertionPrinter( std::ostream& _stream, AssertionStats const& _st...
method print (line 9856) | void print() const {
method printResultType (line 9872) | void printResultType() const {
method printOriginalExpression (line 9878) | void printOriginalExpression() const {
method printReconstructedExpression (line 9886) | void printReconstructedExpression() const {
method printMessage (line 9893) | void printMessage() const {
method printSourceInfo (line 9904) | void printSourceInfo() const {
method lazyPrint (line 9920) | void lazyPrint() {
method lazyPrintRunInfo (line 9932) | void lazyPrintRunInfo() {
method lazyPrintGroupInfo (line 9944) | void lazyPrintGroupInfo() {
method printTestCaseAndSectionHeader (line 9950) | void printTestCaseAndSectionHeader() {
method printClosedHeader (line 9974) | void printClosedHeader( std::string const& _name ) {
method printOpenHeader (line 9978) | void printOpenHeader( std::string const& _name ) {
method printHeaderString (line 9988) | void printHeaderString( std::string const& _string, std::size_t inde...
type SummaryColumn (line 9999) | struct SummaryColumn {
method SummaryColumn (line 10001) | SummaryColumn( std::string const& _label, Colour::Code _colour )
method SummaryColumn (line 10005) | SummaryColumn addRow( std::size_t count ) {
method printTotals (line 10025) | void printTotals( Totals const& totals ) {
method printSummaryRow (line 10056) | void printSummaryRow( std::string const& label, std::vector<SummaryC...
method makeRatio (line 10075) | static std::size_t makeRatio( std::size_t number, std::size_t total ) {
method printTotalsDivider (line 10088) | void printTotalsDivider( Totals const& totals ) {
method printSummaryDivider (line 10110) | void printSummaryDivider() {
type CompactReporter (line 10127) | struct CompactReporter : StreamingReporterBase {
method CompactReporter (line 10129) | CompactReporter( ReporterConfig const& _config )
method getDescription (line 10135) | static std::string getDescription() {
method ReporterPreferences (line 10139) | virtual ReporterPreferences getPreferences() const {
method noMatchingTestCases (line 10145) | virtual void noMatchingTestCases( std::string const& spec ) {
method assertionStarting (line 10149) | virtual void assertionStarting( AssertionInfo const& ) {
method assertionEnded (line 10152) | virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
method testRunEnded (line 10171) | virtual void testRunEnded( TestRunStats const& _testRunStats ) {
class AssertionPrinter (line 10178) | class AssertionPrinter {
method AssertionPrinter (line 10181) | AssertionPrinter( std::ostream& _stream, AssertionStats const& _st...
method print (line 10190) | void print() {
method dimColour (line 10261) | static Colour::Code dimColour() { return Colour::FileName; }
method printSourceInfo (line 10271) | void printSourceInfo() const {
method printResultType (line 10276) | void printResultType( Colour::Code colour, std::string passOrFail ...
method printIssue (line 10286) | void printIssue( std::string issue ) const {
method printExpressionWas (line 10290) | void printExpressionWas() {
method printOriginalExpression (line 10301) | void printOriginalExpression() const {
method printReconstructedExpression (line 10307) | void printReconstructedExpression() const {
method printMessage (line 10317) | void printMessage() {
method printRemainingMessages (line 10324) | void printRemainingMessages( Colour::Code colour = dimColour() ) {
method bothOrAll (line 10365) | std::string bothOrAll( std::size_t count ) const {
method printTotals (line 10369) | void printTotals( const Totals& totals ) const {
type TestCaseTracking (line 10465) | namespace TestCaseTracking {
type ITracker (line 5563) | struct ITracker : SharedImpl<> {
class TrackerContext (line 5591) | class TrackerContext {
type RunState (line 5593) | enum RunState {
method TrackerContext (line 5605) | static TrackerContext& instance() {
method TrackerContext (line 5610) | TrackerContext()
method endRun (line 5617) | void endRun() {
method startCycle (line 5623) | void startCycle() {
method completeCycle (line 5627) | void completeCycle() {
method completedCycle (line 5631) | bool completedCycle() const {
method ITracker (line 5634) | ITracker& currentTracker() {
method setCurrentTracker (line 5637) | void setCurrentTracker( ITracker* tracker ) {
class TrackerBase (line 5642) | class TrackerBase : public ITracker {
type CycleState (line 5644) | enum CycleState {
class TrackerHasName (line 5652) | class TrackerHasName {
method TrackerHasName (line 5655) | TrackerHasName( std::string const& name ) : m_name( name ) {}
method TrackerBase (line 5667) | TrackerBase( std::string const& name, TrackerContext& ctx, ITracke...
method isComplete (line 5678) | virtual bool isComplete() const CATCH_OVERRIDE {
method isSuccessfullyCompleted (line 5681) | virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
method isOpen (line 5684) | virtual bool isOpen() const CATCH_OVERRIDE {
method hasChildren (line 5687) | virtual bool hasChildren() const CATCH_OVERRIDE {
method addChild (line 5691) | virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
method ITracker (line 5695) | virtual ITracker* findChild( std::string const& name ) CATCH_OVERR...
method ITracker (line 5701) | virtual ITracker& parent() CATCH_OVERRIDE {
method isSectionTracker (line 5714) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return fals...
method isIndexTracker (line 5715) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
method open (line 5717) | void open() {
method markAsNeedingAnotherRun (line 5760) | virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
method moveToParent (line 5764) | void moveToParent() {
method moveToThis (line 5768) | void moveToThis() {
class SectionTracker (line 5773) | class SectionTracker : public TrackerBase {
method SectionTracker (line 5775) | SectionTracker( std::string const& name, TrackerContext& ctx, ITra...
method isSectionTracker (line 5780) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
method SectionTracker (line 5782) | static SectionTracker& acquire( TrackerContext& ctx, std::string c...
class IndexTracker (line 5803) | class IndexTracker : public TrackerBase {
method IndexTracker (line 5807) | IndexTracker( std::string const& name, TrackerContext& ctx, ITrack...
method isIndexTracker (line 5814) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
method IndexTracker (line 5816) | static IndexTracker& acquire( TrackerContext& ctx, std::string con...
method index (line 5839) | int index() const { return m_index; }
method moveNext (line 5841) | void moveNext() {
function ITracker (line 5853) | inline ITracker& TrackerContext::startRun() {
type Catch (line 445) | namespace Catch {
type IConfig (line 330) | struct IConfig
type CaseSensitive (line 332) | struct CaseSensitive { enum Choice {
type Choice (line 332) | enum Choice {
class NonCopyable (line 337) | class NonCopyable {
method NonCopyable (line 339) | NonCopyable( NonCopyable const& ) = delete;
method NonCopyable (line 340) | NonCopyable( NonCopyable && ) = delete;
method NonCopyable (line 341) | NonCopyable& operator = ( NonCopyable const& ) = delete;
method NonCopyable (line 342) | NonCopyable& operator = ( NonCopyable && ) = delete;
method NonCopyable (line 349) | NonCopyable() {}
class SafeBool (line 353) | class SafeBool {
method type (line 357) | static type makeSafe( bool value ) {
method trueValue (line 361) | void trueValue() const {}
function deleteAll (line 365) | inline void deleteAll( ContainerT& container ) {
function deleteAllValues (line 372) | inline void deleteAllValues( AssociativeContainerT& container ) {
type pluralise (line 387) | struct pluralise {
type SourceLineInfo (line 396) | struct SourceLineInfo {
method SourceLineInfo (line 402) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 403) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 404) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
function alwaysTrue (line 417) | inline bool alwaysTrue( std::size_t = 0 ) { return true; }
function alwaysFalse (line 418) | inline bool alwaysFalse( std::size_t = 0 ) { return false; }
type StreamEndStop (line 429) | struct StreamEndStop {
function T (line 435) | T const& operator + ( T const& value, StreamEndStop ) {
class NotImplementedException (line 447) | class NotImplementedException : public std::exception
method NotImplementedException (line 451) | NotImplementedException( NotImplementedException const& ) {}
type IGeneratorInfo (line 477) | struct IGeneratorInfo {
type IGeneratorsForTest (line 483) | struct IGeneratorsForTest {
class Ptr (line 508) | class Ptr {
method Ptr (line 510) | Ptr() : m_p( CATCH_NULL ){}
method Ptr (line 511) | Ptr( T* p ) : m_p( p ){
method Ptr (line 515) | Ptr( Ptr const& other ) : m_p( other.m_p ){
method reset (line 523) | void reset() {
method Ptr (line 528) | Ptr& operator = ( T* p ){
method Ptr (line 533) | Ptr& operator = ( Ptr const& other ){
method swap (line 538) | void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
method T (line 539) | T* get() const{ return m_p; }
method T (line 540) | T& operator*() const { return *m_p; }
method T (line 541) | T* operator->() const { return m_p; }
type IShared (line 549) | struct IShared : NonCopyable {
type SharedImpl (line 556) | struct SharedImpl : T {
method SharedImpl (line 558) | SharedImpl() : m_rc( 0 ){}
method addRef (line 560) | virtual void addRef() const {
method release (line 563) | virtual void release() const {
class TestCase (line 583) | class TestCase
class Stream (line 584) | class Stream
type IResultCapture (line 585) | struct IResultCapture
type IRunner (line 586) | struct IRunner
type IGeneratorsForTest (line 587) | struct IGeneratorsForTest
type IConfig (line 588) | struct IConfig
type IContext (line 590) | struct IContext
type IMutableContext (line 601) | struct IMutableContext : IContext
class TestSpec (line 626) | class TestSpec
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type ITestCase (line 628) | struct ITestCase : IShared {
class TestCase (line 634) | class TestCase
type IConfig (line 635) | struct IConfig
type ITestCaseRegistry (line 637) | struct ITestCaseRegistry {
class MethodTestCase (line 652) | class MethodTestCase : public SharedImpl<ITestCase> {
method MethodTestCase (line 655) | MethodTestCase( void (C::*method)() ) : m_method( method ) {}
method invoke (line 657) | virtual void invoke() const {
type NameAndDesc (line 670) | struct NameAndDesc {
method NameAndDesc (line 671) | NameAndDesc( const char* _name = "", const char* _description= "" )
type AutoReg (line 685) | struct AutoReg {
method AutoReg (line 693) | AutoReg
type ResultWas (line 791) | struct ResultWas { enum OfType {
type OfType (line 791) | enum OfType {
function isOk (line 811) | inline bool isOk( ResultWas::OfType resultType ) {
function isJustInfo (line 814) | inline bool isJustInfo( int flags ) {
type ResultDisposition (line 819) | struct ResultDisposition { enum Flags {
type Flags (line 819) | enum Flags {
function shouldContinueOnFailure (line 831) | inline bool shouldContinueOnFailure( int flags ) { return ( flags &...
function isFalseTest (line 832) | inline bool isFalseTest( int flags ) { return ( flags &...
function shouldSuppressFailure (line 833) | inline bool shouldSuppressFailure( int flags ) { return ( flags &...
type AssertionInfo (line 844) | struct AssertionInfo
method AssertionInfo (line 846) | AssertionInfo() {}
type AssertionResultData (line 858) | struct AssertionResultData
method AssertionResultData (line 860) | AssertionResultData() : resultType( ResultWas::Unknown ) {}
class AssertionResult (line 867) | class AssertionResult {
method AssertionResult (line 873) | AssertionResult( AssertionResult const& ) = default;
method AssertionResult (line 874) | AssertionResult( AssertionResult && ) = default;
method AssertionResult (line 875) | AssertionResult& operator = ( AssertionResult const& ) = default;
method AssertionResult (line 876) | AssertionResult& operator = ( AssertionResult && ) = default;
type Matchers (line 903) | namespace Matchers {
type Impl (line 904) | namespace Impl {
type Generic (line 906) | namespace Generic {
class AllOf (line 907) | class AllOf
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 908) | class AnyOf
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
class Not (line 909) | class Not
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class Not (line 937) | class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class AllOf (line 954) | class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 994) | class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
type Matcher (line 913) | struct Matcher : SharedImpl<IShared>
type MatcherImpl (line 928) | struct MatcherImpl : Matcher<ExpressionT> {
method clone (line 930) | virtual Ptr<Matcher<ExpressionT> > clone() const {
type Generic (line 935) | namespace Generic {
class AllOf (line 907) | class AllOf
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 908) | class AnyOf
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
class Not (line 909) | class Not
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class Not (line 937) | class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
method Not (line 939) | explicit Not( Matcher<ExpressionT> const& matcher ) : m_matche...
method Not (line 940) | Not( Not const& other ) : m_matcher( other.m_matcher ) {}
method match (line 942) | virtual bool match( ExpressionT const& expr ) const CATCH_OVER...
method toString (line 946) | virtual std::string toString() const CATCH_OVERRIDE {
class AllOf (line 954) | class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
method AllOf (line 957) | AllOf() {}
method AllOf (line 958) | AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
method AllOf (line 960) | AllOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 964) | virtual bool match( ExpressionT const& expr ) const
method toString (line 971) | virtual std::string toString() const {
method AllOf (line 983) | AllOf operator && ( Matcher<ExpressionT> const& other ) const {
class AnyOf (line 994) | class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
method AnyOf (line 997) | AnyOf() {}
method AnyOf (line 998) | AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
method AnyOf (line 1000) | AnyOf& add( Matcher<ExpressionT> const& matcher ) {
method match (line 1004) | virtual bool match( ExpressionT const& expr ) const
method toString (line 1011) | virtual std::string toString() const {
method AnyOf (line 1023) | AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
type StdString (line 1056) | namespace StdString {
function makeString (line 1058) | inline std::string makeString( std::string const& str ) { return...
function makeString (line 1059) | inline std::string makeString( const char* str ) { return str ? ...
type CasedString (line 1061) | struct CasedString
method CasedString (line 1063) | CasedString( std::string const& str, CaseSensitive::Choice cas...
method adjustString (line 1067) | std::string adjustString( std::string const& str ) const {
method toStringSuffix (line 1073) | std::string toStringSuffix() const
type Equals (line 1083) | struct Equals : MatcherImpl<Equals, std::string> {
method Equals (line 1084) | Equals( std::string const& str, CaseSensitive::Choice caseSens...
method Equals (line 1087) | Equals( Equals const& other ) : m_data( other.m_data ){}
method match (line 1091) | virtual bool match( std::string const& expr ) const {
method toString (line 1094) | virtual std::string toString() const {
type Contains (line 1101) | struct Contains : MatcherImpl<Contains, std::string> {
method Contains (line 1102) | Contains( std::string const& substr, CaseSensitive::Choice cas...
method Contains (line 1104) | Contains( Contains const& other ) : m_data( other.m_data ){}
method match (line 1108) | virtual bool match( std::string const& expr ) const {
method toString (line 1111) | virtual std::string toString() const {
type StartsWith (line 1118) | struct StartsWith : MatcherImpl<StartsWith, std::string> {
method StartsWith (line 1119) | StartsWith( std::string const& substr, CaseSensitive::Choice c...
method StartsWith (line 1122) | StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
method match (line 1126) | virtual bool match( std::string const& expr ) const {
method toString (line 1129) | virtual std::string toString() const {
type EndsWith (line 1136) | struct EndsWith : MatcherImpl<EndsWith, std::string> {
method EndsWith (line 1137) | EndsWith( std::string const& substr, CaseSensitive::Choice cas...
method EndsWith (line 1139) | EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
method match (line 1143) | virtual bool match( std::string const& expr ) const {
method toString (line 1146) | virtual std::string toString() const {
function Not (line 1158) | inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<Expression...
function AllOf (line 1163) | inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<Expres...
function AllOf (line 1168) | inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<Expres...
function AnyOf (line 1174) | inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<Expres...
function AnyOf (line 1179) | inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<Expres...
function Equals (line 1185) | inline Impl::StdString::Equals Equals( std::string const& str, ...
function Equals (line 1188) | inline Impl::StdString::Equals Equals( const char* str, CaseSen...
function Contains (line 1191) | inline Impl::StdString::Contains Contains( std::string const& sub...
function Contains (line 1194) | inline Impl::StdString::Contains Contains( const char* substr, Ca...
function StartsWith (line 1197) | inline Impl::StdString::StartsWith StartsWith( std::string const& s...
function StartsWith (line 1200) | inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
function EndsWith (line 1203) | inline Impl::StdString::EndsWith EndsWith( std::string const& sub...
function EndsWith (line 1206) | inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
type TestFailureException (line 1218) | struct TestFailureException{}
class ExpressionLhs (line 1220) | class ExpressionLhs
method ExpressionLhs (line 1814) | ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
method ExpressionLhs (line 1818) | ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
method ExpressionLhs (line 1820) | ExpressionLhs( ExpressionLhs const& ) = default;
method ExpressionLhs (line 1821) | ExpressionLhs( ExpressionLhs && ) = default;
method ResultBuilder (line 1825) | ResultBuilder& operator == ( RhsT const& rhs ) {
method ResultBuilder (line 1830) | ResultBuilder& operator != ( RhsT const& rhs ) {
method ResultBuilder (line 1835) | ResultBuilder& operator < ( RhsT const& rhs ) {
method ResultBuilder (line 1840) | ResultBuilder& operator > ( RhsT const& rhs ) {
method ResultBuilder (line 1845) | ResultBuilder& operator <= ( RhsT const& rhs ) {
method ResultBuilder (line 1850) | ResultBuilder& operator >= ( RhsT const& rhs ) {
method ResultBuilder (line 1854) | ResultBuilder& operator == ( bool rhs ) {
method ResultBuilder (line 1858) | ResultBuilder& operator != ( bool rhs ) {
method endExpression (line 1862) | void endExpression() {
method ResultBuilder (line 1881) | ResultBuilder& captureExpression( RhsT const& rhs ) {
type STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison (line 1222) | struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_C...
type CopyableStream (line 1224) | struct CopyableStream {
method CopyableStream (line 1225) | CopyableStream() {}
method CopyableStream (line 1226) | CopyableStream( CopyableStream const& other ) {
method CopyableStream (line 1229) | CopyableStream& operator=( CopyableStream const& other ) {
class ResultBuilder (line 1237) | class ResultBuilder {
method ResultBuilder (line 1250) | ResultBuilder& operator << ( T const& value ) {
type ExprComponents (line 1282) | struct ExprComponents {
method ExprComponents (line 1283) | ExprComponents() : testFalse( false ) {}
type Internal (line 1310) | namespace Internal {
type Operator (line 1312) | enum Operator {
type OperatorTraits (line 1321) | struct OperatorTraits { static const char* getName(){ re...
type OperatorTraits<IsEqualTo> (line 1322) | struct OperatorTraits<IsEqualTo> { static const char* ge...
type OperatorTraits<IsNotEqualTo> (line 1323) | struct OperatorTraits<IsNotEqualTo> { static const char* ge...
type OperatorTraits<IsLessThan> (line 1324) | struct OperatorTraits<IsLessThan> { static const char* ge...
type OperatorTraits<IsGreaterThan> (line 1325) | struct OperatorTraits<IsGreaterThan> { static const char* ge...
type OperatorTraits<IsLessThanOrEqualTo> (line 1326) | struct OperatorTraits<IsLessThanOrEqualTo> { static const char* ge...
type OperatorTraits<IsGreaterThanOrEqualTo> (line 1327) | struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* ge...
function T (line 1330) | inline T& opCast(T const& t) { return const_cast<T&>(t); }
function opCast (line 1334) | inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
class Evaluator (line 1340) | class Evaluator{}
type Evaluator<T1, T2, IsEqualTo> (line 1343) | struct Evaluator<T1, T2, IsEqualTo> {
method evaluate (line 1344) | static bool evaluate( T1 const& lhs, T2 const& rhs) {
type Evaluator<T1, T2, IsNotEqualTo> (line 1349) | struct Evaluator<T1, T2, IsNotEqualTo> {
method evaluate (line 1350) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsLessThan> (line 1355) | struct Evaluator<T1, T2, IsLessThan> {
method evaluate (line 1356) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsGreaterThan> (line 1361) | struct Evaluator<T1, T2, IsGreaterThan> {
method evaluate (line 1362) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsGreaterThanOrEqualTo> (line 1367) | struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
method evaluate (line 1368) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
type Evaluator<T1, T2, IsLessThanOrEqualTo> (line 1373) | struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
method evaluate (line 1374) | static bool evaluate( T1 const& lhs, T2 const& rhs ) {
function applyEvaluator (line 1380) | bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
function compare (line 1389) | bool compare( T1 const& lhs, T2 const& rhs ) {
function compare (line 1394) | bool compare( unsigned int lhs, int rhs ) {
function compare (line 1397) | bool compare( unsigned long lhs, int rhs ) {
function compare (line 1400) | bool compare( unsigned char lhs, int rhs ) {
function compare (line 1405) | bool compare( unsigned int lhs, long rhs ) {
function compare (line 1408) | bool compare( unsigned long lhs, long rhs ) {
function compare (line 1411) | bool compare( unsigned char lhs, long rhs ) {
function compare (line 1416) | bool compare( int lhs, unsigned int rhs ) {
function compare (line 1419) | bool compare( int lhs, unsigned long rhs ) {
function compare (line 1422) | bool compare( int lhs, unsigned char rhs ) {
function compare (line 1427) | bool compare( long lhs, unsigned int rhs ) {
function compare (line 1430) | bool compare( long lhs, unsigned long rhs ) {
function compare (line 1433) | bool compare( long lhs, unsigned char rhs ) {
function compare (line 1438) | bool compare( long lhs, T* rhs ) {
function compare (line 1441) | bool compare( T* lhs, long rhs ) {
function compare (line 1446) | bool compare( int lhs, T* rhs ) {
function compare (line 1449) | bool compare( T* lhs, int rhs ) {
function compare (line 1455) | bool compare( long long lhs, unsigned int rhs ) {
function compare (line 1458) | bool compare( long long lhs, unsigned long rhs ) {
function compare (line 1461) | bool compare( long long lhs, unsigned long long rhs ) {
function compare (line 1464) | bool compare( long long lhs, unsigned char rhs ) {
function compare (line 1469) | bool compare( unsigned long long lhs, int rhs ) {
function compare (line 1472) | bool compare( unsigned long long lhs, long rhs ) {
function compare (line 1475) | bool compare( unsigned long long lhs, long long rhs ) {
function compare (line 1478) | bool compare( unsigned long long lhs, char rhs ) {
function compare (line 1483) | bool compare( long long lhs, T* rhs ) {
function compare (line 1486) | bool compare( T* lhs, long long rhs ) {
function compare (line 1493) | bool compare( std::nullptr_t, T* rhs ) {
function compare (line 1496) | bool compare( T* lhs, std::nullptr_t ) {
type Detail (line 1610) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
type StringMaker (line 1687) | struct StringMaker :
type StringMaker<T*> (line 1691) | struct StringMaker<T*> {
method convert (line 1693) | static std::string convert( U* p ) {
type StringMaker<R C::*> (line 1702) | struct StringMaker<R C::*> {
method convert (line 1703) | static std::string convert( R C::* p ) {
type Detail (line 1711) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
function toString (line 1724) | std::string toString( std::vector<T,Allocator> const& v ) {
type TupleDetail (line 1731) | namespace TupleDetail {
type ElementPrinter (line 1737) | struct ElementPrinter {
method print (line 1738) | static void print( const Tuple& tuple, std::ostream& os )
type ElementPrinter<Tuple,N,false> (line 1750) | struct ElementPrinter<Tuple,N,false> {
method print (line 1751) | static void print( const Tuple&, std::ostream& ) {}
type Detail (line 1770) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
function toString (line 1785) | std::string toString( T const& value ) {
type Detail (line 1789) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
class ExpressionLhs (line 1811) | class ExpressionLhs {
method ExpressionLhs (line 1814) | ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
method ExpressionLhs (line 1818) | ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
method ExpressionLhs (line 1820) | ExpressionLhs( ExpressionLhs const& ) = default;
method ExpressionLhs (line 1821) | ExpressionLhs( ExpressionLhs && ) = default;
method ResultBuilder (line 1825) | ResultBuilder& operator == ( RhsT const& rhs ) {
method ResultBuilder (line 1830) | ResultBuilder& operator != ( RhsT const& rhs ) {
method ResultBuilder (line 1835) | ResultBuilder& operator < ( RhsT const& rhs ) {
method ResultBuilder (line 1840) | ResultBuilder& operator > ( RhsT const& rhs ) {
method ResultBuilder (line 1845) | ResultBuilder& operator <= ( RhsT const& rhs ) {
method ResultBuilder (line 1850) | ResultBuilder& operator >= ( RhsT const& rhs ) {
method ResultBuilder (line 1854) | ResultBuilder& operator == ( bool rhs ) {
method ResultBuilder (line 1858) | ResultBuilder& operator != ( bool rhs ) {
method endExpression (line 1862) | void endExpression() {
method ResultBuilder (line 1881) | ResultBuilder& captureExpression( RhsT const& rhs ) {
type MessageInfo (line 1917) | struct MessageInfo {
type MessageBuilder (line 1938) | struct MessageBuilder {
method MessageBuilder (line 1939) | MessageBuilder( std::string const& macroName,
method MessageBuilder (line 1946) | MessageBuilder& operator << ( T const& value ) {
class ScopedMessage (line 1955) | class ScopedMessage {
class TestCase (line 1973) | class TestCase
class AssertionResult (line 1974) | class AssertionResult
method AssertionResult (line 873) | AssertionResult( AssertionResult const& ) = default;
method AssertionResult (line 874) | AssertionResult( AssertionResult && ) = default;
method AssertionResult (line 875) | AssertionResult& operator = ( AssertionResult const& ) = default;
method AssertionResult (line 876) | AssertionResult& operator = ( AssertionResult && ) = default;
type AssertionInfo (line 1975) | struct AssertionInfo
method AssertionInfo (line 846) | AssertionInfo() {}
type SectionInfo (line 1976) | struct SectionInfo
type SectionEndInfo (line 1977) | struct SectionEndInfo
method SectionEndInfo (line 2298) | SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prev...
type MessageInfo (line 1978) | struct MessageInfo
class ScopedMessageBuilder (line 1979) | class ScopedMessageBuilder
type Counts (line 1980) | struct Counts
method Counts (line 2222) | Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
method Counts (line 2224) | Counts operator - ( Counts const& other ) const {
method Counts (line 2231) | Counts& operator += ( Counts const& other ) {
method total (line 2238) | std::size_t total() const {
method allPassed (line 2241) | bool allPassed() const {
method allOk (line 2244) | bool allOk() const {
type IResultCapture (line 1982) | struct IResultCapture {
class TestCase (line 2075) | class TestCase
type IRunner (line 2077) | struct IRunner {
type Counts (line 2221) | struct Counts {
method Counts (line 2222) | Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
method Counts (line 2224) | Counts operator - ( Counts const& other ) const {
method Counts (line 2231) | Counts& operator += ( Counts const& other ) {
method total (line 2238) | std::size_t total() const {
method allPassed (line 2241) | bool allPassed() const {
method allOk (line 2244) | bool allOk() const {
type Totals (line 2253) | struct Totals {
method Totals (line 2255) | Totals operator - ( Totals const& other ) const {
method Totals (line 2262) | Totals delta( Totals const& prevTotals ) const {
method Totals (line 2273) | Totals& operator += ( Totals const& other ) {
type SectionInfo (line 2286) | struct SectionInfo {
type SectionEndInfo (line 2297) | struct SectionEndInfo {
method SectionEndInfo (line 2298) | SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prev...
class Timer (line 2320) | class Timer {
method Timer (line 2322) | Timer() : m_ticks( 0 ) {}
class Section (line 2338) | class Section : NonCopyable {
type IGenerator (line 2376) | struct IGenerator {
class BetweenGenerator (line 2383) | class BetweenGenerator : public IGenerator<T> {
method BetweenGenerator (line 2385) | BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
method T (line 2387) | virtual T getValue( std::size_t index ) const {
method size (line 2391) | virtual std::size_t size() const {
class ValuesGenerator (line 2402) | class ValuesGenerator : public IGenerator<T> {
method ValuesGenerator (line 2404) | ValuesGenerator(){}
method add (line 2406) | void add( T value ) {
method T (line 2410) | virtual T getValue( std::size_t index ) const {
method size (line 2414) | virtual std::size_t size() const {
class CompositeGenerator (line 2423) | class CompositeGenerator {
method CompositeGenerator (line 2425) | CompositeGenerator() : m_totalSize( 0 ) {}
method CompositeGenerator (line 2428) | CompositeGenerator( CompositeGenerator& other )
method CompositeGenerator (line 2435) | CompositeGenerator& setFileInfo( const char* fileInfo ) {
method add (line 2462) | void add( const IGenerator<T>* generator ) {
method CompositeGenerator (line 2467) | CompositeGenerator& then( CompositeGenerator& other ) {
method CompositeGenerator (line 2472) | CompositeGenerator& then( T value ) {
method move (line 2481) | void move( CompositeGenerator& other ) {
type Generators (line 2492) | namespace Generators
function between (line 2495) | CompositeGenerator<T> between( T from, T to ) {
function values (line 2502) | CompositeGenerator<T> values( T val1, T val2 ) {
function values (line 2512) | CompositeGenerator<T> values( T val1, T val2, T val3 ){
function values (line 2523) | CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
class TestCase (line 2558) | class TestCase
type ITestCaseRegistry (line 2559) | struct ITestCaseRegistry
type IExceptionTranslatorRegistry (line 2560) | struct IExceptionTranslatorRegistry
type IExceptionTranslator (line 2561) | struct IExceptionTranslator
type IReporterRegistry (line 2562) | struct IReporterRegistry
type IReporterFactory (line 2563) | struct IReporterFactory
type IRegistryHub (line 2565) | struct IRegistryHub {
type IMutableRegistryHub (line 2573) | struct IMutableRegistryHub {
type IExceptionTranslator (line 2592) | struct IExceptionTranslator
type IExceptionTranslator (line 2595) | struct IExceptionTranslator {
type IExceptionTranslatorRegistry (line 2600) | struct IExceptionTranslatorRegistry {
class ExceptionTranslatorRegistrar (line 2606) | class ExceptionTranslatorRegistrar {
class ExceptionTranslator (line 2608) | class ExceptionTranslator : public IExceptionTranslator {
method ExceptionTranslator (line 2611) | ExceptionTranslator( std::string(*translateFunction)( T& ) )
method translate (line 2615) | virtual std::string translate( ExceptionTranslators::const_iterato...
method ExceptionTranslatorRegistrar (line 2633) | ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
type Detail (line 2655) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum Arch { Big, Little }
method Arch (line 8150) | static Arch which() {
function rawMemoryToString (line 8162) | std::string rawMemoryToString( const void *object, std::size_t size )
type TagAlias (line 2759) | struct TagAlias {
method TagAlias (line 2760) | TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag )...
type RegistrarForTagAliases (line 2766) | struct RegistrarForTagAliases {
class Option (line 2780) | class Option {
method Option (line 2782) | Option() : nullableValue( CATCH_NULL ) {}
method Option (line 2783) | Option( T const& _value )
method Option (line 2786) | Option( Option const& _other )
method Option (line 2794) | Option& operator= ( Option const& _other ) {
method Option (line 2802) | Option& operator = ( T const& _value ) {
method reset (line 2808) | void reset() {
method T (line 2814) | T& operator*() { return *nullableValue; }
method T (line 2815) | T const& operator*() const { return *nullableValue; }
method T (line 2816) | T* operator->() { return nullableValue; }
method T (line 2817) | const T* operator->() const { return nullableValue; }
method T (line 2819) | T valueOr( T const& defaultValue ) const {
method some (line 2823) | bool some() const { return nullableValue != CATCH_NULL; }
method none (line 2824) | bool none() const { return nullableValue == CATCH_NULL; }
type ITagAliasRegistry (line 2840) | struct ITagAliasRegistry {
type ITestCase (line 2865) | struct ITestCase
type TestCaseInfo (line 2867) | struct TestCaseInfo {
type SpecialProperties (line 2868) | enum SpecialProperties{
class TestCase (line 2901) | class TestCase : public TestCaseInfo {
class WildcardPattern (line 3170) | class WildcardPattern {
type WildcardPosition (line 3171) | enum WildcardPosition {
method WildcardPattern (line 3180) | WildcardPattern( std::string const& pattern, CaseSensitive::Choice c...
method matches (line 3195) | virtual bool matches( std::string const& str ) const {
method adjustCase (line 3217) | std::string adjustCase( std::string const& str ) const {
class TestSpec (line 3231) | class TestSpec {
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
class TestSpecParser (line 3307) | class TestSpecParser {
type Mode (line 3308) | enum Mode{ None, Name, QuotedName, Tag, EscapedName }
method TestSpecParser (line 3319) | TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases...
method TestSpecParser (line 3321) | TestSpecParser& parse( std::string const& arg ) {
method TestSpec (line 3333) | TestSpec testSpec() {
method visitChar (line 3338) | void visitChar( char c ) {
method startNewMode (line 3371) | void startNewMode( Mode mode, std::size_t start ) {
method escape (line 3375) | void escape() {
method subString (line 3379) | std::string subString() const { return m_arg.substr( m_start, m_pos ...
method addPattern (line 3381) | void addPattern() {
method addFilter (line 3399) | void addFilter() {
function TestSpec (line 3406) | inline TestSpec parseTestSpec( std::string const& arg ) {
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type Verbosity (line 3425) | struct Verbosity { enum Level {
type Level (line 3425) | enum Level {
type WarnAbout (line 3431) | struct WarnAbout { enum What {
type What (line 3431) | enum What {
type ShowDurations (line 3436) | struct ShowDurations { enum OrNot {
type OrNot (line 3436) | enum OrNot {
type RunTests (line 3441) | struct RunTests { enum InWhatOrder {
type InWhatOrder (line 3441) | enum InWhatOrder {
type UseColour (line 3446) | struct UseColour { enum YesOrNo {
type YesOrNo (line 3446) | enum YesOrNo {
class TestSpec (line 3452) | class TestSpec
type Pattern (line 3232) | struct Pattern : SharedImpl<> {
class NamePattern (line 3236) | class NamePattern : public Pattern {
method NamePattern (line 3238) | NamePattern( std::string const& name )
method matches (line 3242) | virtual bool matches( TestCaseInfo const& testCase ) const {
class TagPattern (line 3249) | class TagPattern : public Pattern {
method TagPattern (line 3251) | TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
method matches (line 3253) | virtual bool matches( TestCaseInfo const& testCase ) const {
class ExcludedPattern (line 3260) | class ExcludedPattern : public Pattern {
method ExcludedPattern (line 3262) | ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_under...
method matches (line 3264) | virtual bool matches( TestCaseInfo const& testCase ) const { retur...
type Filter (line 3269) | struct Filter {
method matches (line 3272) | bool matches( TestCaseInfo const& testCase ) const {
method hasFilters (line 3283) | bool hasFilters() const {
method matches (line 3286) | bool matches( TestCaseInfo const& testCase ) const {
type IConfig (line 3454) | struct IConfig : IShared {
class StreamBufBase (line 3484) | class StreamBufBase : public std::streambuf {
type IStream (line 3500) | struct IStream {
class FileStream (line 3505) | class FileStream : public IStream {
class CoutStream (line 3514) | class CoutStream : public IStream {
class DebugOutStream (line 3524) | class DebugOutStream : public IStream {
type ConfigData (line 3548) | struct ConfigData {
method ConfigData (line 3550) | ConfigData()
class Config (line 3599) | class Config : public SharedImpl<IConfig> {
method Config (line 3606) | Config()
method Config (line 3609) | Config( ConfigData const& data )
method listTests (line 3628) | bool listTests() const { return m_data.listTests; }
method listTestNamesOnly (line 3629) | bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
method listTags (line 3630) | bool listTags() const { return m_data.listTags; }
method listReporters (line 3631) | bool listReporters() const { return m_data.listReporters; }
method getProcessName (line 3633) | std::string getProcessName() const { return m_data.processName; }
method shouldDebugBreak (line 3635) | bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
method getReporterNames (line 3637) | std::vector<std::string> getReporterNames() const { return m_data.re...
method abortAfter (line 3639) | int abortAfter() const { return m_data.abortAfter; }
method TestSpec (line 3641) | TestSpec const& testSpec() const { return m_testSpec; }
method showHelp (line 3643) | bool showHelp() const { return m_data.showHelp; }
method showInvisibles (line 3644) | bool showInvisibles() const { return m_data.showInvisibles; }
method allowThrows (line 3647) | virtual bool allowThrows() const { return !m_data.noThrow; }
method name (line 3649) | virtual std::string name() const { return m_data.name.empty()...
method includeSuccessfulResults (line 3650) | virtual bool includeSuccessfulResults() const { return m_data.show...
method warnAboutMissingAssertions (line 3651) | virtual bool warnAboutMissingAssertions() const { return m_data.warn...
method showDurations (line 3652) | virtual ShowDurations::OrNot showDurations() const { return m_data.s...
method runOrder (line 3653) | virtual RunTests::InWhatOrder runOrder() const { return m_data.runO...
method rngSeed (line 3654) | virtual unsigned int rngSeed() const { return m_data.rngSeed; }
method useColour (line 3655) | virtual UseColour::YesOrNo useColour() const { return m_data.useColo...
method IStream (line 3659) | IStream const* openStream() {
function abortAfterFirst (line 4720) | inline void abortAfterFirst( ConfigData& config ) { config.abortAfter ...
function abortAfterX (line 4721) | inline void abortAfterX( ConfigData& config, int x ) {
function addTestOrTags (line 4726) | inline void addTestOrTags( ConfigData& config, std::string const& _tes...
function addReporterName (line 4727) | inline void addReporterName( ConfigData& config, std::string const& _r...
function addWarning (line 4729) | inline void addWarning( ConfigData& config, std::string const& _warnin...
function setOrder (line 4735) | inline void setOrder( ConfigData& config, std::string const& order ) {
function setRngSeed (line 4745) | inline void setRngSeed( ConfigData& config, std::string const& seed ) {
function setVerbosity (line 4757) | inline void setVerbosity( ConfigData& config, int level ) {
function setShowDurations (line 4761) | inline void setShowDurations( ConfigData& config, bool _showDurations ) {
function setUseColour (line 4766) | inline void setUseColour( ConfigData& config, std::string const& value...
function forceColour (line 4778) | inline void forceColour( ConfigData& config ) {
function loadTestNamesFromFile (line 4781) | inline void loadTestNamesFromFile( ConfigData& config, std::string con...
function makeCommandLineParser (line 4797) | inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
type Colour (line 5078) | struct Colour {
type Code (line 5079) | enum Code {
type ReporterConfig (line 5140) | struct ReporterConfig {
method ReporterConfig (line 5141) | explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
method ReporterConfig (line 5144) | ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream&...
method fullConfig (line 5148) | Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
type ReporterPreferences (line 5155) | struct ReporterPreferences {
method ReporterPreferences (line 5156) | ReporterPreferences()
type LazyStat (line 5164) | struct LazyStat : Option<T> {
method LazyStat (line 5165) | LazyStat() : used( false ) {}
method LazyStat (line 5166) | LazyStat& operator=( T const& _value ) {
method reset (line 5171) | void reset() {
type TestRunInfo (line 5178) | struct TestRunInfo {
method TestRunInfo (line 5179) | TestRunInfo( std::string const& _name ) : name( _name ) {}
type GroupInfo (line 5182) | struct GroupInfo {
method GroupInfo (line 5183) | GroupInfo( std::string const& _name,
type AssertionStats (line 5196) | struct AssertionStats {
method AssertionStats (line 5197) | AssertionStats( AssertionResult const& _assertionResult,
method AssertionStats (line 5217) | AssertionStats( AssertionStats const& ) = default;
method AssertionStats (line 5218) | AssertionStats( AssertionStats && ) = default;
method AssertionStats (line 5219) | AssertionStats& operator = ( AssertionStats const& ) = default;
method AssertionStats (line 5220) | AssertionStats& operator = ( AssertionStats && ) = default;
type SectionStats (line 5228) | struct SectionStats {
method SectionStats (line 5229) | SectionStats( SectionInfo const& _sectionInfo,
method SectionStats (line 5240) | SectionStats( SectionStats const& ) = default;
method SectionStats (line 5241) | SectionStats( SectionStats && ) = default;
method SectionStats (line 5242) | SectionStats& operator = ( SectionStats const& ) = default;
method SectionStats (line 5243) | SectionStats& operator = ( SectionStats && ) = default;
type TestCaseStats (line 5252) | struct TestCaseStats {
method TestCaseStats (line 5253) | TestCaseStats( TestCaseInfo const& _testInfo,
method TestCaseStats (line 5267) | TestCaseStats( TestCaseStats const& ) = default;
method TestCaseStats (line 5268) | TestCaseStats( TestCaseStats && ) = default;
method TestCaseStats (line 5269) | TestCaseStats& operator = ( TestCaseStats const& ) = default;
method TestCaseStats (line 5270) | TestCaseStats& operator = ( TestCaseStats && ) = default;
type TestGroupStats (line 5280) | struct TestGroupStats {
method TestGroupStats (line 5281) | TestGroupStats( GroupInfo const& _groupInfo,
method TestGroupStats (line 5288) | TestGroupStats( GroupInfo const& _groupInfo )
method TestGroupStats (line 5295) | TestGroupStats( TestGroupStats const& ) = default;
method TestGroupStats (line 5296) | TestGroupStats( TestGroupStats && ) = default;
method TestGroupStats (line 5297) | TestGroupStats& operator = ( TestGroupStats const& ) = default;
method TestGroupStats (line 5298) | TestGroupStats& operator = ( TestGroupStats && ) = default;
type TestRunStats (line 5306) | struct TestRunStats {
method TestRunStats (line 5307) | TestRunStats( TestRunInfo const& _runInfo,
method TestRunStats (line 5317) | TestRunStats( TestRunStats const& _other )
method TestRunStats (line 5323) | TestRunStats( TestRunStats const& ) = default;
method TestRunStats (line 5324) | TestRunStats( TestRunStats && ) = default;
method TestRunStats (line 5325) | TestRunStats& operator = ( TestRunStats const& ) = default;
method TestRunStats (line 5326) | TestRunStats& operator = ( TestRunStats && ) = default;
class MultipleReporters (line 5334) | class MultipleReporters
method add (line 8574) | void add( Ptr<IStreamingReporter> const& reporter ) {
method ReporterPreferences (line 8580) | virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
method noMatchingTestCases (line 8584) | virtual void noMatchingTestCases( std::string const& spec ) CATCH_OV...
method testRunStarting (line 8591) | virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH...
method testGroupStarting (line 8598) | virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_O...
method testCaseStarting (line 8605) | virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_...
method sectionStarting (line 8612) | virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH...
method assertionStarting (line 8619) | virtual void assertionStarting( AssertionInfo const& assertionInfo )...
method assertionEnded (line 8627) | virtual bool assertionEnded( AssertionStats const& assertionStats ) ...
method sectionEnded (line 8636) | virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_...
method testCaseEnded (line 8643) | virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CAT...
method testGroupEnded (line 8650) | virtual void testGroupEnded( TestGroupStats const& testGroupStats ) ...
method testRunEnded (line 8657) | virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_...
method skipTest (line 8664) | virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
method MultipleReporters (line 8671) | virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
type IStreamingReporter (line 5336) | struct IStreamingReporter : IShared {
method MultipleReporters (line 5364) | virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
type IReporterFactory (line 5367) | struct IReporterFactory : IShared {
type IReporterRegistry (line 5373) | struct IReporterRegistry {
function listTests (line 5392) | inline std::size_t listTests( Config const& config ) {
function listTestsNamesOnly (line 5430) | inline std::size_t listTestsNamesOnly( Config const& config ) {
type TagInfo (line 5449) | struct TagInfo {
method TagInfo (line 5450) | TagInfo() : count ( 0 ) {}
method add (line 5451) | void add( std::string const& spelling ) {
method all (line 5455) | std::string all() const {
function listTags (line 5467) | inline std::size_t listTags( Config const& config ) {
function listReporters (line 5511) | inline std::size_t listReporters( Config const& /*config*/ ) {
function list (line 5534) | inline Option<std::size_t> list( Config const& config ) {
type TestCaseTracking (line 5561) | namespace TestCaseTracking {
type ITracker (line 5563) | struct ITracker : SharedImpl<> {
class TrackerContext (line 5591) | class TrackerContext {
type RunState (line 5593) | enum RunState {
method TrackerContext (line 5605) | static TrackerContext& instance() {
method TrackerContext (line 5610) | TrackerContext()
method endRun (line 5617) | void endRun() {
method startCycle (line 5623) | void startCycle() {
method completeCycle (line 5627) | void completeCycle() {
method completedCycle (line 5631) | bool completedCycle() const {
method ITracker (line 5634) | ITracker& currentTracker() {
method setCurrentTracker (line 5637) | void setCurrentTracker( ITracker* tracker ) {
class TrackerBase (line 5642) | class TrackerBase : public ITracker {
type CycleState (line 5644) | enum CycleState {
class TrackerHasName (line 5652) | class TrackerHasName {
method TrackerHasName (line 5655) | TrackerHasName( std::string const& name ) : m_name( name ) {}
method TrackerBase (line 5667) | TrackerBase( std::string const& name, TrackerContext& ctx, ITracke...
method isComplete (line 5678) | virtual bool isComplete() const CATCH_OVERRIDE {
method isSuccessfullyCompleted (line 5681) | virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
method isOpen (line 5684) | virtual bool isOpen() const CATCH_OVERRIDE {
method hasChildren (line 5687) | virtual bool hasChildren() const CATCH_OVERRIDE {
method addChild (line 5691) | virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
method ITracker (line 5695) | virtual ITracker* findChild( std::string const& name ) CATCH_OVERR...
method ITracker (line 5701) | virtual ITracker& parent() CATCH_OVERRIDE {
method isSectionTracker (line 5714) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return fals...
method isIndexTracker (line 5715) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
method open (line 5717) | void open() {
method markAsNeedingAnotherRun (line 5760) | virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
method moveToParent (line 5764) | void moveToParent() {
method moveToThis (line 5768) | void moveToThis() {
class SectionTracker (line 5773) | class SectionTracker : public TrackerBase {
method SectionTracker (line 5775) | SectionTracker( std::string const& name, TrackerContext& ctx, ITra...
method isSectionTracker (line 5780) | virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
method SectionTracker (line 5782) | static SectionTracker& acquire( TrackerContext& ctx, std::string c...
class IndexTracker (line 5803) | class IndexTracker : public TrackerBase {
method IndexTracker (line 5807) | IndexTracker( std::string const& name, TrackerContext& ctx, ITrack...
method isIndexTracker (line 5814) | virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
method IndexTracker (line 5816) | static IndexTracker& acquire( TrackerContext& ctx, std::string con...
method index (line 5839) | int index() const { return m_index; }
method moveNext (line 5841) | void moveNext() {
function ITracker (line 5853) | inline ITracker& TrackerContext::startRun() {
function fatal (line 5875) | inline void fatal( std::string const& message, int exitCode ) {
type FatalConditionHandler (line 5890) | struct FatalConditionHandler {
method reset (line 5891) | void reset() {}
method handleSignal (line 5915) | static void handleSignal( int sig ) {
method FatalConditionHandler (line 5922) | FatalConditionHandler() : m_isSet( true ) {
method reset (line 5929) | void reset() {
type SignalDefs (line 5902) | struct SignalDefs { int id; const char* name; }
type FatalConditionHandler (line 5913) | struct FatalConditionHandler {
method reset (line 5891) | void reset() {}
method handleSignal (line 5915) | static void handleSignal( int sig ) {
method FatalConditionHandler (line 5922) | FatalConditionHandler() : m_isSet( true ) {
method reset (line 5929) | void reset() {
class StreamRedirect (line 5949) | class StreamRedirect {
method StreamRedirect (line 5952) | StreamRedirect( std::ostream& stream, std::string& targetString )
class RunContext (line 5974) | class RunContext : public IResultCapture, public IRunner {
method RunContext (line 5981) | explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreami...
method testGroupStarting (line 5998) | void testGroupStarting( std::string const& testSpec, std::size_t gro...
method testGroupEnded (line 6001) | void testGroupEnded( std::string const& testSpec, Totals const& tota...
method Totals (line 6005) | Totals runTest( TestCase const& testCase ) {
method config (line 6048) | Ptr<IConfig const> config() const {
method assertionEnded (line 6054) | virtual void assertionEnded( AssertionResult const& result ) {
method sectionStarted (line 6070) | virtual bool sectionStarted (
method testForMissingAssertions (line 6091) | bool testForMissingAssertions( Counts& assertions ) {
method sectionEnded (line 6103) | virtual void sectionEnded( SectionEndInfo const& endInfo ) {
method sectionEndedEarly (line 6116) | virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) {
method pushScopedMessage (line 6126) | virtual void pushScopedMessage( MessageInfo const& message ) {
method popScopedMessage (line 6130) | virtual void popScopedMessage( MessageInfo const& message ) {
method getCurrentTestName (line 6134) | virtual std::string getCurrentTestName() const {
method AssertionResult (line 6140) | virtual const AssertionResult* getLastResult() const {
method handleFatalErrorCondition (line 6144) | virtual void handleFatalErrorCondition( std::string const& message ) {
method aborting (line 6177) | bool aborting() const {
method runCurrentTest (line 6183) | void runCurrentTest( std::string& redirectedCout, std::string& redir...
method invokeActiveTestCase (line 6229) | void invokeActiveTestCase() {
method ResultBuilder (line 6237) | ResultBuilder makeUnexpectedResultBuilder() const {
method handleUnfinishedSections (line 6244) | void handleUnfinishedSections() {
function IResultCapture (line 6272) | IResultCapture& getResultCapture() {
type Version (line 6287) | struct Version {
function createReporter (line 6317) | Ptr<IStreamingReporter> createReporter( std::string const& reporterNam...
function makeReporter (line 6327) | Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
function addListeners (line 6339) | Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config...
function Totals (line 6348) | Totals runTests( Ptr<Config> const& config ) {
method Totals (line 2255) | Totals operator - ( Totals const& other ) const {
method Totals (line 2262) | Totals delta( Totals const& prevTotals ) const {
method Totals (line 2273) | Totals& operator += ( Totals const& other ) {
function applyFilenamesAsTags (line 6379) | void applyFilenamesAsTags( IConfig const& config ) {
class Session (line 6399) | class Session : NonCopyable {
type OnUnusedOptions (line 6404) | struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }
type DoWhat (line 6404) | enum DoWhat { Ignore, Fail }
method Session (line 6406) | Session()
method showHelp (line 6419) | void showHelp( std::string const& processName ) {
method applyCommandLine (line 6426) | int applyCommandLine( int argc, char const* const* const argv, OnUnu...
method useConfigData (line 6448) | void useConfigData( ConfigData const& _configData ) {
method run (line 6453) | int run( int argc, char const* const* const argv ) {
method run (line 6461) | int run() {
method ConfigData (line 6492) | ConfigData& configData() {
method Config (line 6495) | Config& config() {
type RandomNumberGenerator (line 6525) | struct RandomNumberGenerator {
method result_type (line 6528) | result_type operator()( result_type n ) const { return std::rand() %...
method result_type (line 6531) | static constexpr result_type min() { return 0; }
method result_type (line 6532) | static constexpr result_type max() { return 1000000; }
method result_type (line 6533) | result_type operator()() const { return std::rand() % max(); }
method shuffle (line 6536) | static void shuffle( V& vector ) {
function sortTests (line 6546) | inline std::vector<TestCase> sortTests( IConfig const& config, std::ve...
function matchTest (line 6566) | bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IC...
function enforceNoDuplicateTestCases (line 6570) | void enforceNoDuplicateTestCases( std::vector<TestCase> const& functio...
function filterTests (line 6589) | std::vector<TestCase> filterTests( std::vector<TestCase> const& testCa...
class TestRegistry (line 6603) | class TestRegistry : public ITestCaseRegistry {
method TestRegistry (line 6605) | TestRegistry()
method registerTest (line 6611) | virtual void registerTest( TestCase const& testCase ) {
class FreeFunctionTestCase (line 6645) | class FreeFunctionTestCase : public SharedImpl<ITestCase> {
method FreeFunctionTestCase (line 6648) | FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
method invoke (line 6650) | virtual void invoke() const {
function extractClassName (line 6660) | inline std::string extractClassName( std::string const& classOrQualifi...
function registerTestCase (line 6673) | void registerTestCase
function registerTestCaseFunction (line 6687) | void registerTestCaseFunction
class ReporterRegistry (line 6714) | class ReporterRegistry : public IReporterRegistry {
method IStreamingReporter (line 6720) | virtual IStreamingReporter* create( std::string const& name, Ptr<ICo...
method registerReporter (line 6727) | void registerReporter( std::string const& name, Ptr<IReporterFactory...
method registerListener (line 6730) | void registerListener( Ptr<IReporterFactory> const& factory ) {
method FactoryMap (line 6734) | virtual FactoryMap const& getFactories() const CATCH_OVERRIDE {
method Listeners (line 6737) | virtual Listeners const& getListeners() const CATCH_OVERRIDE {
class ExceptionTranslatorRegistry (line 6756) | class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
method registerTranslator (line 6762) | virtual void registerTranslator( const IExceptionTranslator* transla...
method translateActiveException (line 6766) | virtual std::string translateActiveException() const {
method tryTranslators (line 6797) | std::string tryTranslators() const {
class RegistryHub (line 6813) | class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
method RegistryHub (line 6819) | RegistryHub() {
method IReporterRegistry (line 6821) | virtual IReporterRegistry const& getReporterRegistry() const CATCH_O...
method ITestCaseRegistry (line 6824) | virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_O...
method IExceptionTranslatorRegistry (line 6827) | virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry...
method registerReporter (line 6832) | virtual void registerReporter( std::string const& name, Ptr<IReporte...
method registerListener (line 6835) | virtual void registerListener( Ptr<IReporterFactory> const& factory ...
method registerTest (line 6838) | virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
method registerTranslator (line 6841) | virtual void registerTranslator( const IExceptionTranslator* transla...
function RegistryHub (line 6852) | inline RegistryHub*& getTheRegistryHub() {
method RegistryHub (line 6819) | RegistryHub() {
method IReporterRegistry (line 6821) | virtual IReporterRegistry const& getReporterRegistry() const CATCH_O...
method ITestCaseRegistry (line 6824) | virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_O...
method IExceptionTranslatorRegistry (line 6827) | virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry...
method registerReporter (line 6832) | virtual void registerReporter( std::string const& name, Ptr<IReporte...
method registerListener (line 6835) | virtual void registerListener( Ptr<IReporterFactory> const& factory ...
method registerTest (line 6838) | virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
method registerTranslator (line 6841) | virtual void registerTranslator( const IExceptionTranslator* transla...
function IRegistryHub (line 6860) | IRegistryHub& getRegistryHub() {
function IMutableRegistryHub (line 6863) | IMutableRegistryHub& getMutableRegistryHub() {
function cleanUp (line 6866) | void cleanUp() {
function translateActiveException (line 6871) | std::string translateActiveException() {
class StreamBufImpl (line 6911) | class StreamBufImpl : public StreamBufBase {
method StreamBufImpl (line 6916) | StreamBufImpl() {
method overflow (line 6925) | int overflow( int c ) {
method sync (line 6937) | int sync() {
type OutputDebugWriter (line 6961) | struct OutputDebugWriter {
class Context (line 6999) | class Context : public IMutableContext {
method Context (line 7001) | Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_result...
method IResultCapture (line 7011) | virtual IResultCapture* getResultCapture() {
method IRunner (line 7014) | virtual IRunner* getRunner() {
method getGeneratorIndex (line 7017) | virtual size_t getGeneratorIndex( std::string const& fileInfo, size_...
method advanceGeneratorsForCurrentTest (line 7022) | virtual bool advanceGeneratorsForCurrentTest() {
method getConfig (line 7027) | virtual Ptr<IConfig const> getConfig() const {
method setResultCapture (line 7032) | virtual void setResultCapture( IResultCapture* resultCapture ) {
method setRunner (line 7035) | virtual void setRunner( IRunner* runner ) {
method setConfig (line 7038) | virtual void setConfig( Ptr<IConfig const> const& config ) {
method IGeneratorsForTest (line 7045) | IGeneratorsForTest* findGeneratorsForCurrentTest() {
method IGeneratorsForTest (line 7055) | IGeneratorsForTest& getGeneratorsForCurrentTest() {
function IMutableContext (line 7075) | IMutableContext& getCurrentMutableContext() {
function IContext (line 7080) | IContext& getCurrentContext() {
function cleanUpContext (line 7084) | void cleanUpContext() {
type IColourImpl (line 7096) | struct IColourImpl {
type NoColourImpl (line 7101) | struct NoColourImpl : IColourImpl {
method use (line 7102) | void use( Colour::Code ) {}
method IColourImpl (line 7104) | static IColourImpl* instance() {
class Win32ColourImpl (line 7150) | class Win32ColourImpl : public IColourImpl {
method Win32ColourImpl (line 7152) | Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
method use (line 7160) | virtual void use( Colour::Code _colourCode ) {
method setTextAttribute (line 7181) | void setTextAttribute( WORD _textAttribute ) {
function IColourImpl (line 7189) | IColourImpl* platformColourInstance() {
class PosixColourImpl (line 7219) | class PosixColourImpl : public IColourImpl {
method use (line 7221) | virtual void use( Colour::Code _colourCode ) {
method IColourImpl (line 7240) | static IColourImpl* instance() {
method setColour (line 7246) | void setColour( const char* _escapeCode ) {
function IColourImpl (line 7251) | IColourImpl* platformColourInstance() {
function IColourImpl (line 7272) | static IColourImpl* platformColourInstance() { return NoColourImpl::in...
type GeneratorInfo (line 7300) | struct GeneratorInfo : IGeneratorInfo {
method GeneratorInfo (line 7302) | GeneratorInfo( std::size_t size )
method moveNext (line 7307) | bool moveNext() {
method getCurrentIndex (line 7315) | std::size_t getCurrentIndex() const {
class GeneratorsForTest (line 7325) | class GeneratorsForTest : public IGeneratorsForTest {
method IGeneratorInfo (line 7332) | IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::...
method moveNext (line 7343) | bool moveNext() {
function IGeneratorsForTest (line 7358) | IGeneratorsForTest* createGeneratorsForTest()
function SourceLineInfo (line 7435) | SourceLineInfo AssertionResult::getSourceInfo() const {
method SourceLineInfo (line 402) | SourceLineInfo( SourceLineInfo && ) = default;
method SourceLineInfo (line 403) | SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
method SourceLineInfo (line 404) | SourceLineInfo& operator = ( SourceLineInfo && ) = default;
function parseSpecialTag (line 7450) | inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string co...
function isReservedTag (line 7464) | inline bool isReservedTag( std::string const& tag ) {
function enforceNotReservedTag (line 7467) | inline void enforceNotReservedTag( std::string const& tag, SourceLineI...
function TestCase (line 7483) | TestCase makeTestCase( ITestCase* _testCase,
function setTags (line 7528) | void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const&...
function TestCase (line 7588) | TestCase TestCase::withName( std::string const& _newName ) const {
function TestCase (line 7619) | TestCase& TestCase::operator = ( TestCase const& other ) {
function TestCaseInfo (line 7625) | TestCaseInfo const& TestCase::getTestCaseInfo() const
type SpecialProperties (line 2868) | enum SpecialProperties{
type IReporter (line 7710) | struct IReporter : IShared {
class LegacyReporterAdapter (line 7729) | class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
function ReporterPreferences (line 7761) | ReporterPreferences LegacyReporterAdapter::getPreferences() const {
method ReporterPreferences (line 5156) | ReporterPreferences()
function getCurrentTicks (line 7841) | uint64_t getCurrentTicks() {
function getCurrentTicks (line 7852) | uint64_t getCurrentTicks() {
function startsWith (line 7883) | bool startsWith( std::string const& s, std::string const& prefix ) {
function endsWith (line 7886) | bool endsWith( std::string const& s, std::string const& suffix ) {
function contains (line 7889) | bool contains( std::string const& s, std::string const& infix ) {
function toLowerCh (line 7892) | char toLowerCh(char c) {
function toLowerInPlace (line 7895) | void toLowerInPlace( std::string& s ) {
function toLower (line 7898) | std::string toLower( std::string const& s ) {
function trim (line 7903) | std::string trim( std::string const& str ) {
function replaceInPlace (line 7911) | bool replaceInPlace( std::string& str, std::string const& replaceThis,...
function seedRng (line 7956) | void seedRng( IConfig const& config ) {
function rngSeed (line 7960) | unsigned int rngSeed() {
function throwLogicError (line 7973) | void throwLogicError( std::string const& message, SourceLineInfo const...
function isDebuggerActive (line 8039) | bool isDebuggerActive(){
function isDebuggerActive (line 8084) | bool isDebuggerActive(){
function isDebuggerActive (line 8102) | bool isDebuggerActive() {
function isDebuggerActive (line 8109) | bool isDebuggerActive() {
function isDebuggerActive (line 8115) | inline bool isDebuggerActive() { return false; }
function writeToDebugConsole (line 8122) | void writeToDebugConsole( std::string const& text ) {
function writeToDebugConsole (line 8128) | void writeToDebugConsole( std::string const& text ) {
type Detail (line 8140) | namespace Detail {
type BorgType (line 1614) | struct BorgType {
type TrueType (line 1618) | struct TrueType { char sizer[1]; }
type FalseType (line 1619) | struct FalseType { char sizer[2]; }
type IsStreamInsertable (line 1627) | struct IsStreamInsertable {
type EnumStringMaker (line 1637) | struct EnumStringMaker
method convert (line 1639) | static std::string convert( T const& ) { return unprintableString; }
type EnumStringMaker<T,true> (line 1643) | struct EnumStringMaker<T,true>
method convert (line 1645) | static std::string convert( T const& v )
type StringMakerBase (line 1654) | struct StringMakerBase {
method convert (line 1657) | static std::string convert( T const& v )
method convert (line 1663) | static std::string convert( T const& ) { return unprintableString; }
type StringMakerBase<true> (line 1668) | struct StringMakerBase<true> {
method convert (line 1670) | static std::string convert( T const& _value ) {
function rawMemoryToString (line 1680) | inline std::string rawMemoryToString( const T& object ) {
function makeString (line 1772) | std::string makeString( T const& value ) {
function rangeToString (line 1791) | std::string rangeToString( InputIterator first, InputIterator last ) {
class Approx (line 2657) | class Approx {
method Approx (line 2659) | explicit Approx ( double value )
method Approx (line 2665) | Approx( Approx const& other )
method Approx (line 2671) | static Approx custom() {
method Approx (line 2675) | Approx operator()( double value ) {
method Approx (line 2719) | Approx& epsilon( double newEpsilon ) {
method Approx (line 2724) | Approx& scale( double newScale ) {
method toString (line 2729) | std::string toString() const {
type Endianness (line 8147) | struct Endianness {
type Arch (line 8148) | enum
Condensed preview — 458 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,542K chars).
[
{
"path": ".gitignore",
"chars": 512,
"preview": "bin\nbuild\nnode_modules\ntypes\n\n# ignore all js files under lib except explicit ones specified here\nlib/**/*.js\n!lib/core/"
},
{
"path": ".npmignore",
"chars": 277,
"preview": "bin\nbuild\nexamples\n\n# Exclude TypeScript source files.\nbenchmark/**/*.ts\nbenchmark/tsconfig.json\nlib/**/*.ts\nlib/tsconfi"
},
{
"path": ".travis.yml",
"chars": 2234,
"preview": "language: node_js\ncompiler: default\nmatrix:\n exclude:\n # Disable the default build and use customized matrix only.\n -"
},
{
"path": "CMakeLists.txt",
"chars": 1649,
"preview": "cmake_minimum_required(VERSION 3.2 FATAL_ERROR)\n\nproject(\"napa\")\n\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_S"
},
{
"path": "LICENSE.txt",
"chars": 1107,
"preview": "Napa.JS\n\nCopyright (c) Microsoft Corporation. All rights reserved. \n\nMIT License\n\nPermission is hereby granted, free of "
},
{
"path": "README.md",
"chars": 3310,
"preview": "[](https://travis-ci.org/Micros"
},
{
"path": "appveyor.yml",
"chars": 804,
"preview": "environment:\n matrix:\n # Windows Server 2012 R2 Visual C++ Build Tools 2015\n - APPVEYOR_BUILD_WORKER_IMAGE:"
},
{
"path": "benchmark/README.md",
"chars": 11405,
"preview": "# Benchmark\n\n## Summary\n- JavaScript execution in napajs is on par with node, using the same version of V8, which is exp"
},
{
"path": "benchmark/bench-utils.ts",
"chars": 1535,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/// <summary> Utility f"
},
{
"path": "benchmark/bench.ts",
"chars": 989,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/execute-overhead.ts",
"chars": 2583,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/execute-scalability.ts",
"chars": 2757,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/node-napa-perf-comparison.ts",
"chars": 1180,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/store-overhead.ts",
"chars": 3299,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/transport-overhead.ts",
"chars": 3612,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as napa from '"
},
{
"path": "benchmark/tsconfig.json",
"chars": 245,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "build.bat",
"chars": 215,
"preview": ":: Copyright (c) Microsoft Corporation. All rights reserved.\n:: Licensed under the MIT license.\n@echo off\n\nset NODE_EXE="
},
{
"path": "build.js",
"chars": 1034,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n// Distinguish between "
},
{
"path": "docs/api/index.md",
"chars": 712,
"preview": "# API References\n\n## Core modules\n- Napa.js specific [`global`](./napa-globals.md) variables\n- Namespace [`zone`](./zone"
},
{
"path": "docs/api/log.md",
"chars": 3368,
"preview": "# Function `log`\n\n## Table of Contents\n- [Introduction](#intro)\n- [C++ API](#cpp-api)\n- [JavaScript API](#js-api)\n - "
},
{
"path": "docs/api/memory.md",
"chars": 3712,
"preview": "# Namespace `memory`\n\n## Table of Contents\n- [API](#api)\n - Type [`Handle`](#handle)\n - Interface [`Shareable`](#s"
},
{
"path": "docs/api/metric.md",
"chars": 9279,
"preview": "# Namespace `metric`\n\n## Table of Contents\n- [Introduction](#intro)\n- [C++ API](#cpp-api)\n - Interface [`Metric`](#cp"
},
{
"path": "docs/api/module.md",
"chars": 6019,
"preview": "# Napa.js Module\n\n## Table of Contents\n- [Introduction](#intro)\n- [Developing modules](#develop-modules)\n - [Module: Ja"
},
{
"path": "docs/api/napa-globals.md",
"chars": 528,
"preview": "# Napa.js specific global variables\n\nThis file describes Napa.js specific globals, please refer to [this documentation]("
},
{
"path": "docs/api/node-api.md",
"chars": 2475,
"preview": "# Node.js Compatibility\n\nNapa.js doesn't support full compatibility with node.js and necessary core modules will be adde"
},
{
"path": "docs/api/store.md",
"chars": 3510,
"preview": "# Namespace `store`\n\n## Table of Contents\n- [Introduction](#intro)\n- [API](#api)\n - [`create(id: string): Store`](#cr"
},
{
"path": "docs/api/sync.md",
"chars": 3336,
"preview": "# Namespace `sync`\n## Table of Contents\n- class [`Lock`](#interface-lock)\n - [`lock.guardSync(func: (...params: any[]"
},
{
"path": "docs/api/transport.md",
"chars": 10163,
"preview": "# Namespace `transport`\n\n## Table of Contents\n- [Introduction](#intro)\n - [Transportable types](#transportable-types)"
},
{
"path": "docs/api/zone.md",
"chars": 14016,
"preview": "# Namespace `zone`\n\n## Table of Contents\n- [Introduction](#intro)\n - [Multiple workers vs Multiple zones](#worker-vs-"
},
{
"path": "docs/design/transport-js-builtins.md",
"chars": 9239,
"preview": "# Transport JavaScript standard built-in objects\n\n## Incentives\nThe abstraction of 'Transportable' lies in the center of"
},
{
"path": "examples/modules/README.md",
"chars": 1165,
"preview": "## Napa module source tree\n\nThe source codes can be organized as the structure below.\n```\n+-- napa-module-example\n +-"
},
{
"path": "examples/modules/async-number/.gitignore",
"chars": 134,
"preview": "bin\nbuild\nnode_modules\ntypes\n\n# ignore all js files under lib\nlib/*.js\n\n# ignore all js files under test\ntest/*.js\n\npack"
},
{
"path": "examples/modules/async-number/.npmignore",
"chars": 102,
"preview": "bin\nbuild\n\n# Exclude TypeScript source files.\nlib/*.ts\nlib/tsconfig.json\ntest/*.ts\ntest/tsconfig.json\n"
},
{
"path": "examples/modules/async-number/README.md",
"chars": 8338,
"preview": "# Asynchronous numbering\n\n## APIs\n\nNapa provides two functions to support asynchronous call and they work for both node."
},
{
"path": "examples/modules/async-number/binding.gyp",
"chars": 922,
"preview": "{\n \"variables\": {\n \"napajs_lib\": \"<!(node -e \\\"require('napajs/build').paths.lib\\\")\",\n \"napajs_inc\": \"<!(node -e "
},
{
"path": "examples/modules/async-number/lib/async-number.ts",
"chars": 445,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet addon = require('.."
},
{
"path": "examples/modules/async-number/lib/tsconfig.json",
"chars": 282,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/async-number/napa/addon.cpp",
"chars": 3120,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include <napa/module.h"
},
{
"path": "examples/modules/async-number/package.json",
"chars": 637,
"preview": "{\n \"name\": \"async-number\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"description\": \"Example of an async napa modul"
},
{
"path": "examples/modules/async-number/test/test.ts",
"chars": 2786,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet assert = require('a"
},
{
"path": "examples/modules/async-number/test/tsconfig.json",
"chars": 245,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/hello-world/.gitignore",
"chars": 134,
"preview": "bin\nbuild\nnode_modules\ntypes\n\n# ignore all js files under lib\nlib/*.js\n\n# ignore all js files under test\ntest/*.js\n\npack"
},
{
"path": "examples/modules/hello-world/.npmignore",
"chars": 102,
"preview": "bin\nbuild\n\n# Exclude TypeScript source files.\nlib/*.ts\nlib/tsconfig.json\ntest/*.ts\ntest/tsconfig.json\n"
},
{
"path": "examples/modules/hello-world/README.md",
"chars": 1741,
"preview": "# Hello World\n\nThis example shows the simple napa module, which shows the basic difference between node.js module and na"
},
{
"path": "examples/modules/hello-world/binding.gyp",
"chars": 921,
"preview": "{\n \"variables\": {\n \"napajs_lib\": \"<!(node -e \\\"require('napajs/build').paths.lib\\\")\",\n \"napajs_inc\": \"<!(node -e "
},
{
"path": "examples/modules/hello-world/lib/hello-world.ts",
"chars": 197,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet addon = require('.."
},
{
"path": "examples/modules/hello-world/lib/tsconfig.json",
"chars": 282,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/hello-world/napa/addon.cpp",
"chars": 498,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include <napa/module.h"
},
{
"path": "examples/modules/hello-world/package.json",
"chars": 634,
"preview": "{\n \"name\": \"hello-world\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"description\": \"Example of a simple napa module"
},
{
"path": "examples/modules/hello-world/test/test.ts",
"chars": 778,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet assert = require('a"
},
{
"path": "examples/modules/hello-world/test/tsconfig.json",
"chars": 245,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/plus-number/.gitignore",
"chars": 134,
"preview": "bin\nbuild\nnode_modules\ntypes\n\n# ignore all js files under lib\nlib/*.js\n\n# ignore all js files under test\ntest/*.js\n\npack"
},
{
"path": "examples/modules/plus-number/.npmignore",
"chars": 111,
"preview": "bin\nbuild\nunittest\n\n# Exclude TypeScript source files.\nlib/*.ts\nlib/tsconfig.json\ntest/*.ts\ntest/tsconfig.json\n"
},
{
"path": "examples/modules/plus-number/CMakeLists.txt",
"chars": 664,
"preview": "cmake_minimum_required(VERSION 3.2 FATAL_ERROR)\n\nproject(\"addon\")\n\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_"
},
{
"path": "examples/modules/plus-number/README.md",
"chars": 7934,
"preview": "# Plus Number\n\nThis example shows the napa module, which wraps C++ objects/classes. Instead of using Javascript *new* op"
},
{
"path": "examples/modules/plus-number/inc/plus-number.h",
"chars": 872,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#if defin"
},
{
"path": "examples/modules/plus-number/lib/plus-number.ts",
"chars": 323,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet addon = require('.."
},
{
"path": "examples/modules/plus-number/lib/tsconfig.json",
"chars": 282,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/plus-number/napa/CMakeLists.txt",
"chars": 1841,
"preview": "execute_process(COMMAND node -e \"require('napajs/build').paths.inc\" RESULT_VARIABLE ERR OUTPUT_VARIABLE NAPAJS_INC)\nif(E"
},
{
"path": "examples/modules/plus-number/napa/addon.cpp",
"chars": 451,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"plus-number-w"
},
{
"path": "examples/modules/plus-number/napa/plus-number-wrap.cpp",
"chars": 2634,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"plus-number-w"
},
{
"path": "examples/modules/plus-number/napa/plus-number-wrap.h",
"chars": 1681,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "examples/modules/plus-number/package.json",
"chars": 646,
"preview": "{\n \"name\": \"plus-number\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"description\": \"Example of a napa module wrappi"
},
{
"path": "examples/modules/plus-number/src/CMakeLists.txt",
"chars": 311,
"preview": "# Build plus-number library.\nset(TARGET_NAME \"plus-number\")\n\n# The generated library\nadd_library(${TARGET_NAME} SHARED \""
},
{
"path": "examples/modules/plus-number/src/plus-number.cpp",
"chars": 282,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"plus-number.h"
},
{
"path": "examples/modules/plus-number/test/test.ts",
"chars": 1482,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet assert = require('a"
},
{
"path": "examples/modules/plus-number/test/tsconfig.json",
"chars": 245,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "examples/modules/plus-number/unittest/CMakeLists.txt",
"chars": 1449,
"preview": "cmake_minimum_required(VERSION 3.2 FATAL_ERROR)\n\nproject(\"library-test\")\n\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${P"
},
{
"path": "examples/modules/plus-number/unittest/catch/LICENSE.txt",
"chars": 1337,
"preview": "Boost Software License - Version 1.0 - August 17th, 2003\n\nPermission is hereby granted, free of charge, to any person or"
},
{
"path": "examples/modules/plus-number/unittest/catch/catch.hpp",
"chars": 384568,
"preview": "/*\n * Catch v1.6.1\n * Generated: 2017-01-20 12:33:53.497767\n * ------------------------------------------------------"
},
{
"path": "examples/modules/plus-number/unittest/main.cpp",
"chars": 369,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"plus-number.h"
},
{
"path": "examples/modules/plus-number/unittest/run.js",
"chars": 472,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nvar path = require('pat"
},
{
"path": "examples/tutorial/estimate-pi-in-parallel/README.md",
"chars": 2627,
"preview": "# Estimate PI in parallel\nThis example implements an algorithm to [estimate PI using Monte Carlo method](http://mathfacu"
},
{
"path": "examples/tutorial/estimate-pi-in-parallel/estimate-pi-in-parallel.js",
"chars": 2156,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nvar napa = require(\"nap"
},
{
"path": "examples/tutorial/estimate-pi-in-parallel/package.json",
"chars": 184,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"main\": \"./estimate-pi-in-parallel."
},
{
"path": "examples/tutorial/max-square-sub-matrix/README.md",
"chars": 2773,
"preview": "# Max square sub matrix\nThis example implements an algorithm to solve [Max square sub-matrix of all 1s](http://www.geeks"
},
{
"path": "examples/tutorial/max-square-sub-matrix/max-square-sub-matrix.js",
"chars": 6089,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nvar napa = require(\"nap"
},
{
"path": "examples/tutorial/max-square-sub-matrix/package.json",
"chars": 182,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"main\": \"./max-square-sub-matrix.js"
},
{
"path": "examples/tutorial/napa-runner/CMakeLists.txt",
"chars": 2018,
"preview": "cmake_minimum_required(VERSION 3.2 FATAL_ERROR)\n\nproject(\"napa-runer\")\n\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PRO"
},
{
"path": "examples/tutorial/napa-runner/README.md",
"chars": 1102,
"preview": "# Napa runner\nNapa runner is an example to embed Napa.JS into a C++ program. It simply runs JavaScript with all Napa cap"
},
{
"path": "examples/tutorial/napa-runner/estimate-PI.js",
"chars": 1093,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nfunction estimatePI(poi"
},
{
"path": "examples/tutorial/napa-runner/main.cpp",
"chars": 1646,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include <napa.h>\n\n#inc"
},
{
"path": "examples/tutorial/napa-runner/package.json",
"chars": 140,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"dependencies\": {\n \"napajs\":"
},
{
"path": "examples/tutorial/parallel-quick-sort/README.md",
"chars": 1756,
"preview": "# Parallel Quick Sort\nThis example implements a parallel version of quicksort by napa.js, and compares its performance t"
},
{
"path": "examples/tutorial/parallel-quick-sort/package.json",
"chars": 180,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"main\": \"./parallel-quick-sort.js\","
},
{
"path": "examples/tutorial/parallel-quick-sort/parallel-quick-sort.js",
"chars": 3865,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nconst napa = require(\"n"
},
{
"path": "examples/tutorial/recursive-fibonacci/README.md",
"chars": 2445,
"preview": "# Recursive Fibonacci\nThis example implements an algorithm to calculate [Fibonacci numbers](https://en.wikipedia.org/wik"
},
{
"path": "examples/tutorial/recursive-fibonacci/package.json",
"chars": 180,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"main\": \"./recursive-fibonacci.js\","
},
{
"path": "examples/tutorial/recursive-fibonacci/recursive-fibonacci.js",
"chars": 2347,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nvar napa = require(\"nap"
},
{
"path": "examples/tutorial/synchronized-loading/README.md",
"chars": 1036,
"preview": "# Synchronized loading\nThis example implements a shared phone book component. The component will not load data until the"
},
{
"path": "examples/tutorial/synchronized-loading/package.json",
"chars": 181,
"preview": "{\n \"name\": \"napajs-tutorial\",\n \"version\": \"0.1.0\",\n \"author\": \"napajs\",\n \"main\": \"./synchronized-loading.js\""
},
{
"path": "examples/tutorial/synchronized-loading/phone-book-data.json",
"chars": 118,
"preview": "{\n \"ashley\": \"123-456-7890\",\n \"david\": \"123-444-5555\",\n \"lisa\": \"567-888-9999\",\n \"tony\": \"456-789-0000\"\n}\n"
},
{
"path": "examples/tutorial/synchronized-loading/phone-book.js",
"chars": 1036,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nconst napa = require(\"n"
},
{
"path": "examples/tutorial/synchronized-loading/synchronized-loading.js",
"chars": 1356,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nconst napa = require(\"n"
},
{
"path": "inc/napa/assert.h",
"chars": 1317,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/async.h",
"chars": 238,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#ifdef BU"
},
{
"path": "inc/napa/capi.h",
"chars": 6309,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/exports.h",
"chars": 926,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n// Micros"
},
{
"path": "inc/napa/log.h",
"chars": 3188,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/memory/allocator-debugger.h",
"chars": 4313,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n#pragma once\r\n\r\n#inc"
},
{
"path": "inc/napa/memory/allocator.h",
"chars": 1646,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/memory/common.h",
"chars": 1701,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/memory.h",
"chars": 900,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/binding/basic-wraps.h",
"chars": 892,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/binding/wraps.h",
"chars": 1132,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/binding.h",
"chars": 6521,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/common.h",
"chars": 1931,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/module-internal.h",
"chars": 4024,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/module-node-compat.h",
"chars": 512,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n/// <summ"
},
{
"path": "inc/napa/module/object-wrap.h",
"chars": 3421,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/shareable-wrap.h",
"chars": 9080,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module/transport-context-wrap.h",
"chars": 538,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/module.h",
"chars": 4783,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n// Suppre"
},
{
"path": "inc/napa/providers/logging.h",
"chars": 2645,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/providers/metric.h",
"chars": 5331,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/result-codes.inc",
"chars": 1670,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n///\n/// Napa result cod"
},
{
"path": "inc/napa/stl/allocator.h",
"chars": 4836,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/deque.h",
"chars": 298,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/list.h",
"chars": 296,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/map.h",
"chars": 569,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/queue.h",
"chars": 439,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/set.h",
"chars": 491,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/stack.h",
"chars": 322,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/string.h",
"chars": 1392,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/unordered_map.h",
"chars": 947,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/unordered_set.h",
"chars": 721,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/stl/vector.h",
"chars": 301,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/transport/transport-context.h",
"chars": 2674,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/transport/transport.h",
"chars": 5342,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/transport/transportable.h",
"chars": 5286,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/transport.h",
"chars": 237,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/types.h",
"chars": 5678,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/utils.h",
"chars": 615,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/array.h",
"chars": 735,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/console.h",
"chars": 887,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/conversion.h",
"chars": 1795,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/flow.h",
"chars": 2843,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/function.h",
"chars": 2708,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/json.h",
"chars": 1439,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/maybe.h",
"chars": 878,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/object.h",
"chars": 1185,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/ptr.h",
"chars": 3381,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/string.h",
"chars": 7764,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers/time.h",
"chars": 1713,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/v8-helpers.h",
"chars": 467,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/version.h",
"chars": 131,
"preview": "#pragma once\n\n#ifndef NAPA_VERSION\n\n#define NAPA_VERSION_MAJOR 0\n#define NAPA_VERSION_MINOR 1\n#define NAPA_VERSION_PATCH"
},
{
"path": "inc/napa/zone/napa-async-runner.h",
"chars": 2408,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/zone/node-async-runner.h",
"chars": 6840,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa/zone.h",
"chars": 7637,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "inc/napa.h",
"chars": 454,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#ifdef BU"
},
{
"path": "lib/binding.js",
"chars": 1220,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nfunction checkNodeVersi"
},
{
"path": "lib/core/.gitignore",
"chars": 146,
"preview": "# Ignore all .js files by default\n**/*.js\n\n# Specify all .js files to preserve explicitly\n!/assert.js\n!/events.js\n!/proc"
},
{
"path": "lib/core/.npmignore",
"chars": 56,
"preview": "# Keep this file so that npm can pick up correct files.\n"
},
{
"path": "lib/core/README.md",
"chars": 3350,
"preview": "# Napa.js core modules development guideline\n\n## Summary\n\nA Napa.js **core module** is a module that provided by Napa.js"
},
{
"path": "lib/core/core-modules.json",
"chars": 377,
"preview": "[\n {\n \"name\": \"assert\",\n \"type\": \"core\"\n },\n {\n \"name\": \"events\",\n \"type\": \"core\"\n "
},
{
"path": "lib/core/timers/timer-api.ts",
"chars": 1074,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Timeout, Immed"
},
{
"path": "lib/core/timers/timer.ts",
"chars": 998,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/// <summary> Timer is "
},
{
"path": "lib/core/timers.ts",
"chars": 68,
"preview": "export * from './timers/timer';\nexport * from './timers/timer-api';\n"
},
{
"path": "lib/index.ts",
"chars": 713,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { log } from './"
},
{
"path": "lib/log.ts",
"chars": 2257,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet binding = require('"
},
{
"path": "lib/memory/allocator.ts",
"chars": 1709,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Handle } from "
},
{
"path": "lib/memory/handle.ts",
"chars": 594,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport type Handle = [n"
},
{
"path": "lib/memory/shareable.ts",
"chars": 1121,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Handle} from '"
},
{
"path": "lib/memory.ts",
"chars": 202,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport * from './memory"
},
{
"path": "lib/metric.ts",
"chars": 1065,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet binding = require('"
},
{
"path": "lib/runtime/platform.ts",
"chars": 1564,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet binding = require('"
},
{
"path": "lib/runtime.ts",
"chars": 160,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport { \n setPlatfo"
},
{
"path": "lib/store/store-api.ts",
"chars": 1685,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Store } from '"
},
{
"path": "lib/store/store.ts",
"chars": 1339,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/// <summary> Store is "
},
{
"path": "lib/store.ts",
"chars": 162,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport * from './store/"
},
{
"path": "lib/sync/lock.ts",
"chars": 1057,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet binding = require('"
},
{
"path": "lib/sync.ts",
"chars": 126,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport * from './sync/l"
},
{
"path": "lib/transport/builtin-object-transporter.ts",
"chars": 533,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Shareable } fr"
},
{
"path": "lib/transport/function-transporter.ts",
"chars": 4352,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n///////////////////////"
},
{
"path": "lib/transport/transport.ts",
"chars": 5609,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as transportab"
},
{
"path": "lib/transport/transportable.ts",
"chars": 8507,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/// <summary> In Napa.J"
},
{
"path": "lib/transport.ts",
"chars": 848,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport {\n Transporta"
},
{
"path": "lib/tsconfig.json",
"chars": 281,
"preview": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"target\": \"es5\",\n \"experimentalDecorators\": true"
},
{
"path": "lib/v8/stack-trace.ts",
"chars": 3279,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/// Reference: https://"
},
{
"path": "lib/v8.ts",
"chars": 130,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nexport * from './v8/sta"
},
{
"path": "lib/zone/function-call.ts",
"chars": 4911,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as transport f"
},
{
"path": "lib/zone/zone-impl.ts",
"chars": 6515,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as path from '"
},
{
"path": "lib/zone/zone.ts",
"chars": 7228,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as transport f"
},
{
"path": "lib/zone.ts",
"chars": 1668,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport * as zone from '"
},
{
"path": "node/CMakeLists.txt",
"chars": 2296,
"preview": "# Files to compile\r\n# Note: Do not add napa core-modules cpp files that not needed in node isolation, \r\n# like timer-wra"
},
{
"path": "node/addon.cpp",
"chars": 1613,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"napa-binding."
},
{
"path": "node/node-zone-delegates.cpp",
"chars": 1779,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"node-zone-del"
},
{
"path": "node/node-zone-delegates.h",
"chars": 453,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "package.json",
"chars": 1466,
"preview": "{\n \"name\": \"napajs\",\n \"description\": \"Napa.js is a multi-threaded JavaScript runtime built on V8\",\n \"version\": \"0.2.3"
},
{
"path": "scripts/clean.js",
"chars": 1143,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n\"use strict\";\nvar fs = "
},
{
"path": "scripts/embedded.js",
"chars": 2906,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n\"use strict\";\nvar child"
},
{
"path": "scripts/install.js",
"chars": 3468,
"preview": "#!/usr/bin/env node\n\nvar log = require('npmlog');\nvar fileExistsSync = require('fs').existsSync;\nvar path = require('pat"
},
{
"path": "scripts/paths.js",
"chars": 1524,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nlet path = require('pat"
},
{
"path": "src/CMakeLists.txt",
"chars": 5292,
"preview": "set(CMAKE_CXX_FLAGS_ORG ${CMAKE_CXX_FLAGS})\n\n# Use -fno-rtti and -fPIC to build v8-extensions as a static library for co"
},
{
"path": "src/api/capi.cpp",
"chars": 8801,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include <napa/capi.h>\n"
},
{
"path": "src/memory/built-in-allocators.cpp",
"chars": 2994,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include <napa/memory.h"
},
{
"path": "src/module/core-modules/core-modules.h",
"chars": 1922,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "src/module/core-modules/napa/allocator-debugger-wrap.cpp",
"chars": 3119,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"allocator-deb"
},
{
"path": "src/module/core-modules/napa/allocator-debugger-wrap.h",
"chars": 1560,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#pragma once\n\n#include "
},
{
"path": "src/module/core-modules/napa/allocator-wrap.cpp",
"chars": 3272,
"preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n#include \"allocator-wra"
}
]
// ... and 258 more files (download for full content)
About this extraction
This page contains the full source code of the microsoft/napajs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 458 files (2.3 MB), approximately 630.5k tokens, and a symbol index with 3840 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.