Back to index

lightning-sunbird  0.9+nobinonly
test.cpp
Go to the documentation of this file.
00001 #include "test.h"
00002 #include <stdio.h>
00003 
00004 class testimpl : public test
00005 {
00006 public:
00007     testimpl() : mIntProp(-5) { }
00008     NS_DECL_ISUPPORTS
00009     NS_DECL_TEST
00010 private:
00011     PRInt32 mIntProp;
00012 };
00013 
00014 NS_IMPL_ISUPPORTS1(testimpl, test);
00015 
00016 NS_IMETHODIMP
00017 testimpl::Poke(const char *with)
00018 {
00019     fprintf(stderr, "poke: %s!\n", with);
00020     return NS_OK;
00021 }
00022 
00023 NS_IMETHODIMP
00024 testimpl::Say(const char *sayIt)
00025 {
00026     fprintf(stderr, "testimpl says: %s!\n", sayIt);
00027     return NS_OK;
00028 }
00029 
00030 NS_IMETHODIMP
00031 testimpl::Shout(const char *shoutIt)
00032 {
00033     fprintf(stderr, "testimpl shouts: %s!\n", shoutIt);
00034     return NS_OK;
00035 }
00036 
00037 NS_IMETHODIMP
00038 testimpl::Add(PRInt32 a, PRInt32 b, PRInt32 *result)
00039 {
00040     *result = a + b;
00041     fprintf(stderr, "%d(%08x) + %d(%08x) = %d(%08x)\n", a, a, b, b,
00042             *result, *result);
00043     return NS_OK;
00044 }
00045 
00046 NS_IMETHODIMP
00047 testimpl::Peek(char **retval)
00048 {
00049     *retval = strdup("AHOY!");
00050     fprintf(stderr, "ahoy is %p @ %p\n", *retval, retval);
00051     return NS_OK;
00052 }
00053 
00054 NS_IMETHODIMP
00055 testimpl::Callback(testCallback *cb)
00056 {
00057     fprintf(stderr, "testCallback is %p\n", cb);
00058     return cb->Call();
00059 }
00060 
00061 NS_IMETHODIMP
00062 testimpl::GetIntProp(PRInt32 *aIntProp)
00063 {
00064     *aIntProp = mIntProp;
00065     return NS_OK;
00066 }
00067 
00068 NS_IMETHODIMP
00069 testimpl::SetIntProp(PRInt32 aIntProp)
00070 {
00071     mIntProp = aIntProp;
00072     return NS_OK;
00073 }
00074 
00075 NS_IMETHODIMP
00076 testimpl::GetRoIntProp(PRInt32 *aRoIntProp)
00077 {
00078     *aRoIntProp = 42;
00079     return NS_OK;
00080 }
00081 
00082 extern "C" testimpl*
00083 GetImpl(void)
00084 {
00085     return new testimpl;
00086 }