1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1999
20
* the Initial Developer. All Rights Reserved.
23
* Mike McCabe <mccabe@netscape.com>
24
* John Bandhauer <jband@netscape.com>
26
* Alternatively, the contents of this file may be used under the terms of
27
* either of the GNU General Public License Version 2 or later (the "GPL"),
28
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the MPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the MPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
40
/* Library-private header for Interface Info system. */
42
#ifndef xptiprivate_h___
43
#define xptiprivate_h___
46
#include "nsISupports.h"
48
// this after nsISupports, to pick up IID
49
// so that xpt stuff doesn't try to define it itself...
50
#include "xpt_struct.h"
53
#include "nsIInterfaceInfo.h"
54
#include "nsIInterfaceInfoManager.h"
56
#include "nsIXPTLoader.h"
58
#include "nsIServiceManager.h"
59
#include "nsILocalFile.h"
60
#include "nsIDirectoryService.h"
61
#include "nsDirectoryServiceDefs.h"
62
#include "nsAppDirectoryServiceDefs.h"
63
#include "nsIWeakReference.h"
68
#include "nsISupportsArray.h"
69
#include "nsSupportsArray.h"
72
#include "nsQuickSort.h"
74
#include "nsXPIDLString.h"
76
#include "nsIInputStream.h"
78
#include "nsAutoLock.h"
90
/***************************************************************************/
92
#if 0 && defined(DEBUG_jband)
93
#define LOG_RESOLVE(x) printf x
94
#define LOG_LOAD(x) printf x
95
#define LOG_AUTOREG(x) do{printf x; xptiInterfaceInfoManager::WriteToLog x;}while(0)
97
#define LOG_RESOLVE(x) ((void)0)
98
#define LOG_LOAD(x) ((void)0)
99
#define LOG_AUTOREG(x) xptiInterfaceInfoManager::WriteToLog x
102
#if 1 && defined(DEBUG_jband)
103
#define SHOW_INFO_COUNT_STATS
106
/***************************************************************************/
109
class xptiInterfaceInfo;
110
class xptiInterfaceInfoManager;
111
class xptiInterfaceEntry;
112
class xptiInterfaceGuts;
113
class xptiTypelibGuts;
114
class xptiWorkingSet;
116
/***************************************************************************/
121
// No ctors or dtors so that we can be in a union in xptiInterfaceInfo.
122
// Allow automatic shallow copies.
124
uint16 GetFileIndex() const {return mFileIndex;}
125
uint16 GetZipItemIndex() const {return mZipItemIndex;}
127
enum {NOT_ZIP = 0xffff};
129
PRBool IsZip() const {return mZipItemIndex != NOT_ZIP;}
131
void Init(uint16 aFileIndex, uint16 aZipItemIndex = NOT_ZIP)
132
{mFileIndex = aFileIndex; mZipItemIndex = aZipItemIndex;}
134
PRBool Equals(const xptiTypelib& r) const
135
{return mFileIndex == r.mFileIndex &&
136
mZipItemIndex == r.mZipItemIndex;}
140
uint16 mZipItemIndex;
143
/***************************************************************************/
146
// These are always constructed in the struct arena using placement new.
147
// dtor need not be called.
149
class xptiTypelibGuts
152
static xptiTypelibGuts* NewGuts(XPTHeader* aHeader,
153
xptiWorkingSet* aWorkingSet);
155
XPTHeader* GetHeader() {return mHeader;}
156
PRUint16 GetEntryCount() const {return mHeader->num_interfaces;}
158
void SetEntryAt(PRUint16 i, xptiInterfaceEntry* ptr)
160
NS_ASSERTION(mHeader,"bad state!");
161
NS_ASSERTION(i < GetEntryCount(),"bad param!");
162
mEntryArray[i] = ptr;
165
xptiInterfaceEntry* GetEntryAt(PRUint16 i) const
167
NS_ASSERTION(mHeader,"bad state!");
168
NS_ASSERTION(i < GetEntryCount(),"bad param!");
169
return mEntryArray[i];
173
xptiTypelibGuts(); // not implemented
174
xptiTypelibGuts(XPTHeader* aHeader);
175
~xptiTypelibGuts() {}
176
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
179
XPTHeader* mHeader; // hold pointer into arena
180
xptiInterfaceEntry* mEntryArray[1]; // Always last. Sized to fit.
183
/***************************************************************************/
188
const nsInt64& GetSize() const {return mSize;}
189
const nsInt64& GetDate() const {return mDate;}
190
const char* GetName() const {return mName;}
191
const PRUint32 GetDirectory() const {return mDirectory;}
192
xptiTypelibGuts* GetGuts() {return mGuts;}
196
xptiFile(const nsInt64& aSize,
197
const nsInt64& aDate,
200
xptiWorkingSet* aWorkingSet);
202
xptiFile(const xptiFile& r, xptiWorkingSet* aWorkingSet);
206
PRBool SetHeader(XPTHeader* aHeader, xptiWorkingSet* aWorkingSet);
208
PRBool Equals(const xptiFile& r) const
210
return mDirectory == r.mDirectory &&
213
0 == PL_strcmp(mName, r.mName);
216
xptiFile(const xptiFile& r) {CopyFields(r);}
217
xptiFile& operator= (const xptiFile& r)
225
void CopyFields(const xptiFile& r)
228
// If 'this' has a workingset then it better match that of the assigner.
229
NS_ASSERTION(!mDEBUG_WorkingSet ||
230
mDEBUG_WorkingSet == r.mDEBUG_WorkingSet,
231
"illegal xptiFile assignment");
232
mDEBUG_WorkingSet = r.mDEBUG_WorkingSet;
238
mDirectory = r.mDirectory;
244
xptiWorkingSet* mDEBUG_WorkingSet;
248
const char* mName; // hold pointer into arena from initializer
249
xptiTypelibGuts* mGuts; // hold pointer into arena
253
/***************************************************************************/
258
const char* GetName() const {return mName;}
259
xptiTypelibGuts* GetGuts() {return mGuts;}
263
xptiZipItem(const char* aName,
264
xptiWorkingSet* aWorkingSet);
266
xptiZipItem(const xptiZipItem& r, xptiWorkingSet* aWorkingSet);
270
PRBool SetHeader(XPTHeader* aHeader, xptiWorkingSet* aWorkingSet);
272
PRBool Equals(const xptiZipItem& r) const
274
return 0 == PL_strcmp(mName, r.mName);
277
xptiZipItem(const xptiZipItem& r) {CopyFields(r);}
278
xptiZipItem& operator= (const xptiZipItem& r)
286
void CopyFields(const xptiZipItem& r)
289
// If 'this' has a workingset then it better match that of the assigner.
290
NS_ASSERTION(!mDEBUG_WorkingSet ||
291
mDEBUG_WorkingSet == r.mDEBUG_WorkingSet,
292
"illegal xptiFile assignment");
293
mDEBUG_WorkingSet = r.mDEBUG_WorkingSet;
302
xptiWorkingSet* mDEBUG_WorkingSet;
304
const char* mName; // hold pointer into arena from initializer
305
xptiTypelibGuts* mGuts; // hold pointer into arena
308
/***************************************************************************/
313
xptiWorkingSet(); // not implmented
314
xptiWorkingSet(nsISupportsArray* aDirectories);
317
PRBool IsValid() const;
319
void InvalidateInterfaceInfos();
320
void ClearHashTables();
322
void ClearZipItems();
324
// utility methods...
326
xptiTypelibGuts* GetTypelibGuts(const xptiTypelib& typelib)
328
return typelib.IsZip() ?
329
GetZipItemAt(typelib.GetZipItemIndex()).GetGuts() :
330
GetFileAt(typelib.GetFileIndex()).GetGuts();
333
enum {NOT_FOUND = 0xffffffff};
335
// FileArray stuff...
337
PRUint32 GetFileCount() const {return mFileCount;}
338
PRUint32 GetFileFreeSpace()
339
{return mFileArray ? mMaxFileCount - mFileCount : 0;}
341
PRUint32 FindFile(PRUint32 dir, const char* name);
343
PRUint32 GetTypelibDirectoryIndex(const xptiTypelib& typelib)
345
return GetFileAt(typelib.GetFileIndex()).GetDirectory();
348
const char* GetTypelibFileName(const xptiTypelib& typelib)
350
return GetFileAt(typelib.GetFileIndex()).GetName();
353
xptiFile& GetFileAt(PRUint32 i) const
355
NS_ASSERTION(mFileArray, "bad state!");
356
NS_ASSERTION(i < mFileCount, "bad param!");
357
return mFileArray[i];
360
void SetFileAt(PRUint32 i, const xptiFile& r)
362
NS_ASSERTION(mFileArray, "bad state!");
363
NS_ASSERTION(i < mFileCount, "bad param!");
367
void AppendFile(const xptiFile& r)
369
NS_ASSERTION(mFileArray, "bad state!");
370
NS_ASSERTION(mFileCount < mMaxFileCount, "bad param!");
371
mFileArray[mFileCount++] = r;
374
PRBool NewFileArray(PRUint32 count);
375
PRBool ExtendFileArray(PRUint32 count);
377
// ZipItemArray stuff...
379
PRUint32 GetZipItemCount() const {return mZipItemCount;}
380
PRUint32 GetZipItemFreeSpace()
381
{return mZipItemArray ? mMaxZipItemCount - mZipItemCount : 0;}
383
PRUint32 FindZipItemWithName(const char* name);
385
xptiZipItem& GetZipItemAt(PRUint32 i) const
387
NS_ASSERTION(mZipItemArray, "bad state!");
388
NS_ASSERTION(i < mZipItemCount, "bad param!");
389
return mZipItemArray[i];
392
void SetZipItemAt(PRUint32 i, const xptiZipItem& r)
394
NS_ASSERTION(mZipItemArray, "bad state!");
395
NS_ASSERTION(i < mZipItemCount, "bad param!");
396
mZipItemArray[i] = r;
399
void AppendZipItem(const xptiZipItem& r)
401
NS_ASSERTION(mZipItemArray, "bad state!");
402
NS_ASSERTION(mZipItemCount < mMaxZipItemCount, "bad param!");
403
mZipItemArray[mZipItemCount++] = r;
406
PRBool NewZipItemArray(PRUint32 count);
407
PRBool ExtendZipItemArray(PRUint32 count);
409
// Directory stuff...
411
PRUint32 GetDirectoryCount();
412
nsresult GetCloneOfDirectoryAt(PRUint32 i, nsILocalFile** dir);
413
nsresult GetDirectoryAt(PRUint32 i, nsILocalFile** dir);
414
PRBool FindDirectory(nsILocalFile* dir, PRUint32* index);
415
PRBool FindDirectoryOfFile(nsILocalFile* file, PRUint32* index);
416
PRBool DirectoryAtMatchesPersistentDescriptor(PRUint32 i, const char* desc);
420
XPTArena* GetStringArena() {return mStringArena;}
421
XPTArena* GetStructArena() {return mStructArena;}
426
PRUint32 mMaxFileCount;
427
xptiFile* mFileArray; // using new[] and delete[]
429
PRUint32 mZipItemCount;
430
PRUint32 mMaxZipItemCount;
431
xptiZipItem* mZipItemArray; // using new[] and delete[]
433
XPTArena* mStringArena;
434
XPTArena* mStructArena;
436
nsCOMPtr<nsISupportsArray> mDirectories;
439
// XXX make these private with accessors
440
PLDHashTable* mNameTable;
441
PLDHashTable* mIIDTable;
442
PRUint32* mFileMergeOffsetMap; // always in an arena
443
PRUint32* mZipItemMergeOffsetMap; // always in an arena
446
/***************************************************************************/
448
class xptiInterfaceGuts
451
uint16 mMethodBaseIndex;
452
uint16 mConstantBaseIndex;
453
xptiInterfaceEntry* mParent;
454
XPTInterfaceDescriptor* mDescriptor;
455
xptiTypelib mTypelib;
456
xptiWorkingSet* mWorkingSet;
458
static xptiInterfaceGuts* NewGuts(XPTInterfaceDescriptor* aDescriptor,
459
const xptiTypelib& aTypelib,
460
xptiWorkingSet* aWorkingSet)
462
void* place = XPT_MALLOC(aWorkingSet->GetStructArena(),
463
sizeof(xptiInterfaceGuts));
466
return new(place) xptiInterfaceGuts(aDescriptor, aTypelib, aWorkingSet);
470
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
471
xptiInterfaceGuts(XPTInterfaceDescriptor* aDescriptor,
472
const xptiTypelib& aTypelib,
473
xptiWorkingSet* aWorkingSet)
474
: mMethodBaseIndex(0),
475
mConstantBaseIndex(0),
477
mDescriptor(aDescriptor),
479
mWorkingSet(aWorkingSet) {}
481
~xptiInterfaceGuts() {}
484
/***************************************************************************/
486
// This class exists to help xptiInterfaceInfo store a 4-state (2 bit) value
487
// and a set of bitflags in one 8bit value. See below.
491
enum {STATE_MASK = 3};
493
xptiInfoFlags(uint8 n) : mData(n) {}
494
xptiInfoFlags(const xptiInfoFlags& r) : mData(r.mData) {}
496
static uint8 GetStateMask()
497
{return uint8(STATE_MASK);}
502
uint8 GetData() const
505
uint8 GetState() const
506
{return mData & GetStateMask();}
508
void SetState(uint8 state)
509
{mData &= ~GetStateMask(); mData |= state;}
511
void SetFlagBit(uint8 flag, PRBool on)
513
mData |= ~GetStateMask() & flag;
515
mData &= GetStateMask() | ~flag;}
517
PRBool GetFlagBit(uint8 flag) const
518
{return (mData & flag) ? PR_TRUE : PR_FALSE;}
524
/****************************************************/
526
// No virtual methods.
527
// We always create in the struct arena and construct using "placement new".
528
// No members need dtor calls.
530
class xptiInterfaceEntry
533
static xptiInterfaceEntry* NewEntry(const char* name,
536
const xptiTypelib& typelib,
537
xptiWorkingSet* aWorkingSet);
539
static xptiInterfaceEntry* NewEntry(const xptiInterfaceEntry& r,
540
const xptiTypelib& typelib,
541
xptiWorkingSet* aWorkingSet);
545
PARTIALLY_RESOLVED = 1,
550
// Additional bit flags...
551
enum {SCRIPTABLE = 4};
553
uint8 GetResolveState() const {return mFlags.GetState();}
555
PRBool IsFullyResolved() const
556
{return GetResolveState() == (uint8) FULLY_RESOLVED;}
558
PRBool HasInterfaceRecord() const
559
{int s = (int) GetResolveState();
560
return (s == PARTIALLY_RESOLVED || s == FULLY_RESOLVED) && mInterface;}
562
const xptiTypelib& GetTypelibRecord() const
563
{return HasInterfaceRecord() ? mInterface->mTypelib : mTypelib;}
565
xptiInterfaceGuts* GetInterfaceGuts() const
566
{return HasInterfaceRecord() ? mInterface : nsnull;}
569
PRBool DEBUG_ScriptableFlagIsValid() const
570
{int s = (int) GetResolveState();
571
if((s == PARTIALLY_RESOLVED || s == FULLY_RESOLVED) && mInterface)
573
if(XPT_ID_IS_SCRIPTABLE(mInterface->mDescriptor->flags))
574
return GetScriptableFlag();
575
return !GetScriptableFlag();
581
void SetScriptableFlag(PRBool on)
582
{mFlags.SetFlagBit(uint8(SCRIPTABLE),on);}
583
PRBool GetScriptableFlag() const
584
{return mFlags.GetFlagBit(uint8(SCRIPTABLE));}
586
const nsID* GetTheIID() const {return &mIID;}
587
const char* GetTheName() const {return mName;}
589
PRBool EnsureResolved(xptiWorkingSet* aWorkingSet = nsnull)
590
{return IsFullyResolved() ? PR_TRUE : Resolve(aWorkingSet);}
592
PRBool PartiallyResolveLocked(XPTInterfaceDescriptor* aDescriptor,
593
xptiWorkingSet* aWorkingSet);
595
nsresult GetInterfaceInfo(xptiInterfaceInfo** info);
596
PRBool InterfaceInfoEquals(const xptiInterfaceInfo* info) const
597
{return info == mInfo;}
599
void LockedInvalidateInterfaceInfo();
600
void LockedInterfaceInfoDeathNotification() {mInfo = nsnull;}
602
//////////////////////
603
// These non-virtual methods handle the delegated nsIInterfaceInfo methods.
605
nsresult GetName(char * *aName);
606
nsresult GetIID(nsIID * *aIID);
607
nsresult IsScriptable(PRBool *_retval);
609
//nsresult GetParent(nsIInterfaceInfo * *aParent);
610
nsresult GetMethodCount(PRUint16 *aMethodCount);
611
nsresult GetConstantCount(PRUint16 *aConstantCount);
612
nsresult GetMethodInfo(PRUint16 index, const nsXPTMethodInfo * *info);
613
nsresult GetMethodInfoForName(const char *methodName, PRUint16 *index, const nsXPTMethodInfo * *info);
614
nsresult GetConstant(PRUint16 index, const nsXPTConstant * *constant);
615
nsresult GetInfoForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval);
616
nsresult GetIIDForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID * *_retval);
617
nsresult GetTypeForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, nsXPTType *_retval);
618
nsresult GetSizeIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval);
619
nsresult GetLengthIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval);
620
nsresult GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint8 *_retval);
621
nsresult IsIID(const nsIID * IID, PRBool *_retval);
622
nsresult GetNameShared(const char **name);
623
nsresult GetIIDShared(const nsIID * *iid);
624
nsresult IsFunction(PRBool *_retval);
625
nsresult HasAncestor(const nsIID * iid, PRBool *_retval);
626
nsresult GetIIDForParamNoAlloc(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID *iid);
628
//////////////////////
631
xptiInterfaceEntry(); // not implemented
633
xptiInterfaceEntry(const char* name,
636
const xptiTypelib& typelib);
638
xptiInterfaceEntry(const xptiInterfaceEntry& r,
640
const xptiTypelib& typelib);
641
~xptiInterfaceEntry();
643
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
645
void SetResolvedState(int state)
646
{mFlags.SetState(uint8(state));}
648
PRBool Resolve(xptiWorkingSet* aWorkingSet = nsnull);
650
// We only call these "*Locked" variants after locking. This is done to
651
// allow reentrace as files are loaded and various interfaces resolved
652
// without having to worry about the locked state.
654
PRBool EnsureResolvedLocked(xptiWorkingSet* aWorkingSet = nsnull)
655
{return IsFullyResolved() ? PR_TRUE : ResolveLocked(aWorkingSet);}
656
PRBool ResolveLocked(xptiWorkingSet* aWorkingSet = nsnull);
660
nsresult GetEntryForParam(PRUint16 methodIndex,
661
const nsXPTParamInfo * param,
662
xptiInterfaceEntry** entry);
664
nsresult GetTypeInArray(const nsXPTParamInfo* param,
666
const XPTTypeDescriptor** type);
671
xptiTypelib mTypelib; // Valid only until resolved.
672
xptiInterfaceGuts* mInterface; // Valid only after resolved.
674
xptiInterfaceInfo* mInfo; // May come and go.
675
xptiInfoFlags mFlags;
676
char mName[1]; // Always last. Sized to fit.
679
struct xptiHashEntry : public PLDHashEntryHdr
681
xptiInterfaceEntry* value;
684
/****************************************************/
686
class xptiInterfaceInfo : public nsIInterfaceInfo
691
// Use delegation to implement (most!) of nsIInterfaceInfo.
692
NS_IMETHOD GetName(char * *aName) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetName(aName); }
693
NS_IMETHOD GetInterfaceIID(nsIID * *aIID) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIID(aIID); }
694
NS_IMETHOD IsScriptable(PRBool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsScriptable(_retval); }
696
NS_IMETHOD GetParent(nsIInterfaceInfo * *aParent)
698
if(!EnsureResolved() || !EnsureParent())
699
return NS_ERROR_UNEXPECTED;
700
NS_IF_ADDREF(*aParent = mParent);
703
NS_IMETHOD GetMethodCount(PRUint16 *aMethodCount) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodCount(aMethodCount); }
704
NS_IMETHOD GetConstantCount(PRUint16 *aConstantCount) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstantCount(aConstantCount); }
705
NS_IMETHOD GetMethodInfo(PRUint16 index, const nsXPTMethodInfo * *info) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfo(index, info); }
706
NS_IMETHOD GetMethodInfoForName(const char *methodName, PRUint16 *index, const nsXPTMethodInfo * *info) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfoForName(methodName, index, info); }
707
NS_IMETHOD GetConstant(PRUint16 index, const nsXPTConstant * *constant) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstant(index, constant); }
708
NS_IMETHOD GetInfoForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInfoForParam(methodIndex, param, _retval); }
709
NS_IMETHOD GetIIDForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID * *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParam(methodIndex, param, _retval); }
710
NS_IMETHOD GetTypeForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, nsXPTType *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetTypeForParam(methodIndex, param, dimension, _retval); }
711
NS_IMETHOD GetSizeIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval); }
712
NS_IMETHOD GetLengthIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetLengthIsArgNumberForParam(methodIndex, param, dimension, _retval); }
713
NS_IMETHOD GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint8 *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval); }
714
NS_IMETHOD IsIID(const nsIID * IID, PRBool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsIID(IID, _retval); }
715
NS_IMETHOD GetNameShared(const char **name) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetNameShared(name); }
716
NS_IMETHOD GetIIDShared(const nsIID * *iid) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDShared(iid); }
717
NS_IMETHOD IsFunction(PRBool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsFunction(_retval); }
718
NS_IMETHOD HasAncestor(const nsIID * iid, PRBool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->HasAncestor(iid, _retval); }
719
NS_IMETHOD GetIIDForParamNoAlloc(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID *iid) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParamNoAlloc(methodIndex, param, iid); }
722
xptiInterfaceInfo(xptiInterfaceEntry* entry);
725
{NS_IF_RELEASE(mParent); mEntry = nsnull;}
728
static void DEBUG_ShutdownNotification();
733
~xptiInterfaceInfo();
735
// Note that mParent might still end up as nsnull if we don't have one.
736
PRBool EnsureParent(xptiWorkingSet* aWorkingSet = nsnull)
738
NS_ASSERTION(mEntry && mEntry->IsFullyResolved(), "bad EnsureParent call");
739
return mParent || !mEntry->GetInterfaceGuts()->mParent || BuildParent();
742
PRBool EnsureResolved(xptiWorkingSet* aWorkingSet = nsnull)
744
return mEntry && mEntry->EnsureResolved(aWorkingSet);
749
NS_ASSERTION(mEntry &&
750
mEntry->IsFullyResolved() &&
752
mEntry->GetInterfaceGuts()->mParent,
753
"bad BuildParent call");
754
return NS_SUCCEEDED(mEntry->GetInterfaceGuts()->mParent->
755
GetInterfaceInfo(&mParent));
758
xptiInterfaceInfo(); // not implemented
761
xptiInterfaceEntry* mEntry;
762
xptiInterfaceInfo* mParent;
765
/***************************************************************************/
770
static PRBool Read(xptiInterfaceInfoManager* aMgr,
771
xptiWorkingSet* aWorkingSet);
773
static PRBool Write(xptiInterfaceInfoManager* aMgr,
774
xptiWorkingSet* aWorkingSet);
776
static PRBool Delete(xptiInterfaceInfoManager* aMgr);
779
xptiManifest(); // no implementation
782
/***************************************************************************/
784
class xptiZipLoaderSink : public nsIXPTLoaderSink
787
xptiZipLoaderSink(xptiInterfaceInfoManager* aMgr,
788
xptiWorkingSet* aWorkingSet) :
790
mWorkingSet(aWorkingSet) {}
793
NS_DECL_NSIXPTLOADERSINK
796
~xptiZipLoaderSink() {}
798
xptiInterfaceInfoManager* mManager;
799
xptiWorkingSet* mWorkingSet;
806
xptiZipLoader(); // not implemented
809
ReadXPTFileFromInputStream(nsIInputStream *stream,
810
xptiWorkingSet* aWorkingSet);
815
/***************************************************************************/
820
enum Type {UNKNOWN = -1, XPT = 0, ZIP = 1 };
822
static Type GetType(const char* name);
824
static PRBool IsUnknown(const char* name)
825
{return GetType(name) == UNKNOWN;}
827
static PRBool IsXPT(const char* name)
828
{return GetType(name) == XPT;}
830
static PRBool IsZip(const char* name)
831
{return GetType(name) == ZIP;}
833
xptiFileType(); // no implementation
836
/***************************************************************************/
838
// We use this is as a fancy way to open a logfile to be used within the scope
839
// of some given function where it is instantiated.
844
xptiAutoLog(); // not implemented
845
xptiAutoLog(xptiInterfaceInfoManager* mgr,
846
nsILocalFile* logfile, PRBool append);
849
void WriteTimestamp(PRFileDesc* fd, const char* msg);
851
xptiInterfaceInfoManager* mMgr;
852
PRFileDesc* mOldFileDesc;
854
PRFileDesc* m_DEBUG_FileDesc;
858
/***************************************************************************/
860
class xptiInterfaceInfoManager
861
: public nsIInterfaceInfoSuperManager
864
NS_DECL_NSIINTERFACEINFOMANAGER
865
NS_DECL_NSIINTERFACEINFOSUPERMANAGER
869
FoundZipEntry(const char* entryName,
872
xptiWorkingSet* aWorkingSet);
875
static xptiInterfaceInfoManager* GetInterfaceInfoManagerNoAddRef();
876
static void FreeInterfaceInfoManager();
878
xptiWorkingSet* GetWorkingSet() {return &mWorkingSet;}
879
PRFileDesc* GetOpenLogFile() {return mOpenLogFile;}
880
PRFileDesc* SetOpenLogFile(PRFileDesc* fd)
881
{PRFileDesc* temp = mOpenLogFile; mOpenLogFile = fd; return temp;}
883
PRBool LoadFile(const xptiTypelib& aTypelibRecord,
884
xptiWorkingSet* aWorkingSet = nsnull);
886
PRBool GetApplicationDir(nsILocalFile** aDir);
887
PRBool GetCloneOfManifestLocation(nsILocalFile** aDir);
889
void GetSearchPath(nsISupportsArray** aSearchPath)
890
{NS_ADDREF(*aSearchPath = mSearchPath);}
892
static PRLock* GetResolveLock(xptiInterfaceInfoManager* self = nsnull)
893
{if(!self && !(self = GetInterfaceInfoManagerNoAddRef()))
895
return self->mResolveLock;}
897
static PRLock* GetAutoRegLock(xptiInterfaceInfoManager* self = nsnull)
898
{if(!self && !(self = GetInterfaceInfoManagerNoAddRef()))
900
return self->mAutoRegLock;}
902
static PRMonitor* GetInfoMonitor(xptiInterfaceInfoManager* self = nsnull)
903
{if(!self && !(self = GetInterfaceInfoManagerNoAddRef()))
905
return self->mInfoMonitor;}
907
static void WriteToLog(const char *fmt, ...);
910
~xptiInterfaceInfoManager();
911
xptiInterfaceInfoManager(); // not implmented
912
xptiInterfaceInfoManager(nsISupportsArray* aSearchPath);
915
NO_FILES_CHANGED = 0,
917
FULL_VALIDATION_REQUIRED
922
PRBool BuildFileList(nsISupportsArray* aSearchPath,
923
nsISupportsArray** aFileList);
925
nsILocalFile** BuildOrderedFileArray(nsISupportsArray* aSearchPath,
926
nsISupportsArray* aFileList,
927
xptiWorkingSet* aWorkingSet);
929
XPTHeader* ReadXPTFile(nsILocalFile* aFile, xptiWorkingSet* aWorkingSet);
931
AutoRegMode DetermineAutoRegStrategy(nsISupportsArray* aSearchPath,
932
nsISupportsArray* aFileList,
933
xptiWorkingSet* aWorkingSet);
935
PRBool AddOnlyNewFilesFromFileList(nsISupportsArray* aSearchPath,
936
nsISupportsArray* aFileList,
937
xptiWorkingSet* aWorkingSet);
939
PRBool DoFullValidationMergeFromFileList(nsISupportsArray* aSearchPath,
940
nsISupportsArray* aFileList,
941
xptiWorkingSet* aWorkingSet);
943
PRBool VerifyAndAddEntryIfNew(xptiWorkingSet* aWorkingSet,
944
XPTInterfaceDirectoryEntry* iface,
945
const xptiTypelib& typelibRecord,
946
xptiInterfaceEntry** entryAdded);
948
PRBool MergeWorkingSets(xptiWorkingSet* aDestWorkingSet,
949
xptiWorkingSet* aSrcWorkingSet);
953
PRBool DEBUG_DumpFileList(nsISupportsArray* aFileList);
954
PRBool DEBUG_DumpFileArray(nsILocalFile** aFileArray, PRUint32 count);
955
PRBool DEBUG_DumpFileListInWorkingSet(xptiWorkingSet* aWorkingSet);
957
static PRBool BuildFileSearchPath(nsISupportsArray** aPath);
960
xptiWorkingSet mWorkingSet;
961
nsCOMPtr<nsILocalFile> mStatsLogFile;
962
nsCOMPtr<nsILocalFile> mAutoRegLogFile;
963
PRFileDesc* mOpenLogFile;
964
PRLock* mResolveLock;
965
PRLock* mAutoRegLock;
966
PRMonitor* mInfoMonitor;
967
PRLock* mAdditionalManagersLock;
968
nsSupportsArray mAdditionalManagers;
969
nsCOMPtr<nsISupportsArray> mSearchPath;
972
/***************************************************************************/
975
nsresult xptiCloneLocalFile(nsILocalFile* aLocalFile,
976
nsILocalFile** aCloneLocalFile);
978
nsresult xptiCloneElementAsLocalFile(nsISupportsArray* aArray, PRUint32 aIndex,
979
nsILocalFile** aLocalFile);
981
#endif /* xptiprivate_h___ */