1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xulrunner/examples/simple/components/src/SimpleTest.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et cin: */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include <stdio.h> 1.10 +#include "nsISimpleTest.h" 1.11 +#include "mozilla/ModuleUtils.h" 1.12 + 1.13 +class SimpleTest : public nsISimpleTest 1.14 +{ 1.15 +public: 1.16 + NS_DECL_ISUPPORTS 1.17 + NS_DECL_NSISIMPLETEST 1.18 +}; 1.19 + 1.20 +NS_IMPL_ISUPPORTS(SimpleTest, nsISimpleTest) 1.21 + 1.22 +NS_IMETHODIMP 1.23 +SimpleTest::Add(int32_t a, int32_t b, int32_t *r) 1.24 +{ 1.25 + printf("add(%d,%d) from C++\n", a, b); 1.26 + 1.27 + *r = a + b; 1.28 + return NS_OK; 1.29 +} 1.30 + 1.31 +NS_GENERIC_FACTORY_CONSTRUCTOR(SimpleTest) 1.32 + 1.33 +// 5e14b432-37b6-4377-923b-c987418d8429 1.34 +#define SIMPLETEST_CID \ 1.35 + { 0x5e14b432, 0x37b6, 0x4377, \ 1.36 + { 0x92, 0x3b, 0xc9, 0x87, 0x41, 0x8d, 0x84, 0x29 } } 1.37 + 1.38 +NS_DEFINE_NAMED_CID(SIMPLETEST_CID); 1.39 + 1.40 +static const mozilla::Module::CIDEntry kSimpleCIDs[] = { 1.41 + { &kSIMPLETEST_CID, false, nullptr, SimpleTestConstructor }, 1.42 + { nullptr } 1.43 +}; 1.44 + 1.45 +static const mozilla::Module::ContractIDEntry kSimpleContracts[] = { 1.46 + { "@test.mozilla.org/simple-test;1?impl=c++", &kSIMPLETEST_CID }, 1.47 + { nullptr } 1.48 +}; 1.49 + 1.50 +static const mozilla::Module kSimpleModule = { 1.51 + mozilla::Module::kVersion, 1.52 + kSimpleCIDs, 1.53 + kSimpleContracts 1.54 +}; 1.55 + 1.56 +NSMODULE_DEFN(SimpleTestModule) = &kSimpleModule;