Adele
adele wrote:
Hello, everyone, Could you please take a look at the problem I encountered while compiling WebLock.cpp? I have a class myEnumerator in the same file. When I compile, I got the following errors. I looked at the Appendix in your book and couldn't figure out why. > I attached all the files needed to compile. If you need more info, pls let me know. Thank you.
myEnumerator.cpp: In instantiation of `nsDerivedSafe<nsIComponentManager>':
myEnumerator.cpp:75: instantiated from here
myEnumerator.cpp:75: base class `nsIComponentManager' has incomplete type
myEnumerator.cpp: In member function `virtual nsresult
myEnumerator::GetNext(nsISupports**)':
myEnumerator.cpp:78: no matching function for call to `
nsDerivedSafe<nsIComponentManager>::CreateInstance(const nsCID&, int, const
nsID&, void**)'
Adele
------------------------------------------------------------------------
CXX = c++ CPPFLAGS += -fno-rtti \
-fno-exceptions \
-shared # Change this to point at your Gecko SDK directory. GECKO_SDK_PATH = /home/adele/gecko-sdk
# GCC only define which allows us to not have to #include mozilla-config # in every .cpp file. If your not using GCC remove this line and add # #include "mozilla-config.h" to each of your .cpp files. GECKO_CONFIG_INCLUDE = -include mozilla-config.h GECKO_DEFINES = -DXPCOM_GLUE -DMOZILLA_STRICT_API
GECKO_INCLUDES = -I $(GECKO_SDK_PATH) \ -I $(GECKO_SDK_PATH)/xpcom/include \ -I $(GECKO_SDK_PATH)/nspr/include \ -I $(GECKO_SDK_PATH)/string/include \ -I $(GECKO_SDK_PATH)/embedstring/include \ -I .
GECKO_LDFLAGS = -L $(GECKO_SDK_PATH)/xpcom/bin -lxpcomglue \
-L $(GECKO_SDK_PATH)/nspr/bin -lnspr4 \
-L $(GECKO_SDK_PATH)/nspr/bin -lplds4 \
-L $(GECKO_SDK_PATH)/embedstring/bin/ -lembedstring build: $(CXX) -c $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) myEnumerator.cpp
clean:
------------------------------------------------------------------------
#include "nsIGenericFactory.h"
#include "nsCOMPtr.h" #include "nsXPCOM.h" #include "nsIServiceManager.h" #include "nsICategoryManager.h"
#include "nsIObserver.h"
#include "nsEmbedString.h" #include "nsMemory.h"
#include "nsXPCOMCID.h" #include "nsISupportsPrimitives.h"
#include <stdlib.h>
static NS_DEFINE_CID(kSupportsCStringCID, NS_SUPPORTS_CSTRING_CID);
// a simple link list. struct urlNode { char* urlString; struct urlNode* next; };
class myEnumerator : public nsISimpleEnumerator { public: NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR myEnumerator(urlNode* node) { mNode = node; } virtual ~myEnumerator(void) {} protected: urlNode* mNode; nsCOMPtr<nsIComponentManager> mCompMgr; };
NS_IMETHODIMP myEnumerator::HasMoreElements(PRBool* aResult) { if (!aResult) return NS_ERROR_NULL_POINTER; if (!mNode) { *aResult = PR_FALSE; return NS_OK; } *aResult = PR_TRUE; return NS_OK; }
NS_IMETHODIMP myEnumerator::GetNext(nsISupports** aResult) { if (! aResult) return NS_ERROR_NULL_POINTER; *aResult = nsnull; if (!mNode) return NS_ERROR_FAILURE; if (!mCompMgr) { NS_GetComponentManager(getter_AddRefs(mCompMgr)); if (!mCompMgr) return NS_ERROR_UNEXPECTED; } nsISupportsCString* stringSupports; mCompMgr->CreateInstance(kSupportsCStringCID, nsnull, NS_GET_IID(nsISupportsCString), (void**)&stringSupports); if (!stringSupports) return NS_ERROR_UNEXPECTED; nsEmbedCString str(mNode->urlString); stringSupports->SetData(str); *aResult = stringSupports; // addref'ed above. mNode = mNode->next; return NS_OK; }
_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
