Skip to content

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
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

mceachen
Copy link
Member

This change addresses some maintenance and security considerations resulting from our current LZZ dependency.

While LZZ has served its purpose, the tool has been abandoned for many, many years, and requiring additional toolchain dependencies with unproven provenance can present challenges for contributors and long-term project maintenance.

This branch converts the existing LZZ-generated code into standard .cpp and .hpp files, using the #line directives from the original .lzz files as a guide for the separation.

This approach simplifies the build process and reduces external dependencies while preserving the existing code structure and functionality

@mceachen mceachen requested review from JoshuaWise and a team as code owners May 29, 2025 16:23
@mceachen mceachen requested a review from Copilot May 29, 2025 16:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the LZZ-generated C++ sources with standard .cpp/.hpp files, updates the build configuration, and revises documentation to eliminate the LZZ dependency.

  • Converts all .lzz definitions into explicit .cpp and .hpp files for core classes (Database, Statement, StatementIterator, Backup) and utilities.
  • Updates binding.gyp to list all newly added .cpp sources and removes the LZZ build step from package.json.
  • Revises documentation (docs/contribution.md) to reflect direct editing of .cpp/.hpp files and new build process.

Reviewed Changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/util/bind-map.cpp New implementation of BindMap replacing LZZ output.
src/objects/*.hpp, *.cpp Converted class definitions and implementations.
binding.gyp Expanded sources list to include all .cpp files.
package.json Removed LZZ scripts, added fmt for clang-format.
docs/contribution.md Updated instructions for editing and building C++.

mceachen added 8 commits May 29, 2025 09:47
  - Split monolithic LZZ-generated files into modular C++ components
  - Create separate .hpp/.cpp files for each original .lzz source
  - Maintain single compilation unit architecture via strategic includes
  - Add proper forward declarations to resolve circular dependencies
  - Update binding.gyp to compile all individual source files
  - Add standard LLVM formatting with .clang-format
  - Add npm script for formatting C++ code
… BETTER_SQLITE3_BETTER_SQLITE3_HPP to

  BETTER_SQLITE3_SPLIT_HPP
@mceachen mceachen requested a review from Copilot May 29, 2025 16:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the legacy LZZ-generated code with standard C++ source (.cpp) and header (.hpp) files to improve maintainability and security by removing an abandoned dependency. Key changes include removing all .lzz files for Statement, StatementIterator, and Backup; adding corresponding .cpp/.hpp files that leverage the original #line directives for code separation; and updating build configuration and documentation accordingly.

Reviewed Changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/util/bind-map.cpp New implementation of BindMap using explicit allocation and growth
src/objects/statement.lzz Removal of legacy LZZ file for Statement
src/objects/statement.hpp New standardized header for Statement
src/objects/statement-iterator.lzz Removal of legacy LZZ file for StatementIterator
src/objects/statement-iterator.hpp New standardized header for StatementIterator
src/objects/statement-iterator.cpp New implementation for StatementIterator
src/objects/backup.lzz Removal of legacy LZZ file for Backup
src/objects/backup.hpp & backup.cpp New standardized files for Backup functionality
src/objects/database.hpp Updated API and state management methods
binding.gyp, package.json, docs Updates reflecting the new file structure and build processes

@mceachen mceachen requested a review from Copilot May 29, 2025 17:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Migrates the codebase from LZZ-generated .lzz files to standard C++ .cpp/.hpp files, updates build and formatting commands, and cleans up tooling dependencies.

  • Removed all .lzz sources and added corresponding headers and implementation files.
  • Updated binding.gyp, package.json, and documentation to reflect the new build and formatting workflow.
  • Adjusted .gitattributes to show diffs for C++ files.

Reviewed Changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/objects/statement.lzz Removed legacy LZZ source
src/objects/statement.hpp Added Statement class header
src/objects/statement-iterator.lzz Removed legacy LZZ source
src/objects/statement-iterator.hpp Added StatementIterator header
src/objects/statement-iterator.cpp Added StatementIterator implementation
src/objects/backup.lzz Removed legacy LZZ source
src/objects/backup.hpp Added Backup header
src/objects/backup.cpp Added Backup implementation
src/objects/database.hpp Added Database class header
binding.gyp Updated source list to include all new .cpp files
package.json Removed lzz commands, added fmt script
docs/contribution.md Updated C++ contribution instructions
.gitattributes Enabled diffs for .cpp and .hpp files
Comments suppressed due to low confidence (3)

docs/contribution.md:59

  • The word "layed" is misspelled; it should be "laid".
Although the rules aren't layed out formally, you are expected to adhere to them by using your eyeballs.

binding.gyp:13

  • The file src/objects/database.cpp is listed here but not added in the PR; the Database implementation is missing and must be included or the build will fail.
        'src/objects/database.cpp',

binding.gyp:14

  • The file src/objects/statement.cpp is referenced but not present in the commit; the Statement implementation needs to be supplied or the build will break.
        'src/objects/statement.cpp',

@mceachen mceachen requested a review from Copilot May 29, 2025 17:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the now‐obsolete LZZ-generated files and migrates the code to standard C++ source/header files (.cpp/.hpp) to simplify the build process and reduce external dependencies. Key changes include:

  • Removal of all *.lzz files (Statement, StatementIterator, Backup, better_sqlite3.lzz).
  • Addition of corresponding .cpp and .hpp files for Statement, StatementIterator, Backup, Database, and supporting utilities.
  • Updates to project configuration (binding.gyp, package.json, docs) reflecting the migration.

Reviewed Changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/objects/statement.lzz Removed obsolete LZZ source file for Statement
src/objects/statement.hpp New header file for Statement class
src/objects/statement-iterator.lzz Removed obsolete LZZ source file for StatementIterator
src/objects/statement-iterator.hpp/cpp New header and source files for StatementIterator
src/objects/backup.lzz Removed obsolete LZZ source file for Backup
src/objects/backup.hpp/cpp New header and source files for Backup
src/objects/database.hpp New header file for Database class
binding.gyp Updated sources list to include all new C++ files
package.json Updated scripts to reflect the removal of LZZ tooling
docs/contribution.md Updated documentation to refer to .cpp/.hpp based development
.gitattributes Adjusted diff settings for C++ files
Comments suppressed due to low confidence (1)

.gitattributes:2

  • [nitpick] Disabling diffs for *.cpp and *.hpp files might hide important changes during reviews; consider whether this setting aligns with the team's review practices.
-*.cpp -diff

Comment on lines +96 to +102
stmts.insert(stmts.end(), stmt);
}
LZZ_INLINE void Database::RemoveStatement(Statement *stmt) {
stmts.erase(stmt);
}
LZZ_INLINE void Database::AddBackup(Backup *backup) {
backups.insert(backups.end(), backup);
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider simplifying the insertion by using stmts.insert(stmt) instead of providing a hint with stmts.end(), unless there is a measured performance benefit.

Suggested change
stmts.insert(stmts.end(), stmt);
}
LZZ_INLINE void Database::RemoveStatement(Statement *stmt) {
stmts.erase(stmt);
}
LZZ_INLINE void Database::AddBackup(Backup *backup) {
backups.insert(backups.end(), backup);
stmts.insert(stmt);
}
LZZ_INLINE void Database::RemoveStatement(Statement *stmt) {
stmts.erase(stmt);
}
LZZ_INLINE void Database::AddBackup(Backup *backup) {
backups.insert(backup);

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant