From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Fri, 6 Oct 2023 14:15:20 -0400
Subject: feat: allow passing of ObjectTemplate to ObjectTemplateBuilder

https://chromium-review.googlesource.com/c/chromium/src/+/4905829 removed the
ObjectTemplateBuilder constructor which allows passing in an ObjectTemplate.

Electron needs this constructor, namely for gin_helper::Constructible
objects.

diff --git a/gin/object_template_builder.cc b/gin/object_template_builder.cc
index a694f7dc4da4f1bba579ab8c032eea21d8459995..8aaaba327166b1d3b884fe390a389c0c50890af9 100644
--- a/gin/object_template_builder.cc
+++ b/gin/object_template_builder.cc
@@ -146,6 +146,13 @@ ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate,
   template_->SetInternalFieldCount(kNumberOfInternalFields);
 }
 
+ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate,
+                                             const char* type_name,
+                                             v8::Local<v8::ObjectTemplate> tmpl)
+    : isolate_(isolate), type_name_(type_name), template_(tmpl) {
+  template_->SetInternalFieldCount(kNumberOfInternalFields);
+}
+
 ObjectTemplateBuilder::ObjectTemplateBuilder(
     const ObjectTemplateBuilder& other) = default;
 
diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h
index 9d8f6e5de793ea419875d99a0b46898f2e40ead5..c803363b8050f4084c9250fce9b5b8b171082703 100644
--- a/gin/object_template_builder.h
+++ b/gin/object_template_builder.h
@@ -46,6 +46,9 @@ class GIN_EXPORT ObjectTemplateBuilder {
  public:
   explicit ObjectTemplateBuilder(v8::Isolate* isolate);
   ObjectTemplateBuilder(v8::Isolate* isolate, const char* type_name);
+  ObjectTemplateBuilder(v8::Isolate* isolate,
+                        const char* type_name,
+                        v8::Local<v8::ObjectTemplate> tmpl);
   ObjectTemplateBuilder(const ObjectTemplateBuilder& other);
   ~ObjectTemplateBuilder();
 
