Copilot commented on code in PR #3529:
URL: https://github.com/apache/thrift/pull/3529#discussion_r3366051512


##########
lib/nodejs/test/int64_bigint.test.js:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Exercises the `js:bigint=true` default of the compiler. The fixture is
+// regenerated by testAll.sh into `gen-nodejs-bigint/` using the bare
+// `--gen js:node,es6` flag set (bigint=true is implicit).

Review Comment:
   The file header comment describes `js:bigint=true` as the compiler default 
and claims the fixture is regenerated with bare `--gen js:node,es6` (implicit 
bigint). In this PR, BigInt codegen is explicitly opt-in and testAll.sh 
regenerates the fixture with `--gen js:node,es6,bigint`, so the comment is 
misleading.



##########
lib/nodejs/test/bigint_helpers.test.js:
##########
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Exercises `thrift.toBigInt` / `thrift.fromBigInt` — the JS-side helpers
+// emitted by `js:bigint=true` generated code to convert between node-int64
+// `Int64` and native `bigint`. Verifies they round-trip through the binary
+// protocol without any runtime toggle on `TBinaryProtocol`.

Review Comment:
   This comment references generated code as `js:bigint=true`, but the CLI 
syntax in this PR is `--gen js:node,bigint` (and BigInt mode is only meaningful 
when `node` is enabled). Using the actual option name here avoids confusion for 
readers trying to reproduce the behavior.



##########
lib/nodejs/lib/thrift/index.js:
##########
@@ -57,6 +57,70 @@ exports.createWebServer = web_server.createWebServer;
 
 exports.Int64 = require("node-int64");
 
+const bigIntCompat = require("./bigint_compat");
+
+/**
+ * Convert a `node-int64` Int64 (as returned by `TBinaryProtocol.readI64`,
+ * `TCompactProtocol.readI64`, etc.) to a native `bigint`. Used by code
+ * generated with `js:bigint=true` to surface int64 values as BigInt without
+ * a protocol-layer toggle.

Review Comment:
   The JSDoc mentions code generated with `js:bigint=true`, but the generator 
option added in this PR is the opt-in `bigint` flag used as `--gen 
js:node,bigint`. Aligning the wording with the documented CLI syntax helps 
avoid confusion.



##########
lib/nodejs/lib/thrift/browser.js:
##########
@@ -37,6 +37,53 @@ exports.createClient = require("./create_client");
 
 exports.Int64 = require("node-int64");
 
+const bigIntCompat = require("./bigint_compat");
+
+/**
+ * Convert a `node-int64` Int64 to a native `bigint`. Used by code generated
+ * with `js:bigint=true`. Feature-detects `Buffer#readBigInt64BE` (Node 12+
+ * and modern buffer polyfills) and falls back to a `readInt32BE` /
+ * `readUInt32BE` + BigInt composition when the native method is absent.

Review Comment:
   The JSDoc mentions code generated with `js:bigint=true`, but the generator 
option added in this PR is the opt-in `bigint` flag used as `--gen 
js:node,bigint`. Aligning the wording with the documented CLI syntax helps 
avoid confusion.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to