dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp
author Mike Hommey <mh+mozilla@glandium.org>
Fri, 05 Apr 2019 02:30:56 +0000
changeset 468491 60669a841a87644ba9b2f4d9f17f225e2eca0980
parent 446977 0ceae9db9ec0be18daa1a279511ad305723185d4
permissions -rw-r--r--
Bug 1541792 - Replace linker magic with manual component registration. r=froydnj Before bug 938437, we had a rather large and error-prone nsStaticXULComponents.cpp used to register all modules. That was replaced with clever use of the linker, which allowed to avoid the mess that maintaining that file was. Fast forward to now, where after bug 1524687 and other work that preceded it, we have a much smaller number of remaining static xpcom components, registered via this linker hack, and don't expect to add any new ones. The list should eventually go down to zero. Within that context, it seems to be the right time to get rid of the magic, and with it the problems it causes on its own. Some of those components could probably be trivially be converted to static registration via .conf files, but I didn't want to deal with the possible need to increase the number of dummy modules in XPCOMInit.cpp. They can still be converted as a followup. Differential Revision: https://phabricator.services.mozilla.com/D26076

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "OSXSpeechSynthesizerService.h"

using namespace mozilla::dom;

#define OSXSPEECHSYNTHESIZERSERVICE_CID              \
  {                                                  \
    0x914e73b4, 0x6337, 0x4bef, {                    \
      0x97, 0xf3, 0x4d, 0x06, 0x9e, 0x05, 0x3a, 0x12 \
    }                                                \
  }

#define OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID "@mozilla.org/synthsystem;1"

// Defines OSXSpeechSynthesizerServiceConstructor
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(
    OSXSpeechSynthesizerService,
    OSXSpeechSynthesizerService::GetInstanceForService)

// Defines kOSXSERVICE_CID
NS_DEFINE_NAMED_CID(OSXSPEECHSYNTHESIZERSERVICE_CID);

static const mozilla::Module::CIDEntry kCIDs[] = {
    {&kOSXSPEECHSYNTHESIZERSERVICE_CID, true, nullptr,
     OSXSpeechSynthesizerServiceConstructor},
    {nullptr}};

static const mozilla::Module::ContractIDEntry kContracts[] = {
    {OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID, &kOSXSPEECHSYNTHESIZERSERVICE_CID},
    {nullptr}};

static const mozilla::Module::CategoryEntry kCategories[] = {
    {"speech-synth-started", "OSX Speech Synth",
     OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID},
    {nullptr}};

static void UnloadOSXSpeechSynthesizerModule() {
  OSXSpeechSynthesizerService::Shutdown();
}

extern const mozilla::Module kSpeechSynthModule = {
    mozilla::Module::kVersion,
    kCIDs,
    kContracts,
    kCategories,
    nullptr,
    nullptr,
    UnloadOSXSpeechSynthesizerModule};