summaryrefslogtreecommitdiffstats
path: root/application/xulrunner/examples/simple/components/src
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-25 15:48:44 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-25 15:48:44 +0200
commit3ab6c7feee8126bdfc5c9ab9371db41102e12e95 (patch)
treea309c45826300b888238b6a517051fe7e71d63eb /application/xulrunner/examples/simple/components/src
parentb18a9cf86ea25bc52d9cfea584e3aa8bfbe81f0a (diff)
parentb069dabc91b7e0f5f8d161cdbe598276a21d6d68 (diff)
downloadUXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar
UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.gz
UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.lz
UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.xz
UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into pm_url_1
Diffstat (limited to 'application/xulrunner/examples/simple/components/src')
-rw-r--r--application/xulrunner/examples/simple/components/src/SimpleTest.cpp54
-rw-r--r--application/xulrunner/examples/simple/components/src/SimpleTest.js27
-rw-r--r--application/xulrunner/examples/simple/components/src/SimpleTest.manifest2
-rw-r--r--application/xulrunner/examples/simple/components/src/moz.build21
4 files changed, 104 insertions, 0 deletions
diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.cpp b/application/xulrunner/examples/simple/components/src/SimpleTest.cpp
new file mode 100644
index 000000000..06249abdd
--- /dev/null
+++ b/application/xulrunner/examples/simple/components/src/SimpleTest.cpp
@@ -0,0 +1,54 @@
+/* vim:set ts=2 sw=2 sts=2 et cin: */
+/* 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 <stdio.h>
+#include "nsISimpleTest.h"
+#include "mozilla/ModuleUtils.h"
+
+class SimpleTest : public nsISimpleTest
+{
+ ~SimpleTest() {}
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISIMPLETEST
+};
+
+NS_IMPL_ISUPPORTS(SimpleTest, nsISimpleTest)
+
+NS_IMETHODIMP
+SimpleTest::Add(int32_t a, int32_t b, int32_t *r)
+{
+ printf("add(%d,%d) from C++\n", a, b);
+
+ *r = a + b;
+ return NS_OK;
+}
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(SimpleTest)
+
+// 5e14b432-37b6-4377-923b-c987418d8429
+#define SIMPLETEST_CID \
+ { 0x5e14b432, 0x37b6, 0x4377, \
+ { 0x92, 0x3b, 0xc9, 0x87, 0x41, 0x8d, 0x84, 0x29 } }
+
+NS_DEFINE_NAMED_CID(SIMPLETEST_CID);
+
+static const mozilla::Module::CIDEntry kSimpleCIDs[] = {
+ { &kSIMPLETEST_CID, false, nullptr, SimpleTestConstructor },
+ { nullptr }
+};
+
+static const mozilla::Module::ContractIDEntry kSimpleContracts[] = {
+ { "@test.mozilla.org/simple-test;1?impl=c++", &kSIMPLETEST_CID },
+ { nullptr }
+};
+
+static const mozilla::Module kSimpleModule = {
+ mozilla::Module::kVersion,
+ kSimpleCIDs,
+ kSimpleContracts
+};
+
+NSMODULE_DEFN(SimpleTestModule) = &kSimpleModule;
diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.js b/application/xulrunner/examples/simple/components/src/SimpleTest.js
new file mode 100644
index 000000000..e6cf90660
--- /dev/null
+++ b/application/xulrunner/examples/simple/components/src/SimpleTest.js
@@ -0,0 +1,27 @@
+/* vim:set ts=2 sw=2 sts=2 et cin: */
+/* 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");
+
+function SimpleTest() {
+}
+
+SimpleTest.prototype = {
+ classID: Components.ID("{4177e257-a0dc-49b9-a774-522a000a49fa}"),
+
+ QueryInterface: function(iid) {
+ if (iid.equals(Components.interfaces.nsISimpleTest) ||
+ iid.equals(Components.interfaces.nsISupports))
+ return this;
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ },
+
+ add: function(a, b) {
+ dump("add(" + a + "," + b + ") from JS\n");
+ return a + b;
+ }
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SimpleTest]);
diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.manifest b/application/xulrunner/examples/simple/components/src/SimpleTest.manifest
new file mode 100644
index 000000000..c7388b9d7
--- /dev/null
+++ b/application/xulrunner/examples/simple/components/src/SimpleTest.manifest
@@ -0,0 +1,2 @@
+component {4177e257-a0dc-49b9-a774-522a000a49fa} SimpleTest.js
+contract @test.mozilla.org/simple-test;1?impl=js {4177e257-a0dc-49b9-a774-522a000a49fa}
diff --git a/application/xulrunner/examples/simple/components/src/moz.build b/application/xulrunner/examples/simple/components/src/moz.build
new file mode 100644
index 000000000..153bfdd0c
--- /dev/null
+++ b/application/xulrunner/examples/simple/components/src/moz.build
@@ -0,0 +1,21 @@
+# -*- 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/.
+
+SOURCES += [
+ 'SimpleTest.cpp',
+]
+
+XPCOMBinaryComponent('simpletest')
+
+EXTRA_COMPONENTS += [
+ 'SimpleTest.js',
+ 'SimpleTest.manifest',
+]
+
+XPI_NAME = 'simple'
+
+if CONFIG['GNU_CXX']:
+ CXXFLAGS += ['-Wshadow']