LCOV - code coverage report
Current view: top level - toolkit/components/mozintl - MozIntlHelper.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 38 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "MozIntlHelper.h"
       7             : #include "jswrapper.h"
       8             : #include "mozilla/ModuleUtils.h"
       9             : 
      10             : #define MOZ_MOZINTLHELPER_CID \
      11             :   { 0xb43c96be, 0x2b3a, 0x4dc4, { 0x90, 0xe9, 0xb0, 0x6d, 0x34, 0x21, 0x9b, 0x68 } }
      12             : 
      13             : using namespace mozilla;
      14             : 
      15           0 : NS_IMPL_ISUPPORTS(MozIntlHelper, mozIMozIntlHelper)
      16             : 
      17             : MozIntlHelper::MozIntlHelper() = default;
      18             : 
      19             : MozIntlHelper::~MozIntlHelper() = default;
      20             : 
      21             : static nsresult
      22           0 : AddFunctions(JSContext* cx, JS::Handle<JS::Value> val, const JSFunctionSpec* funcs)
      23             : {
      24           0 :   if (!val.isObject()) {
      25           0 :     return NS_ERROR_INVALID_ARG;
      26             :   }
      27             : 
      28           0 :   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
      29           0 :   if (!realIntlObj) {
      30           0 :     return NS_ERROR_INVALID_ARG;
      31             :   }
      32             : 
      33           0 :   JSAutoCompartment ac(cx, realIntlObj);
      34             : 
      35           0 :   if (!JS_DefineFunctions(cx, realIntlObj, funcs)) {
      36           0 :     return NS_ERROR_FAILURE;
      37             :   }
      38             : 
      39           0 :   return NS_OK;
      40             : }
      41             : 
      42             : NS_IMETHODIMP
      43           0 : MozIntlHelper::AddGetCalendarInfo(JS::Handle<JS::Value> val, JSContext* cx)
      44             : {
      45             :   static const JSFunctionSpec funcs[] = {
      46             :     JS_SELF_HOSTED_FN("getCalendarInfo", "Intl_getCalendarInfo", 1, 0),
      47             :     JS_FS_END
      48             :   };
      49             : 
      50           0 :   return AddFunctions(cx, val, funcs);
      51             : }
      52             : 
      53             : NS_IMETHODIMP
      54           0 : MozIntlHelper::AddGetDisplayNames(JS::Handle<JS::Value> val, JSContext* cx)
      55             : {
      56             :   static const JSFunctionSpec funcs[] = {
      57             :     JS_SELF_HOSTED_FN("getDisplayNames", "Intl_getDisplayNames", 2, 0),
      58             :     JS_FS_END
      59             :   };
      60             : 
      61           0 :   return AddFunctions(cx, val, funcs);
      62             : }
      63             : 
      64             : NS_IMETHODIMP
      65           0 : MozIntlHelper::AddPluralRulesConstructor(JS::Handle<JS::Value> val, JSContext* cx)
      66             : {
      67           0 :   if (!val.isObject()) {
      68           0 :     return NS_ERROR_INVALID_ARG;
      69             :   }
      70             : 
      71           0 :   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
      72           0 :   if (!realIntlObj) {
      73           0 :     return NS_ERROR_INVALID_ARG;
      74             :   }
      75             : 
      76           0 :   JSAutoCompartment ac(cx, realIntlObj);
      77             : 
      78           0 :   if (!js::AddPluralRulesConstructor(cx, realIntlObj)) {
      79           0 :     return NS_ERROR_FAILURE;
      80             :   }
      81             : 
      82           0 :   return NS_OK;
      83             : }
      84             : 
      85             : NS_IMETHODIMP
      86           0 : MozIntlHelper::AddDateTimeFormatConstructor(JS::Handle<JS::Value> val, JSContext* cx)
      87             : {
      88           0 :   if (!val.isObject()) {
      89           0 :     return NS_ERROR_INVALID_ARG;
      90             :   }
      91             : 
      92           0 :   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
      93           0 :   if (!realIntlObj) {
      94           0 :     return NS_ERROR_INVALID_ARG;
      95             :   }
      96             : 
      97           0 :   JSAutoCompartment ac(cx, realIntlObj);
      98             : 
      99           0 :   if (!js::AddMozDateTimeFormatConstructor(cx, realIntlObj)) {
     100           0 :     return NS_ERROR_FAILURE;
     101             :   }
     102             : 
     103           0 :   return NS_OK;
     104             : }
     105             : 
     106             : NS_IMETHODIMP
     107           0 : MozIntlHelper::AddGetLocaleInfo(JS::Handle<JS::Value> val, JSContext* cx)
     108             : {
     109             :   static const JSFunctionSpec funcs[] = {
     110             :     JS_SELF_HOSTED_FN("getLocaleInfo", "Intl_getLocaleInfo", 1, 0),
     111             :     JS_FS_END
     112             :   };
     113             : 
     114           0 :   return AddFunctions(cx, val, funcs);
     115             : }
     116             : 
     117           0 : NS_GENERIC_FACTORY_CONSTRUCTOR(MozIntlHelper)
     118             : NS_DEFINE_NAMED_CID(MOZ_MOZINTLHELPER_CID);
     119             : 
     120             : static const Module::CIDEntry kMozIntlHelperCIDs[] = {
     121             :   { &kMOZ_MOZINTLHELPER_CID, false, nullptr, MozIntlHelperConstructor },
     122             :   { nullptr }
     123             : };
     124             : 
     125             : static const mozilla::Module::ContractIDEntry kMozIntlHelperContracts[] = {
     126             :   { "@mozilla.org/mozintlhelper;1", &kMOZ_MOZINTLHELPER_CID },
     127             :   { nullptr }
     128             : };
     129             : 
     130             : static const mozilla::Module kMozIntlHelperModule = {
     131             :   mozilla::Module::kVersion,
     132             :   kMozIntlHelperCIDs,
     133             :   kMozIntlHelperContracts,
     134             :   nullptr,
     135             :   nullptr,
     136             :   nullptr,
     137             :   nullptr
     138             : };
     139             : 
     140             : NSMODULE_DEFN(mozMozIntlHelperModule) = &kMozIntlHelperModule;

Generated by: LCOV version 1.13