Bug 787574 - Add a script for creating stub implementations of Web IDL interfaces; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 06 Sep 2012 13:53:43 -0400
changeset 104485 0fc505e515aa36dc9a17acc269d937d44f9e7d40
parent 104484 9ed5024f9101e5b9ca4e8047854c6824d2852a4a
child 104486 95b911e4e4358364d196f14354a170676eff798a
push id14521
push usereakhgari@mozilla.com
push dateThu, 06 Sep 2012 17:54:34 +0000
treeherdermozilla-inbound@0fc505e515aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs787574
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 787574 - Add a script for creating stub implementations of Web IDL interfaces; r=bzbarsky DONTBUILD since this is just a script, and NPOTB.
dom/bindings/stubgenerator/Skeleton.cpp
dom/bindings/stubgenerator/Skeleton.h
dom/bindings/stubgenerator/generate.sh
new file mode 100644
--- /dev/null
+++ b/dom/bindings/stubgenerator/Skeleton.cpp
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Skeleton.h"
+#include "mozilla/dom/SkeletonBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(Skeleton)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(Skeleton)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(Skeleton)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Skeleton)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+Skeleton::Skeleton()
+{
+  SetIsDOMBinding();
+}
+
+Skeleton::~Skeleton()
+{
+}
+
+JSObject*
+Skeleton::WrapObject(JSContext* aCx, JSObject* aScope,
+                         bool* aTriedToWrap)
+{
+  return SkeletonBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
+}
+}
+
new file mode 100644
--- /dev/null
+++ b/dom/bindings/stubgenerator/Skeleton.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsWrapperCache.h"
+#include "nsCycleCollectionParticipant.h"
+#include "mozilla/Attributes.h"
+
+class JSContext;
+
+namespace mozilla {
+namespace dom {
+
+class Skeleton MOZ_FINAL : public nsISupports,
+                           public nsWrapperCache
+{
+public:
+  Skeleton();
+  ~Skeleton();
+
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Skeleton)
+
+  void* GetParentObject() const
+  {
+    // TODO: return something sensible here, and change the return type
+    return somethingSensible;
+  }
+
+  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
+                               bool* aTriedToWrap);
+};
+
+}
+}
+
new file mode 100755
--- /dev/null
+++ b/dom/bindings/stubgenerator/generate.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# This script creates a skeleton implementation for a C++ class which
+# implements a Web IDL interface.
+
+# This script is released into the public domain.
+
+if [ -z "$1" ]; then
+  echo usage: ./generate.sh ClassName
+  exit 1
+fi
+
+expression="s/Skeleton/$1/g"
+
+sed "$expression" < Skeleton.h > "$1.h"
+sed "$expression" < Skeleton.cpp > "$1.cpp"
+