Bug 1138123 - Remove xpcom/sample/ as a bygone relic. r=bsmedberg, a=bajaj
authorNathan Froyd <froydnj@mozilla.com>
Mon, 09 Mar 2015 11:37:21 -0400
changeset 237573 004fa1cb1dd4d33015d30411f78797abb90b234e
parent 237572 6156ba35c69dbf192273c6e40a915846023ebd51
child 237574 89b1f4a803c707f0eb681537c9c27119b8b2926c
push id301
push userryanvm@gmail.com
push dateWed, 11 Mar 2015 02:14:36 +0000
treeherdermozilla-b2g37_v2_2@004fa1cb1dd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, bajaj
bugs1138123
milestone37.0
Bug 1138123 - Remove xpcom/sample/ as a bygone relic. r=bsmedberg, a=bajaj
xpcom/moz.build
xpcom/sample/moz.build
xpcom/sample/nsISample.idl
xpcom/sample/nsSample.cpp
xpcom/sample/nsSample.h
xpcom/sample/nsSample.js
xpcom/sample/nsSample.manifest
xpcom/sample/nsSampleModule.cpp
xpcom/sample/program/moz.build
xpcom/sample/program/nsTestSample.cpp
xpcom/sample/xpconnect-sample.html
--- a/xpcom/moz.build
+++ b/xpcom/moz.build
@@ -23,17 +23,16 @@ DIRS += [
     'build',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_DEBUG']:
     DIRS += ['windbgdlg']
 
 TEST_DIRS += [
     'tests',
-    'sample',
     'typelib/xpt/tests',
 ]
 
 #  Can't build internal xptcall tests that use symbols which are not exported.
 #TEST_DIRS += [
 #    'reflect/xptinfo/tests',
 #    'reflect/xptcall/tests,
 #]
deleted file mode 100644
--- a/xpcom/sample/moz.build
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-# If you're copying from this file, you'll likely need to replace
-# TEST_DIRS with DIRS.
-TEST_DIRS += ['program']
-
-# XPIDL_SOURCES specifies IDL files. The build system runs the xpidl tool
-# on these files to generate C++ headers and .xpt typelib files.
-XPIDL_SOURCES += ['nsISample.idl']
-
-# XPIDL_MODULE specifies where header files from this Makefile are installed,
-# i.e. dist/include/xpcomsample
-XPIDL_MODULE = 'xpcomsample'
-
-# CPP_SOURCES specifies C++ files to be built into a library.
-UNIFIED_SOURCES += [
-    'nsSample.cpp',
-    'nsSampleModule.cpp',
-]
-
-# EXTRA_COMPONENTS installs components written JavaScript to
-# dist/bin/components
-EXTRA_COMPONENTS += [
-    'nsSample.js',
-    'nsSample.manifest',
-]
-
-# XPCOMBinaryComponent names the library generated by this makefile,
-# i.e. dist/bin/components/libxpcomsample.so
-XPCOMBinaryComponent('xpcomsample')
-
-RESOURCE_FILES.samples += [
-    'xpconnect-sample.html',
-]
-
-# Need to link with CoreFoundation on Mac
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    OS_LIBS += CONFIG['TK_LIBS']
-
-FAIL_ON_WARNINGS = True
deleted file mode 100644
--- a/xpcom/sample/nsISample.idl
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-
-/**
- * A sample of XPConnect. This file contains a sample interface.
- *
- */
-
-#include "nsISupports.idl"
-
-/**
- * The uuid is a unique number identifying the interface normally
- * called IID. It can be generated as follows:
- *
- * Windows: guidgen.exe
- * Unix: uuidgen which comes with e2fsprogs package
- * Mac: ???
- * All platform: Using irc, connect to irc.mozilla.org and type in
- *				/join #mozilla
- *				/msg mozbot uuid
- *
- */
-[scriptable, uuid(7CB5B7A1-07D7-11d3-BDE2-000064657374)]
-interface nsISample : nsISupports
-{
-    attribute string value;
-    void writeValue(in string aPrefix);
-    void poke(in string aValue);
-};
-
-
-
deleted file mode 100644
--- a/xpcom/sample/nsSample.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-
-
-/**
- *
- * A sample of XPConnect. This file contains an implementation nsSample
- * of the interface nsISample.
- *
- */
-#include <stdio.h>
-
-#include "nsSample.h"
-#include "nsMemory.h"
-
-#include "nsEmbedString.h"
-#include "nsIClassInfoImpl.h"
-////////////////////////////////////////////////////////////////////////
-
-nsSampleImpl::nsSampleImpl() : mValue(nullptr)
-{
-  mValue = (char*)nsMemory::Clone("initial value", 14);
-}
-
-nsSampleImpl::~nsSampleImpl()
-{
-  if (mValue) {
-    nsMemory::Free(mValue);
-  }
-}
-
-/**
- * NS_IMPL_ISUPPORTS expands to a simple implementation of the nsISupports
- * interface.  This includes a proper implementation of AddRef, Release,
- * and QueryInterface.  If this class supported more interfaces than just
- * nsISupports,
- * you could use NS_IMPL_ADDREF() and NS_IMPL_RELEASE() to take care of the
- * simple stuff, but you would have to create QueryInterface on your own.
- * nsSampleFactory.cpp is an example of this approach.
- * Notice that the second parameter to the macro is name of the interface, and
- * NOT the #defined IID.
- *
- * The _CI variant adds support for nsIClassInfo, which permits introspection
- * and interface flattening.
- */
-NS_IMPL_CLASSINFO(nsSampleImpl, nullptr, 0, NS_SAMPLE_CID)
-NS_IMPL_ISUPPORTS_CI(nsSampleImpl, nsISample)
-/**
- * Notice that in the protoype for this function, the NS_IMETHOD macro was
- * used to declare the return type.  For the implementation, the return
- * type is declared by NS_IMETHODIMP
- */
-NS_IMETHODIMP
-nsSampleImpl::GetValue(char** aValue)
-{
-  NS_PRECONDITION(aValue != nullptr, "null ptr");
-  if (!aValue) {
-    return NS_ERROR_NULL_POINTER;
-  }
-
-  if (mValue) {
-    /**
-     * GetValue's job is to return data known by an instance of
-     * nsSampleImpl to the outside world.  If we  were to simply return
-     * a pointer to data owned by this instance, and the client were to
-     * free it, bad things would surely follow.
-     * On the other hand, if we create a new copy of the data for our
-     * client, and it turns out that client is implemented in JavaScript,
-     * there would be no way to free the buffer.  The solution to the
-     * buffer ownership problem is the nsMemory singleton.  Any buffer
-     * returned by an XPCOM method should be allocated by the nsMemory.
-     * This convention lets things like JavaScript reflection do their
-     * job, and simplifies the way C++ clients deal with returned buffers.
-     */
-    *aValue = (char*)nsMemory::Clone(mValue, strlen(mValue) + 1);
-    if (!*aValue) {
-      return NS_ERROR_NULL_POINTER;
-    }
-  } else {
-    *aValue = nullptr;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsSampleImpl::SetValue(const char* aValue)
-{
-  NS_PRECONDITION(aValue != nullptr, "null ptr");
-  if (!aValue) {
-    return NS_ERROR_NULL_POINTER;
-  }
-
-  if (mValue) {
-    nsMemory::Free(mValue);
-  }
-
-  /**
-   * Another buffer passing convention is that buffers passed INTO your
-   * object ARE NOT YOURS.  Keep your hands off them, unless they are
-   * declared "inout".  If you want to keep the value for posterity,
-   * you will have to make a copy of it.
-   */
-  mValue = (char*)nsMemory::Clone(aValue, strlen(aValue) + 1);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsSampleImpl::Poke(const char* aValue)
-{
-  return SetValue((char*)aValue);
-}
-
-
-static void
-GetStringValue(nsACString& aValue)
-{
-  NS_CStringSetData(aValue, "GetValue");
-}
-
-NS_IMETHODIMP
-nsSampleImpl::WriteValue(const char* aPrefix)
-{
-  NS_PRECONDITION(aPrefix != nullptr, "null ptr");
-  if (!aPrefix) {
-    return NS_ERROR_NULL_POINTER;
-  }
-
-  printf("%s %s\n", aPrefix, mValue);
-
-  // This next part illustrates the nsEmbedString:
-  nsEmbedString foopy;
-  foopy.Append(char16_t('f'));
-  foopy.Append(char16_t('o'));
-  foopy.Append(char16_t('o'));
-  foopy.Append(char16_t('p'));
-  foopy.Append(char16_t('y'));
-
-  const char16_t* f = foopy.get();
-  uint32_t l = foopy.Length();
-  printf("%c%c%c%c%c %d\n",
-         char(f[0]), char(f[1]), char(f[2]), char(f[3]), char(f[4]), l);
-
-  nsEmbedCString foopy2;
-  GetStringValue(foopy2);
-
-  //foopy2.AppendLiteral("foopy");
-  const char* f2 = foopy2.get();
-  uint32_t l2 = foopy2.Length();
-
-  printf("%s %d\n", f2, l2);
-
-  return NS_OK;
-}
deleted file mode 100644
--- a/xpcom/sample/nsSample.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-
-#ifndef nsSample_h
-#define nsSample_h
-
-/**
- * A sample of XPConnect. This file is the header of an implementation
- * nsSample of the nsISample interface.
- *
- */
-
-#include "nsISample.h"
-#include "mozilla/Attributes.h"
-
-/**
- * SampleImpl is an implementation of the nsISample interface.  In XPCOM,
- * there can be more than one implementation of an given interface.  Class
- * IDs (CIDs) uniquely identify a particular implementation of an interface.
- * Interface IDs (IIDs) uniquely identify an interface.
- *
- * The CID is also a unique number that looks just like an IID
- * and uniquely identifies an implementation
- * {7CB5B7A0-07D7-11d3-BDE2-000064657374}
- */
-
-#define NS_SAMPLE_CID \
-{ 0x7cb5b7a0, 0x7d7, 0x11d3, { 0xbd, 0xe2, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
-
-#define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1"
-
-
-class nsSampleImpl MOZ_FINAL : public nsISample
-{
-public:
-  nsSampleImpl();
-
-  /**
-   * This macro expands into a declaration of the nsISupports interface.
-   * Every XPCOM component needs to implement nsISupports, as it acts
-   * as the gateway to other interfaces this component implements.  You
-   * could manually declare QueryInterface, AddRef, and Release instead
-   * of using this macro, but why?
-   */
-  // nsISupports interface
-  NS_DECL_ISUPPORTS
-
-  /**
-   * This macro is defined in the nsISample.h file, and is generated
-   * automatically by the xpidl compiler.  It expands to
-   * declarations of all of the methods required to implement the
-   * interface.  xpidl will generate a NS_DECL_[INTERFACENAME] macro
-   * for each interface that it processes.
-   *
-   * The methods of nsISample are discussed individually below, but
-   * commented out (because this macro already defines them.)
-   */
-  NS_DECL_NSISAMPLE
-
-  /**
-   * The following is an explanation of how the interface header
-   * file expands to for a c++ implementation. NS_DELC_NSISAMPLE
-   * takes care of defining the right c++ implementation.
-   *
-   * The following if provided for more understanding.
-   *
-   * NS_IMETHOD expands to the standard XPCOM return type.  XPCOM methods
-   * should never return any other type.  The return value is used
-   * behind the scenes by the XPConnect runtime to figure out if the call
-   * failed in any way.
-   * These methods were generated by "attribute string Value" in
-   * nsISample.idl.  When reflected into JavaScript, XPCOM will use these
-   * calls as Getter/Setter ops, so that they can be called transparently
-   * as "sample.Value='foo';" and "var val = sample.Value"
-   */
-  /* NS_IMETHOD GetValue(char** aValue); */
-  /* NS_IMETHOD SetValue(char* aValue); */
-
-  /**
-   * The const came from the "in" specifier in nsISample.idl.  "in"
-   * specifies that the value of this parameter is used only for input,
-   * this method is not allowed to modify the contents of the buffer.
-   */
-  /* NS_IMETHOD WriteValue(const char* aPrefix); */
-
-  /**
-   * nsISample.idl specifies all of its string types as string, instead
-   * of wstring (wide string), the Unicode type.  If the world were a
-   * perfect place, all normal strings in XPCOM interfaces would be unicode.
-   * If this type had been specified as wstring, it would appear as
-   * char16_t * in C++, which is the NSPR type for unicode characters.
-   */
-  /* NS_IMETHOD Poke(const char* aValue); */
-
-private:
-  ~nsSampleImpl();
-
-  char* mValue;
-};
-
-#endif
deleted file mode 100644
--- a/xpcom/sample/nsSample.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
-/* 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/. */
-
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-/**
- * We set up a sample component. The constructor is empty, all the interesting
- * stuff goes in the prototype.
- */
-function mySample() { }
-
-mySample.prototype = {
-    /**
-     * .classID is required for generateNSGetFactory to work correctly.
-     * Make sure this CID matches the "component" in your .manifest file.
-     */
-    classID: Components.ID("{dea98e50-1dd1-11b2-9344-8902b4805a2e}"),
-
-    /**
-     * .classDescription and .contractID are only used for
-     * backwards compatibility with Gecko 1.9.2 and
-     * XPCOMUtils.generateNSGetModule.
-     */
-    classDescription: "nsSample: JS version", // any human-readable string
-    contractID: "@mozilla.org/jssample;1",
-
-    /**
-     * List all the interfaces your component supports.
-     * @note nsISupports is generated automatically; you don't need to list it.
-     */
-    QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISample]),
-
-    /*
-     * get and set are new Magic in JS1.5, borrowing the intent -- if not
-     * the exact syntax -- from the JS2 design.  They define accessors for
-     * properties on the JS object, follow the expected rules for prototype
-     * delegation, and make a mean cup of coffee.
-     */
-    get value()       { return this.val; },
-    set value(newval) { return this.val = newval; },
-
-    writeValue: function (aPrefix) {
-        debug("mySample::writeValue => " + aPrefix + this.val + "\n");
-    },
-    poke: function (aValue) { this.val = aValue; },
-
-    val: "<default value>"
-};
-
-/**
- * XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
- * XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
- */
-if (XPCOMUtils.generateNSGetFactory)
-    this.NSGetFactory = XPCOMUtils.generateNSGetFactory([mySample]);
-else
-    var NSGetModule = XPCOMUtils.generateNSGetModule([mySample]);
deleted file mode 100644
--- a/xpcom/sample/nsSample.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component dea98e50-1dd1-11b2-9344-8902b4805a2e nsSample.js
-contract @mozilla.org/jssample;1 dea98e50-1dd1-11b2-9344-8902b4805a2e
deleted file mode 100644
--- a/xpcom/sample/nsSampleModule.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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 "mozilla/ModuleUtils.h"
-#include "nsIClassInfoImpl.h"
-
-#include "nsSample.h"
-
-////////////////////////////////////////////////////////////////////////
-// With the below sample, you can define an implementation glue
-// that talks with xpcom for creation of component nsSampleImpl
-// that implement the interface nsISample. This can be extended for
-// any number of components.
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-// Define the contructor function for the object nsSampleImpl
-//
-// What this does is defines a function nsSampleImplConstructor which we
-// will specific in the nsModuleComponentInfo table. This function will
-// be used by the generic factory to create an instance of nsSampleImpl.
-//
-// NOTE: This creates an instance of nsSampleImpl by using the default
-//		 constructor nsSampleImpl::nsSampleImpl()
-//
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl)
-
-// The following line defines a kNS_SAMPLE_CID CID variable.
-NS_DEFINE_NAMED_CID(NS_SAMPLE_CID);
-
-// Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs
-// should be completely unique UUIDs.
-// each entry has the form { CID, service, factoryproc, constructorproc }
-// where factoryproc is usually nullptr.
-static const mozilla::Module::CIDEntry kSampleCIDs[] = {
-  { &kNS_SAMPLE_CID, false, nullptr, nsSampleImplConstructor },
-  { nullptr }
-};
-
-// Build a table which maps contract IDs to CIDs.
-// A contract is a string which identifies a particular set of functionality. In some
-// cases an extension component may override the contract ID of a builtin gecko component
-// to modify or extend functionality.
-static const mozilla::Module::ContractIDEntry kSampleContracts[] = {
-  { NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID },
-  { nullptr }
-};
-
-// Category entries are category/key/value triples which can be used
-// to register contract ID as content handlers or to observe certain
-// notifications. Most modules do not need to register any category
-// entries: this is just a sample of how you'd do it.
-// @see nsICategoryManager for information on retrieving category data.
-static const mozilla::Module::CategoryEntry kSampleCategories[] = {
-  { "my-category", "my-key", NS_SAMPLE_CONTRACTID },
-  { nullptr }
-};
-
-static const mozilla::Module kSampleModule = {
-  mozilla::Module::kVersion,
-  kSampleCIDs,
-  kSampleContracts,
-  kSampleCategories
-};
-
-// The following line implements the one-and-only "NSModule" symbol exported from this
-// shared library.
-NSMODULE_DEFN(nsSampleModule) = &kSampleModule;
-
-// The following line implements the one-and-only "NSGetModule" symbol
-// for compatibility with mozilla 1.9.2. You should only use this
-// if you need a binary which is backwards-compatible and if you use
-// interfaces carefully across multiple versions.
-NS_IMPL_MOZILLA192_NSGETMODULE(&kSampleModule)
deleted file mode 100644
--- a/xpcom/sample/program/moz.build
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-# GeckoSimplePrograms compiles a single .cpp file into an executable
-# depending on Gecko with standalone linkage.
-GeckoSimplePrograms([
-    'nsTestSample'
-], linkage='standalone')
-
-# Need to link with CoreFoundation on Mac
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    OS_LIBS += CONFIG['TK_LIBS']
deleted file mode 100644
--- a/xpcom/sample/program/nsTestSample.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-
-
-/**
- * A Test application that exercises the sample moudule. This is intented
- * to be a sample application for using xpcom standalone.
- */
-
-#include <stdio.h>
-
-#include "nsXPCOMGlue.h"
-#include "nsXPCOM.h"
-#include "nsCOMPtr.h"
-#include "nsISample.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsIComponentRegistrar.h"
-
-#define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1"
-
-int
-main()
-{
-  nsresult rv;
-
-  XPCOMGlueStartup(nullptr);
-
-  // Initialize XPCOM
-  nsCOMPtr<nsIServiceManager> servMan;
-  rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-  if (NS_FAILED(rv)) {
-    printf("ERROR: XPCOM intialization error [%x].\n",
-           static_cast<uint32_t>(rv));
-    return -1;
-  }
-
-  nsCOMPtr<nsIComponentManager> manager = do_QueryInterface(servMan);
-
-  // Create an instance of our component
-  nsCOMPtr<nsISample> mysample;
-  rv = manager->CreateInstanceByContractID(NS_SAMPLE_CONTRACTID,
-                                           nullptr,
-                                           NS_GET_IID(nsISample),
-                                           getter_AddRefs(mysample));
-  if (NS_FAILED(rv)) {
-    printf("ERROR: Cannot create instance of component " NS_SAMPLE_CONTRACTID " [%x].\n"
-           "Debugging hint:\n"
-           "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
-           "\tsetenv NSPR_LOG_FILE xpcom.log\n"
-           "\t./nsTestSample\n"
-           "\t<check the contents for xpcom.log for possible cause of error>.\n",
-           static_cast<uint32_t>(rv));
-    return -2;
-  }
-
-  // Call methods on our sample to test it out.
-  rv = mysample->WriteValue("Inital print:");
-  if (NS_FAILED(rv)) {
-    printf("ERROR: Calling nsISample::WriteValue() [%x]\n",
-           static_cast<uint32_t>(rv));
-    return -3;
-  }
-
-  const char* testValue = "XPCOM defies gravity";
-  rv = mysample->SetValue(testValue);
-  if (NS_FAILED(rv)) {
-    printf("ERROR: Calling nsISample::SetValue() [%x]\n",
-           static_cast<uint32_t>(rv));
-    return -3;
-  }
-  printf("Set value to: %s\n", testValue);
-  char* str;
-  rv = mysample->GetValue(&str);
-
-  if (NS_FAILED(rv)) {
-    printf("ERROR: Calling nsISample::GetValue() [%x]\n",
-           static_cast<uint32_t>(rv));
-    return -3;
-  }
-  if (strcmp(str, testValue)) {
-    printf("Test FAILED.\n");
-    return -4;
-  }
-
-  NS_Free(str);
-
-  rv = mysample->WriteValue("Final print :");
-  printf("Test passed.\n");
-
-  // All nsCOMPtr's must be deleted prior to calling shutdown XPCOM
-  // as we should not hold references passed XPCOM Shutdown.
-  servMan = 0;
-  manager = 0;
-  mysample = 0;
-
-  // Shutdown XPCOM
-  NS_ShutdownXPCOM(nullptr);
-
-  return 0;
-}
deleted file mode 100644
--- a/xpcom/sample/xpconnect-sample.html
+++ /dev/null
@@ -1,224 +0,0 @@
-<!-- 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/. -->
-
-
-<center><b><font size=+2>XPConnect Sample</font></b>
-
-<p>
-<a href="mailto:arielb@rice.edu">Ariel Blackenroth &lt;arielb@rice.edu&gt;</a>
-<br>
-<a href="mailto:mang@subcarrier.org">Michael Ang &lt;mang@subcarrier.org&gt;</a>
-<br>
-Last modified 
-<script>
-document.write(document.lastModified);
-</script>
-</center>
-
-<p>In the spirit of "worse is better" this somewhat rough guide is being
-released to the world.  It will be expanded upon and improved.
-
-<p>XPConnect allows JavaScript
-to transparantly access and manipulate XPCOM objects; this communication
-between JavaScript and
-native code is done by having their interfaces defined in the XPIDL interface
-definition language. See the <a href="http://www.mozilla.org/scriptable/roadmap.html">Roadmap
-for documentation on XPCOM, XPConnect, XPTCall and XPIDL</a> for more information.
-
-<p><b>Overview</b>
-
-<p>
-This sample demonstrates accessing a XPCOM object through XPConnect.
-The JavaScript executed when this page loads creates an instance
-of the object by
-using the <tt>Components</tt> object, then accesses it through
-the <a href="http://lxr.mozilla.org/seamonkey/source/xpcom/sample/nsISample.idl">nsISample</a> interface by calling <tt>QueryInterface</tt>:
-<br>
-<pre>
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-var sample = Components.classes["@mozilla.org/sample;1"].createInstance();
-sample = sample.QueryInterface(Components.interfaces.nsISample);
-</pre>
-
-<p>
-The buttons on the form are connected to JavaScript event handlers which
-call the methods defined in C++.
-
-
-<p><b><a href="http://lxr.mozilla.org/mozilla/source/xpcom/sample/nsISample.idl">nsISample.idl</a></b>
-<p>This is the interface declaration for the XPCOM object. It defines
-two functions, their parameters, and one attribute. It also defines
-the interface's id. The idl file is compiled by the xpidl compiler
-into a C++ header, nsISample.h and a .xpt file which is a binary representation
-of the interface used at runtime.
-<br><tt>attribute string value;</tt>
-<br><tt>void writeValue(in string aPrefix);</tt>
-<br><tt>void poke(in string aValue);</tt><b></b>
-<p><b><a href="http://lxr.mozilla.org/mozilla/source/xpcom/sample/nsSample.cpp">nsSample.cpp</a></b>
-<p>This contains the implementation of nsISample.idl. SampleImpl
-inherits from nsISample.h, the header dynamically created by the xpidl
-compiler. The attribute Value has been expanded into a get and set
-and the return values have been modified to NS_IMETHOD, a success status
-for the method. The macro NS_DECL_ISUPPORTS, defined in <a href="http://lxr.mozilla.org/mozilla/source/xpcom/base/nsISupportsUtils.h">mozilla/xpcom/public/nsISupportsUtils.h</a>
-defines the inherited methods from nsISupports.h.
-<br><tt>NS_IMPL_ISUPPORTS(SampleImpl, nsISample)</tt>
-<br>In the constructor, the macro NS_INIT_REFCNT is called which sets the
-reference count to 0.<p>
-Note that the methods in the C++ bindings use InterCaps style, while the IDL
-and JavaScript versions should use interCaps naming.  The JavaScript binding
-matches the case of the IDL, <b>except</b> <a
-href="http://bugzilla.mozilla.org/show_bug.cgi?id=14460">QueryInterface</a>.
-<p><b><a href="http://lxr.mozilla.org/mozilla/source/xpcom/sample/nsSampleFactory.cpp">nsSampleFactory.cpp</a></b>
-<p>This is the class which builds the instance of the nsSample class.
-The COM framework uses factories to create instance of implementations
-rather than having the implementations instantiate themselves in order to
-increase portability of code. This factory inherits from nsFactory,
-which is also an XPCOM object. To gain more knowledge of factories
-see the <a href="http://www.mozilla.org/projects/xpcom/generic-factory.html">generic
-factory document</a> or the <a href="http://www.mozilla.org/docs/modunote.htm#Basics">Modularization techniques document</a>.
-<p><b><a href="http://lxr.mozilla.org/mozilla/source/xpcom/sample/nsSample.js">nsSample.js</a></b>
-<p>This file implements the nsISample interface, and associated factory glue,
-in JavaScript.
-
-<p><b>Compiling the idl</b>
-
-<p>The XPIDL compiler (xpidl on Unix, xpidl.exe on Windows, and a CodeWarrior plugin on Mac)
-is compiled at build time (except on Mac) thus
-you will have to build mozilla in order to test this out. If you
-have already built mozilla then the compiler will be located at <tt>mozilla\dist\WIN32_D.OBJ\bin\xpidl.exe</tt>.
-
-<p>Once you have the XPIDL compiler enter the following command at your
-prompt:
-<br><tt>D:\mozilla\xpcom\sample>d:\mozilla\dist\WIN32_D.OBJ\bin\xpidl -I
-d:\mozilla\dist\idl -m header nsISample.idl</tt>
-
-<p>The <tt>-I d:\mozilla\dist\idl</tt> points the compiler to the folder
-containing the other idl files, needed because nsISample.idl inherits from
-nsISupports.idl. The <tt>-m header</tt> instruction tells the compiler
-to build the C++ header. To build the .xpt file substitute <tt>-m
-typelib</tt>. 
-
-<p>
-For more information on compilation see the <a href="http://www.mozilla.org/scriptable/xpidl/">xpidl
-compiler page</a>.
-
-<p><b>Building the Sample</b>
-
-<p>To build the Sample just enter
-<br><tt>d:\mozilla\xpcom\sample>nmake /f makefile.win</tt>
-
-<p>In order to do this you need to have your environment variables set
-correctly. See the <a href="http://www.mozilla.org/build/">Build</a>
-page for more information.
-
-<p><b>Running the sample</b>
-<p>Using Mozilla, load
-<a href="resource://res/samples/xpconnect-sample.html">resource://res/samples/xpconnect-sample.html</a> (i.e. what
-you're reading now). Pay attention
-to the console when clicking "write". Notice that the value
-printed is calculated in C++ code defined in <a href="http://lxr.mozilla.org/seamonkey/source/xpcom/sample/nsSample.cpp">nsSample.cpp</a>.
-
-<!-- XXX keep in sync with stuff in pre tag below -->
-<script>
-/* to use nsSample.js version, use "@mozilla.org/jssample;1" */
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-var sample = Components.classes["@mozilla.org/sample;1"].createInstance();
-sample = sample.QueryInterface(Components.interfaces.nsISample);
-dump("sample = " + sample + "\n");
-
-function get()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var field = document.getElementById('Value');
-  field.value = sample.value;
-}
-
-function set()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var field = document.getElementById('Value');
-  sample.value = field.value;
-}
-
-function poke()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var field = document.getElementById('Value');
-  sample.poke(field.value);
-}
-
-function sampleWrite()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  sample.writeValue("here is what I'm writing: ");
-}
-</script>
-
-<p>
-<form name="form">
-<input type="button" value="Get" onclick="get();">
-<input type="button" value="Set" onclick="set();">
-<input type="button" value="Poke" onclick="poke();">
-<input type="text" id="Value">
-<input type="button" value="Write" onclick="sampleWrite();">
-<form>
-
-<hr>
-
-<p>
-JavaScript and form source:
-
-<!-- XXX keep in sync with actual script -->
-<pre>
-&lt;script&gt;
-/* to use nsSample.js version, use "@mozilla.org/jssample;1" */
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-var sample = Components.classes["@mozilla.org/sample;1"].createInstance();
-sample = sample.QueryInterface(Components.interfaces.nsISample);
-dump("sample = " + sample + "\n");
-
-function get()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  var field = document.getElementById('Value');
-  field.value = sample.value;
-}
-
-function set()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  var field = document.getElementById('Value');
-  sample.value = field.value;
-}
-
-function poke()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  var field = document.getElementById('Value');
-  sample.poke(field.value);
-}
-
-function sampleWrite()
-{
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  sample.writeValue("here is what I'm writing: ");
-}
-&lt;/script&gt;
-
-&lt;form name=&quot;form&quot;&gt;
-&lt;input type=&quot;button&quot; value=&quot;Get&quot; onclick=&quot;get();&quot;&gt;
-&lt;input type=&quot;button&quot; value=&quot;Set&quot; onclick=&quot;set();&quot;&gt;
-&lt;input type=&quot;button&quot; value=&quot;Poke&quot; onclick=&quot;poke();&quot;&gt;
-&lt;input type=&quot;text&quot; id=&quot;Value&quot;&gt;
-&lt;input type=&quot;button&quot; value=&quot;Write&quot; onclick=&quot;sampleWrite();&quot;&gt;
-&lt;form>
-
-</pre>
-
-<p>
-<hr>
-<b>Resources:</b>
-<ul>
-<li><a href="http://lxr.mozilla.org/seamonkey/source/xpcom/sample/">mozilla/xpcom/sample source directory</a>
-</ul>
-<hr>
-<b>Comments to:</b>
-<a href="mailto:mang@subcarrier.org?Subject=XPCOM sample documentation">Michael Ang &lt;mang@subcarrier.org&gt;</a>