Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 2.87 KB

File metadata and controls

64 lines (41 loc) · 2.87 KB

Agent Instructions

About ruby-bindgen

For ruby-bindgen features and capabilities, see the docs/ directory (classes, methods, enums, templates, default_values, filtering, include_header, operators, iterators). For configuration options, see docs/configuration.md.

Key Files

  • lib/ruby-bindgen/generators/generator.rb - Base class for all generators
  • lib/ruby-bindgen/generators/rice/rice.rb - Rice generator that walks the AST
  • lib/ruby-bindgen/generators/rice/*.erb - ERB templates that generate Rice C++ code
  • test/headers/cpp/*.hpp - Test input headers
  • test/bindings/cpp/*-rb.cpp - Expected output (golden files)

Running Tests

# Run all tests
bundle exec ruby -Ilib -Itest test/rice_test.rb
bundle exec ruby -Ilib -Itest test/cmake_test.rb

# Run a specific test
bundle exec ruby -Ilib -Itest test/rice_test.rb --name test_classes

# Regenerate expected files after making changes
UPDATE_EXPECTED=1 bundle exec ruby -Ilib -Itest test/rice_test.rb
UPDATE_EXPECTED=1 bundle exec ruby -Ilib -Itest test/cmake_test.rb

NOTE: cmake_test must run after rice_test because it scans for *-rb.cpp files generated by rice_test.

All 16 Rice tests: classes, enums, functions, inheritance, template, constructors, operators, default_values, iterators, template_inheritance, overloads, incomplete_types, filtering, template_defaults, buffers, cross_file_typedef

IMPORTANT: Before using UPDATE_EXPECTED=1 or committing any changes, you MUST first run ALL tests to verify your changes don't break existing functionality. Never blindly update expected files without checking for regressions.

NEVER manually edit expected output files in test/bindings/cpp/. Always use UPDATE_EXPECTED=1 to regenerate them.

Test Coverage Requirements

Every bug fix MUST include test coverage. Write a failing test FIRST, then implement the fix. Add test cases to the appropriate header file in test/headers/cpp/ and update the expected output in test/bindings/cpp/.

Mocks are NEVER allowed in tests. All tests must use real headers and real generator output.

For typedef-related issues, use cross_file_base.hpp and cross_file_derived.hpp.

Git Commits

One commit per fix. Do not batch multiple unrelated fixes into a single commit.

Do not add Co-Authored-By or any other author attribution to commit messages.

Regenerate opencv-ruby bindings

See /mnt/c/Source/opencv-ruby/ext/rice-bindings.yaml for the full configuration. Use the match field to configure what .h/.hpp files are processed and thus generate bindings for.

cd /mnt/c/Source/ruby-bindgen

# 1. Generate Rice C++ source files
bundle exec ruby -Ilib bin/ruby-bindgen /mnt/c/Source/opencv-ruby/ext/rice-bindings.yaml

# 2. Generate CMake build files (must run after Rice generation)
bundle exec ruby -Ilib bin/ruby-bindgen /mnt/c/Source/opencv-ruby/ext/cmake-bindings.yaml