|
1 /* vim:set ts=2 sw=2 sts=2 et cin: */ |
|
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 <stdio.h> |
|
7 #include "nsISimpleTest.h" |
|
8 #include "mozilla/ModuleUtils.h" |
|
9 |
|
10 class SimpleTest : public nsISimpleTest |
|
11 { |
|
12 public: |
|
13 NS_DECL_ISUPPORTS |
|
14 NS_DECL_NSISIMPLETEST |
|
15 }; |
|
16 |
|
17 NS_IMPL_ISUPPORTS(SimpleTest, nsISimpleTest) |
|
18 |
|
19 NS_IMETHODIMP |
|
20 SimpleTest::Add(int32_t a, int32_t b, int32_t *r) |
|
21 { |
|
22 printf("add(%d,%d) from C++\n", a, b); |
|
23 |
|
24 *r = a + b; |
|
25 return NS_OK; |
|
26 } |
|
27 |
|
28 NS_GENERIC_FACTORY_CONSTRUCTOR(SimpleTest) |
|
29 |
|
30 // 5e14b432-37b6-4377-923b-c987418d8429 |
|
31 #define SIMPLETEST_CID \ |
|
32 { 0x5e14b432, 0x37b6, 0x4377, \ |
|
33 { 0x92, 0x3b, 0xc9, 0x87, 0x41, 0x8d, 0x84, 0x29 } } |
|
34 |
|
35 NS_DEFINE_NAMED_CID(SIMPLETEST_CID); |
|
36 |
|
37 static const mozilla::Module::CIDEntry kSimpleCIDs[] = { |
|
38 { &kSIMPLETEST_CID, false, nullptr, SimpleTestConstructor }, |
|
39 { nullptr } |
|
40 }; |
|
41 |
|
42 static const mozilla::Module::ContractIDEntry kSimpleContracts[] = { |
|
43 { "@test.mozilla.org/simple-test;1?impl=c++", &kSIMPLETEST_CID }, |
|
44 { nullptr } |
|
45 }; |
|
46 |
|
47 static const mozilla::Module kSimpleModule = { |
|
48 mozilla::Module::kVersion, |
|
49 kSimpleCIDs, |
|
50 kSimpleContracts |
|
51 }; |
|
52 |
|
53 NSMODULE_DEFN(SimpleTestModule) = &kSimpleModule; |