Repository: denoland/deno_core
Pull request #993 (2024-12-09 06:31:58)

Fix multiple objects in `extension!` macro

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/denoland/deno_core/pull/993?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) Report
Attention: Patch coverage is `42.85714%` with `4 lines` in your changes missing coverage. Please review.
> Project coverage is 81.78%. Comparing base [(`0c7f83e`)](https://app.codecov.io/gh/denoland/deno_core/commit/0c7f83ea8daabe8f541fc93ae97529dc446f5f24?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) to head [(`9135e8a`)](https://app.codecov.io/gh/denoland/deno_core/commit/9135e8ad4faa49376c3da1b01c9c82a66c527594?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).
> Report is 189 commits behind head on main.

| [Files with missing lines](https://app.codecov.io/gh/denoland/deno_core/pull/993?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) | Patch % | Lines |
|---|---|---|
| [testing/checkin/runner/ops.rs](https://app.codecov.io/gh/denoland/deno_core/pull/993?src=pr&el=tree&filepath=testing%2Fcheckin%2Frunner%2Fops.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland#diff-dGVzdGluZy9jaGVja2luL3J1bm5lci9vcHMucnM=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/denoland/deno_core/pull/993?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #993      +/-   ##
==========================================
+ Coverage   81.43%   81.78%   +0.34%     
==========================================
  Files          97       98       +1     
  Lines       23877    25787    +1910     
==========================================
+ Hits        19445    21090    +1645     
- Misses       4432     4697     +265     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/denoland/deno_core/pull/993?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).


Patch:
diff --git a/core/extensions.rs b/core/extensions.rs
index 11bc573..053c7ea 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -410,7 +410,7 @@ macro_rules! extension {
     $(, bounds = [ $( $bound:path : $bound_type:ident ),+ ] )?
     $(, ops_fn = $ops_symbol:ident $( < $ops_param:ident > )? )?
     $(, ops = [ $( $(#[$m:meta])* $( $op:ident )::+ $( < $( $op_param:ident ),* > )?  ),+ $(,)? ] )?
-    $(, objects = [  $( $object:ident )::+ ] )?
+    $(, objects = [ $( $(#[$masd:meta])* $( $object:ident )::+ ),+ $(,)? ] )?
     $(, esm_entry_point = $esm_entry_point:expr )?
     $(, esm = [ $($esm:tt)* ] )?
     $(, lazy_loaded_esm = [ $($lazy_loaded_esm:tt)* ] )?
@@ -474,9 +474,9 @@ macro_rules! extension {
             $( #[ $m ] )*
             $( $op )::+ $( :: < $($op_param),* > )? ()
           }),+)?]),
-          objects: ::std::borrow::Cow::Borrowed(&[
-            $( $( $object )::+::DECL, )*
-          ]),
+          objects: ::std::borrow::Cow::Borrowed(&[$($({
+            $( $object )::+::DECL
+          }),+)?]),
           external_references: ::std::borrow::Cow::Borrowed(&[ $( $external_reference ),* ]),
           global_template_middleware: ::std::option::Option::None,
           global_object_middleware: ::std::option::Option::None,


Test patch:
diff --git a/testing/checkin/runner/extensions.rs b/testing/checkin/runner/extensions.rs
index 129277a..a540082 100644
--- a/testing/checkin/runner/extensions.rs
+++ b/testing/checkin/runner/extensions.rs
@@ -50,7 +50,8 @@ deno_core::extension!(
     ops_worker::op_worker_terminate,
   ],
   objects = [
-    ops::DOMPoint
+    ops::DOMPoint,
+    ops::TestObjectWrap
   ],
   esm_entry_point = "ext:checkin_runtime/__init.js",
   esm = [
diff --git a/testing/checkin/runner/ops.rs b/testing/checkin/runner/ops.rs
index 98c15f0..7b56ff0 100644
--- a/testing/checkin/runner/ops.rs
+++ b/testing/checkin/runner/ops.rs
@@ -70,6 +70,18 @@ pub fn op_stats_delete(
   test_data.take::<RuntimeActivityStats>(name);
 }
 
+pub struct TestObjectWrap {}
+impl GarbageCollected for TestObjectWrap {}
+
+#[op2]
+impl TestObjectWrap {
+  #[constructor]
+  #[cppgc]
+  fn new(_: bool) -> TestObjectWrap {
+    TestObjectWrap {}
+  }
+}
+
 pub struct DOMPoint {
   pub x: f64,
   pub y: f64,