-
-
Notifications
You must be signed in to change notification settings - Fork 423
Switch from LZZ to .cpp/.hpp #1377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mceachen
wants to merge
14
commits into
WiseLibs:master
Choose a base branch
from
mceachen:no-lzz-20250428
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cde632f
chore(docs): initial project analysis and lzz-migration steps
mceachen 431a476
feat(migration): add automated split option using #line directives
mceachen 908ff83
refactor(src): migrate from .lzz to .cpp/.hpp
mceachen 44743d3
refactor(src): complete LZZ migration by removing all .lzz source files
mceachen 1d99b11
refactor(docs): update documentation to reflect migration from LZZ to…
mceachen ea3db13
refactor(docs): remove TODO.md
mceachen eb08bda
fix(src/better_sqlite3_split.hpp): Fixed mismatched header guard from…
mceachen 2ec5d57
docs: add C++ code formatting instructions using clang-format
mceachen 2dcd7b9
chore(bind-map.cpp): simplify capacity calculation
mceachen 1e1db61
chore(settings.local.json): add additional Bash permissions for git a…
mceachen ac4e897
fix(database.hpp): add static_assert for standard layout of State str…
mceachen a899b4d
fix(.gitattributes): remove diff exclusion for C++ source files
mceachen 37a9964
style(.cpp/.hpp): Remove extra spaces around :: in v8 type declaratio…
mceachen a22d0f5
fix(docs/contribution.md): correct typo in style guide section
mceachen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BasedOnStyle: LLVM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"permissions": { | ||
"allow": [ | ||
"WebFetch(domain:www.lazycplusplus.com)", | ||
"Bash(grep:*)", | ||
"Bash(ls:*)", | ||
"Bash(find:*)", | ||
"Bash(lzz:*)", | ||
"Bash(cp:*)", | ||
"Bash(npm run:*)", | ||
"Bash(chmod:*)", | ||
"Bash(python3:*)", | ||
"Bash(npm test:*)", | ||
"Bash(timeout:*)", | ||
"Bash(awk:*)", | ||
"Bash(git fetch:*)", | ||
"Bash(git merge-base:*)", | ||
"Bash(git stash:*)", | ||
"Bash(rg:*)", | ||
"Bash(clang-format:*)" | ||
] | ||
}, | ||
"enableAllProjectMcpServers": false | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
*.lzz linguist-language=C++ | ||
*.cpp -diff | ||
*.hpp -diff | ||
*.c -diff | ||
*.h -diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# CLAUDE.md | ||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
||
## Project Overview | ||
|
||
**better-sqlite3** is a Node.js native addon providing synchronous SQLite database access. It's architected as a hybrid C++/JavaScript library where C++ handles direct SQLite operations and JavaScript provides the high-level API. | ||
|
||
## Build & Development Commands | ||
|
||
### Essential Commands | ||
- **Build**: `npm run build-release` (production build) | ||
- **Debug Build**: `npm run build-debug` | ||
- **Test**: `npm test` (mocha with 5s timeout) | ||
- **Single Test**: `npx mocha test/[test-file].js` | ||
- **Benchmark**: `npm run benchmark` | ||
- **Download SQLite**: `npm run download` | ||
|
||
## Architecture | ||
|
||
### Code Organization | ||
``` | ||
lib/ # JavaScript API layer | ||
├── index.js # Main export (Database constructor) | ||
├── database.js # Database class with native binding | ||
└── methods/ # Method implementations | ||
|
||
src/ # C++ source | ||
├── better_sqlite3.cpp # Main implementation file | ||
├── better_sqlite3.hpp # Main header file | ||
├── objects/ # Core classes (Database, Statement, etc.) | ||
└── util/ # Utilities and type conversion | ||
``` | ||
|
||
### C++ Architecture | ||
- Standard C++ source files (.cpp/.hpp) | ||
- Modular header structure in `src/objects/` and `src/util/` | ||
- Single compilation unit architecture maintained | ||
- Uses standard C++ #include directives | ||
|
||
## Native Addon Structure | ||
|
||
### Data Flow | ||
``` | ||
JavaScript API → C++ Native Methods → SQLite C API → Results → Type Conversion → JavaScript | ||
``` | ||
|
||
### Key Classes | ||
- `Database`: Main database connection and operations | ||
- `Statement`: Prepared SQL statements | ||
- `StatementIterator`: Row iteration | ||
- `Backup`: Database backup functionality | ||
|
||
### Type Conversion | ||
The C++ layer handles conversion between SQLite types and V8/JavaScript types, including support for 64-bit integers, Buffers, and BigInts. | ||
|
||
## Testing | ||
|
||
Tests are organized by functionality in `test/`: | ||
- `00.setup.js`: Global test setup | ||
- `10-19.*`: Database-level operations | ||
- `20-29.*`: Statement operations | ||
- `30-39.*`: Advanced features (transactions, custom functions) | ||
- `40-50.*`: Special cases (BigInts, worker threads, unsafe mode) | ||
|
||
## Development Workflow | ||
|
||
1. **For C++ changes**: Edit `.cpp/.hpp` files → `npm run build-release` → `npm test` | ||
2. **For JavaScript changes**: Edit files in `lib/` → `npm test` | ||
3. **Performance testing**: Use `npm run benchmark` after changes | ||
|
||
## Important Notes | ||
|
||
- This is a **synchronous** SQLite library (no async/await) | ||
- Single-threaded SQLite access for performance | ||
- Uses Node.js N-API for forward compatibility | ||
- Embeds SQLite source in `deps/` directory | ||
- Supports Node.js 20.x, 22.x, 23.x, 24.x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.