Compare commits

..

2 Commits

Author SHA1 Message Date
fur%netscape.com
1c43d4984f This is a copy of regalloc_code2_BRANCH from Netscape's private repository,
as it existed in January of 1998.


git-svn-id: svn://10.0.0.236/branches/regalloc_code2_BRANCH@22571 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-02 16:12:08 +00:00
(no author)
cfe021ff88 This commit was manufactured by cvs2svn to create branch
'regalloc_code2_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/regalloc_code2_BRANCH@22567 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-02 15:57:58 +00:00
1640 changed files with 5230 additions and 479315 deletions

View File

@@ -0,0 +1,134 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "BitSet.h"
// Return the next bit after index set to true or -1 if none.
//
Int32 BitSet::nextOne(Int32 pos) const
{
++pos;
if (pos < 0 || Uint32(pos) >= universeSize)
return -1;
Uint32 offset = getWordOffset(pos);
Uint8 index = getBitOffset(pos);
Word* ptr = &word[offset];
Word currentWord = *ptr++ >> index;
if (currentWord != Word(0)) {
while ((currentWord & Word(1)) == 0) {
++index;
currentWord >>= 1;
}
return (offset << nBitsInWordLog2) + index;
}
Word* limit = &word[getSizeInWords(universeSize)];
while (ptr < limit) {
++offset;
currentWord = *ptr++;
if (currentWord != Word(0)) {
index = 0;
while ((currentWord & Word(1)) == 0) {
++index;
currentWord >>= 1;
}
return (offset << nBitsInWordLog2) + index;
}
}
return -1;
}
// Return the next bit after index set to false or -1 if none.
//
Int32 BitSet::nextZero(Int32 pos) const
{
++pos;
if (pos < 0 || Uint32(pos) >= universeSize)
return -1;
Uint32 offset = getWordOffset(pos);
Uint8 index = getBitOffset(pos);
Word* ptr = &word[offset];
Word currentWord = *ptr++ >> index;
if (currentWord != Word(~0)) {
for (; index < nBitsInWord; ++index) {
if ((currentWord & Word(1)) == 0) {
Int32 ret = (offset << nBitsInWordLog2) + index;
return (Uint32(ret) < universeSize) ? ret : -1;
}
currentWord >>= 1;
}
}
Word* limit = &word[getSizeInWords(universeSize)];
while (ptr < limit) {
++offset;
currentWord = *ptr++;
if (currentWord != Word(~0)) {
for (index = 0; index < nBitsInWord; ++index) {
if ((currentWord & Word(1)) == 0) {
Int32 ret = (offset << nBitsInWordLog2) + index;
return (Uint32(ret) < universeSize) ? ret : -1;
}
currentWord >>= 1;
}
}
}
return -1;
}
#ifdef DEBUG_LOG
// Print the set.
//
void BitSet::printPretty(LogModuleObject log)
{
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("[ "));
for (Int32 i = firstOne(); i != -1; i = nextOne(i)) {
Int32 currentBit = i;
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", currentBit));
Int32 nextBit = nextOne(currentBit);
if (nextBit != currentBit + 1) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" "));
continue;
}
while ((nextBit != -1) && (nextBit == (currentBit + 1))) {
currentBit = nextBit;
nextBit = nextOne(nextBit);
}
if (currentBit > (i+1))
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("-%d ", currentBit));
else
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" %d ", currentBit));
i = currentBit;
}
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("]\n"));
}
#endif // DEBUG_LOG

View File

@@ -0,0 +1,195 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _BITSET_H_
#define _BITSET_H_
#include "Fundamentals.h"
#include "LogModule.h"
#include "Pool.h"
#include <string.h>
//------------------------------------------------------------------------------
// BitSet -
class BitSet
{
private:
#if (PR_BITS_PER_WORD == 64)
typedef Uint64 Word;
#elif (PR_BITS_PER_WORD == 32)
typedef Uint32 Word;
#endif
static const nBitsInWord = PR_BITS_PER_WORD;
static const nBytesInWord = PR_BYTES_PER_WORD;
static const nBitsInWordLog2 = PR_BITS_PER_WORD_LOG2;
static const nBytesInWordLog2 = PR_BYTES_PER_WORD_LOG2;
// Return the number of Word need to store the universe.
static Uint32 getSizeInWords(Uint32 sizeOfUniverse) {return (sizeOfUniverse + (nBitsInWord - 1)) >> nBitsInWordLog2;}
// Return the given element offset in its containing Word.
static Uint32 getBitOffset(Uint32 element) {return element & (nBitsInWord - 1);}
// Return the Word offset for the given element int the universe.
static Uint32 getWordOffset(Uint32 element) {return element >> nBitsInWordLog2;}
// Return the mask for the given bit index.
static Word getMask(Uint8 index) {return Word(1) << index;}
private:
Uint32 universeSize; // Size of the universe
Word* word; // universe memory.
private:
// No copy constructor.
BitSet(const BitSet&);
// Check if the given set's universe is of the same size than this universe.
void checkUniverseCompatibility(const BitSet& set) const {assert(set.universeSize == universeSize);}
// Check if pos is valid for this set's universe.
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
public:
// Create a bitset of universeSize bits.
BitSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {word = new(pool) Word[getSizeInWords(universeSize)]; clear();}
// Return the size of this bitset.
Uint32 getSize() const {return universeSize;}
// Clear the bitset.
void clear() {memset(word, 0x00, getSizeInWords(universeSize) << nBytesInWordLog2);}
// Clear the bit at index.
void clear(Uint32 index) {checkMember(index); word[getWordOffset(index)] &= ~getMask(index);}
// Set the bitset.
void set() {memset(word, 0xFF, getSizeInWords(universeSize) << nBytesInWordLog2);}
// Set the bit at index.
void set(Uint32 index) {checkMember(index); word[getWordOffset(index)] |= getMask(index);}
// Return true if the bit at index is set.
bool test(Uint32 index) const {checkMember(index); return (word[getWordOffset(index)] & getMask(index)) != 0;}
// Union with the given bitset.
inline void or(const BitSet& set);
// Intersection with the given bitset.
inline void and(const BitSet& set);
// Difference with the given bitset.
inline void difference(const BitSet& set);
// Copy set.
inline BitSet& operator = (const BitSet& set);
// Return true if the bitset are identical.
friend bool operator == (const BitSet& set1, const BitSet& set2);
// Return true if the bitset are different.
friend bool operator != (const BitSet& set1, const BitSet& set2);
// Logical operators.
BitSet& operator |= (const BitSet& set) {or(set); return *this;}
BitSet& operator &= (const BitSet& set) {and(set); return *this;}
BitSet& operator -= (const BitSet& set) {difference(set); return *this;}
// Return the first bit at set to true or -1 if none.
Int32 firstOne() const {return nextOne(-1);}
// Return the next bit after index set to true or -1 if none.
Int32 nextOne(Int32 pos) const;
// Return the first bit at set to false or -1 if none.
Int32 firstZero() const {return nextZero(-1);}
// Return the next bit after index set to false or -1 if none.
Int32 nextZero(Int32 pos) const;
// Iterator to conform with the set API.
typedef Int32 iterator;
// Return true if the walk is ordered.
static bool isOrdered() {return true;}
// Return the iterator for the first element of this set.
iterator begin() const {return firstOne();}
// Return the next iterator.
iterator advance(iterator pos) const {return nextOne(pos);}
// Return true if the iterator is at the end of the set.
bool done(iterator pos) const {return pos == -1;}
// Return the element corresponding to the given iterator.
Uint32 get(iterator pos) const {return pos;}
#ifdef DEBUG_LOG
// Print the set.
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
// Union with the given bitset.
//
inline void BitSet::or(const BitSet& set)
{
checkUniverseCompatibility(set);
Word* src = set.word;
Word* dst = word;
Word* limit = &src[getSizeInWords(universeSize)];
while (src < limit)
*dst++ |= *src++;
}
// Intersection with the given bitset.
//
inline void BitSet::and(const BitSet& set)
{
checkUniverseCompatibility(set);
Word* src = set.word;
Word* dst = word;
Word* limit = &src[getSizeInWords(universeSize)];
while (src < limit)
*dst++ &= *src++;
}
// Difference with the given bitset.
//
inline void BitSet::difference(const BitSet& set)
{
checkUniverseCompatibility(set);
Word* src = set.word;
Word* dst = word;
Word* limit = &src[getSizeInWords(universeSize)];
while (src < limit)
*dst++ &= ~*src++;
}
// Copy the given set into this set.
//
inline BitSet& BitSet::operator = (const BitSet& set)
{
checkUniverseCompatibility(set);
if (this != &set)
memcpy(word, set.word, getSizeInWords(universeSize) << nBytesInWordLog2);
return *this;
}
// Return true if the given set is identical to this set.
inline bool operator == (const BitSet& set1, const BitSet& set2)
{
set1.checkUniverseCompatibility(set2);
if (&set1 == &set2)
return true;
return memcmp(set1.word, set2.word, BitSet::getSizeInWords(set1.universeSize) << BitSet::nBytesInWordLog2) == 0;
}
inline bool operator != (const BitSet& set1, const BitSet& set2) {return !(set1 == set2);}
#endif // _BITSET_H

View File

@@ -0,0 +1,159 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _COALESCING_H_
#define _COALESCING_H_
#include "Fundamentals.h"
#include "Pool.h"
#include "RegisterPressure.h"
#include "InterferenceGraph.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "SparseSet.h"
#include "RegisterAllocator.h"
#include "RegisterAllocatorTools.h"
#if 1
// Performing an ultra conservative coalescing meens that when we look at
// candidates (source,destination) for coalescing we need to make sure
// that the combined interference of the source and destination register
// will not exceed the total number of register available for the register
// class.
#define ULTRA_CONSERVATIVE_COALESCING
#else
// If we are not doing an ultra conservative coalescing we have to make sure
// that the total number of neighbor whose degree is greater than the total
// number of register is not greater than the total number of register.
#undef ULTRA_CONSERVATIVE_COALESCING
#endif
template <class RegisterPressure>
struct Coalescing
{
static bool coalesce(RegisterAllocator& registerAllocator);
};
template <class RegisterPressure>
bool Coalescing<RegisterPressure>::coalesce(RegisterAllocator& registerAllocator)
{
Pool& pool = registerAllocator.pool;
// Initialize the lookup table
//
Uint32 rangeCount = registerAllocator.rangeCount;
RegisterName* newRange = new RegisterName[2 * rangeCount];
RegisterName* coalescedRange = &newRange[rangeCount];
RegisterName* name2range = registerAllocator.name2range;
init(coalescedRange, rangeCount);
SparseSet interferences(pool, rangeCount);
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
bool removedInstructions = false;
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.lndList;
Uint32 nNodes = controlGraph.nNodes;
// Walk the nodes in the loop nesting depth list.
for (Int32 n = nNodes - 1; n >= 0; n--) {
InstructionList& instructions = nodes[n]->getInstructions();
InstructionList::iterator it = instructions.begin();
while (!instructions.done(it)) {
Instruction& instruction = instructions.get(it);
it = instructions.advance(it);
if ((instruction.getFlags() & ifCopy) != 0) {
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
RegisterName source = findRoot(name2range[instruction.getInstructionUseBegin()[0].getRegisterName()], coalescedRange);
RegisterName destination = findRoot(name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()], coalescedRange);
if (source == destination) {
instruction.remove();
} else if (!iGraph.interfere(source, destination)) {
InterferenceVector* sourceVector = iGraph.getInterferenceVector(source);
InterferenceVector* destinationVector = iGraph.getInterferenceVector(destination);
#ifdef ULTRA_CONSERVATIVE_COALESCING
interferences.clear();
InterferenceVector* vector;
for (vector = sourceVector; vector != NULL; vector = vector->next) {
RegisterName* neighbors = vector->neighbors;
for (Uint32 i = 0; i < vector->count; i++)
interferences.set(findRoot(neighbors[i], coalescedRange));
}
for (vector = destinationVector; vector != NULL; vector = vector->next) {
RegisterName* neighbors = vector->neighbors;
for (Uint32 i = 0; i < vector->count; i++)
interferences.set(findRoot(neighbors[i], coalescedRange));
}
Uint32 count = interferences.getSize();
#else // ULTRA_CONSERVATIVE_COALESCING
trespass("not implemented");
Uint32 count = 0;
#endif // ULTRA_CONSERVATIVE_COALESCING
if (count < 6 /* FIX: should get the number from the class */) {
// Update the interferences vector.
if (sourceVector == NULL) {
iGraph.setInterferenceVector(source, destinationVector);
sourceVector = destinationVector;
} else if (destinationVector == NULL)
iGraph.setInterferenceVector(destination, sourceVector);
else {
InterferenceVector* last = NULL;
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next)
last = v;
assert(last);
last->next = destinationVector;
iGraph.setInterferenceVector(destination, sourceVector);
}
// Update the interference matrix.
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next) {
RegisterName* neighbors = v->neighbors;
for (Uint32 i = 0; i < v->count; i++) {
RegisterName neighbor = findRoot(neighbors[i], coalescedRange);
iGraph.setInterference(neighbor, source);
iGraph.setInterference(neighbor, destination);
}
}
instruction.remove();
coalescedRange[source] = destination;
removedInstructions = true;
}
}
}
}
}
registerAllocator.rangeCount = compress(registerAllocator.name2range, coalescedRange, registerAllocator.nameCount, rangeCount);
delete newRange;
return removedInstructions;
}
#endif // _COALESCING_H_

View File

@@ -0,0 +1,283 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef NEW_LAURENTM_CODE
#include "Coloring.h"
#include "VirtualRegister.h"
#include "FastBitSet.h"
#include "FastBitMatrix.h"
#include "CpuInfo.h"
bool Coloring::
assignRegisters(FastBitMatrix& interferenceMatrix)
{
PRUint32 *stackPtr = new(pool) PRUint32[vRegManager.count()];
return select(interferenceMatrix, stackPtr, simplify(interferenceMatrix, stackPtr));
}
PRInt32 Coloring::
getLowestSpillCostRegister(FastBitSet& bitset)
{
PRInt32 lowest = bitset.firstOne();
if (lowest != -1)
{
Flt32 cost = vRegManager.getVirtualRegister(lowest).spillInfo.spillCost;
for (PRInt32 r = bitset.nextOne(lowest); r != -1; r = bitset.nextOne(r))
{
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
if (!vReg.spillInfo.infiniteSpillCost && (vReg.spillInfo.spillCost < cost))
{
cost = vReg.spillInfo.spillCost;
lowest = r;
}
}
}
return lowest;
}
PRUint32* Coloring::
simplify(FastBitMatrix interferenceMatrix, PRUint32* stackPtr)
{
// first we construct the sets low and high. low contains all nodes of degree
// inferior to the number of register available on the processor. All the
// nodes with an high degree and a finite spill cost are placed in high.
// Nodes of high degree and infinite spill cost are not included in either sets.
PRUint32 nRegisters = vRegManager.count();
FastBitSet low(pool, nRegisters);
FastBitSet high(pool, nRegisters);
FastBitSet stack(pool, nRegisters);
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
{
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
if (vReg.getClass() == vrcStackSlot)
{
stack.set(i);
vReg.colorRegister(nRegisters);
}
else
{
if (vReg.colorInfo.interferenceDegree < NUMBER_OF_REGISTERS)
low.set(i);
else // if (!vReg.spillInfo.infiniteSpillCost)
high.set(i);
// Set coloring info.
vReg.spillInfo.willSpill = false;
switch(vReg.getClass())
{
case vrcInteger:
vReg.colorRegister(LAST_GREGISTER + 1);
break;
case vrcFloatingPoint:
case vrcFixedPoint:
vReg.colorRegister(LAST_FPREGISTER + 1);
break;
default:
PR_ASSERT(false); // Cannot happen.
}
}
}
// push the stack registers
PRInt32 j;
for (j = stack.firstOne(); j != -1; j = stack.nextOne(j))
*stackPtr++ = j;
// simplify
while (true)
{
PRInt32 r;
while ((r = getLowestSpillCostRegister(low)) != -1)
{
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
/* update low and high */
FastBitSet inter(interferenceMatrix.getRow(r), nRegisters);
for (j = inter.firstOne(); j != -1; j = inter.nextOne(j))
{
VirtualRegister& neighbor = vRegManager.getVirtualRegister(j);
// if the new interference degree of one of his neighbor becomes
// NUMBER_OF_REGISTERS - 1 then it is added to the set 'low'.
PRUint32 maxInterference = 0;
switch (neighbor.getClass())
{
case vrcInteger:
maxInterference = NUMBER_OF_GREGISTERS;
break;
case vrcFloatingPoint:
case vrcFixedPoint:
maxInterference = NUMBER_OF_FPREGISTERS;
break;
default:
PR_ASSERT(false);
}
if ((vRegManager.getVirtualRegister(j).colorInfo.interferenceDegree-- == maxInterference))
{
high.clear(j);
low.set(j);
}
vReg.colorInfo.interferenceDegree--;
interferenceMatrix.clear(r, j);
interferenceMatrix.clear(j, r);
}
low.clear(r);
// Push this register.
*stackPtr++ = r;
}
if ((r = getLowestSpillCostRegister(high)) != -1)
{
high.clear(r);
low.set(r);
}
else
break;
}
return stackPtr;
}
bool Coloring::
select(FastBitMatrix& interferenceMatrix, PRUint32* stackBase, PRUint32* stackPtr)
{
PRUint32 nRegisters = vRegManager.count();
FastBitSet usedRegisters(NUMBER_OF_REGISTERS + 1); // usedRegisters if used for both GR & FPR.
FastBitSet preColoredRegisters(NUMBER_OF_REGISTERS + 1);
FastBitSet usedStack(nRegisters + 1);
bool success = true;
Int32 lastUsedSSR = -1;
// select
while (stackPtr != stackBase)
{
// Pop one register.
PRUint32 r = *--stackPtr;
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
FastBitSet neighbors(interferenceMatrix.getRow(r), nRegisters);
if (vReg.getClass() == vrcStackSlot)
// Stack slots coloring.
{
usedStack.clear();
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
usedStack.set(vRegManager.getVirtualRegister(i).getColor());
Int32 color = usedStack.firstZero();
vReg.colorRegister(color);
if (color > lastUsedSSR)
lastUsedSSR = color;
}
else
// Integer & Floating point register coloring.
{
usedRegisters.clear();
preColoredRegisters.clear();
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
{
VirtualRegister& nvReg = vRegManager.getVirtualRegister(i);
usedRegisters.set(nvReg.getColor());
if (nvReg.isPreColored())
preColoredRegisters.set(nvReg.getPreColor());
}
if (vReg.hasSpecialInterference)
usedRegisters |= vReg.specialInterference;
PRInt8 c = -1;
PRInt8 maxColor = 0;
PRInt8 firstColor = 0;
switch (vReg.getClass())
{
case vrcInteger:
firstColor = FIRST_GREGISTER;
maxColor = LAST_GREGISTER;
break;
case vrcFloatingPoint:
case vrcFixedPoint:
firstColor = FIRST_FPREGISTER;
maxColor = LAST_FPREGISTER;
break;
default:
PR_ASSERT(false);
}
if (vReg.isPreColored())
{
c = vReg.getPreColor();
if (usedRegisters.test(c))
c = -1;
}
else
{
for (c = usedRegisters.nextZero(firstColor - 1); (c >= 0) && (c <= maxColor) && (preColoredRegisters.test(c));
c = usedRegisters.nextZero(c)) {}
}
if ((c >= 0) && (c <= maxColor))
{
vReg.colorRegister(c);
}
else
{
VirtualRegister& stackRegister = vRegManager.newVirtualRegister(vrcStackSlot);
vReg.equivalentRegister[vrcStackSlot] = &stackRegister;
vReg.spillInfo.willSpill = true;
success = false;
}
}
}
#ifdef DEBUG
if (success)
{
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
{
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
switch (vReg.getClass())
{
case vrcInteger:
if (vReg.getColor() > LAST_GREGISTER)
PR_ASSERT(false);
break;
case vrcFloatingPoint:
case vrcFixedPoint:
#if NUMBER_OF_FPREGISTERS != 0
if (vReg.getColor() > LAST_FPREGISTER)
PR_ASSERT(false);
#endif
break;
default:
break;
}
}
}
#endif
vRegManager.nUsedStackSlots = lastUsedSSR + 1;
return success;
}
#endif // NEW_LAURENTM_CODE

View File

@@ -0,0 +1,284 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "RegisterAllocator.h"
#include "VirtualRegister.h"
#include "InterferenceGraph.h"
#include "SparseSet.h"
#include "Spilling.h"
#include "Splits.h"
UT_EXTERN_LOG_MODULE(RegAlloc);
template <class RegisterPressure>
class Coloring
{
private:
static RegisterName* simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack);
static bool select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr);
public:
static bool color(RegisterAllocator& registerAllocator);
static void finalColoring(RegisterAllocator& registerAllocator);
};
template <class RegisterPressure>
void Coloring<RegisterPressure>::finalColoring(RegisterAllocator& registerAllocator)
{
RegisterName* color = registerAllocator.color;
RegisterName* name2range = registerAllocator.name2range;
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
usePtr->setRegisterName(color[name2range[usePtr->getRegisterName()]]);
#ifdef DEBUG
RegisterID rid = usePtr->getRegisterID();
setColoredRegister(rid);
usePtr->setRegisterID(rid);
#endif // DEBUG
}
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
definePtr->setRegisterName(color[name2range[definePtr->getRegisterName()]]);
#ifdef DEBUG
RegisterID rid = definePtr->getRegisterID();
setColoredRegister(rid);
definePtr->setRegisterID(rid);
#endif // DEBUG
}
}
}
}
template <class RegisterPressure>
bool Coloring<RegisterPressure>::select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr)
{
Uint32 rangeCount = registerAllocator.rangeCount;
RegisterName* color = new RegisterName[rangeCount];
registerAllocator.color = color;
for (Uint32 r = 1; r < rangeCount; r++)
color[r] = RegisterName(6); // FIX;
// Color the preColored registers.
//
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
RegisterName* name2range = registerAllocator.name2range;
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
if (machinePtr->id != invalidID) {
color[name2range[getName(machinePtr->id)]] = machinePtr->color;
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill preColor range %d as %d\n", name2range[getName(machinePtr->id)], machinePtr->color));
}
SpillCost* cost = registerAllocator.spillCost;
Pool& pool = registerAllocator.pool;
SparseSet& spill = *new(pool) SparseSet(pool, rangeCount);
registerAllocator.willSpill = &spill;
SparseSet neighborColors(pool, 6); // FIX
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
bool coloringFailed = false;
while (coloringStackPtr > coloringStack) {
RegisterName range = *--coloringStackPtr;
if (!cost[range].infinite && cost[range].cost < 0) {
coloringFailed = true;
spill.set(range);
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, will spill.\n", range));
} else {
neighborColors.clear();
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
for (Int32 i = vector->count - 1; i >= 0; --i) {
RegisterName neighborColor = color[vector->neighbors[i]];
if (neighborColor < 6) // FIX
neighborColors.set(neighborColor);
}
if (neighborColors.getSize() == 6) { // FIX
coloringFailed = true;
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, ", range));
if (!Splits<RegisterPressure>::findSplit(registerAllocator, color, range)) {
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will spill.\n"));
spill.set(range);
} else
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will split.\n"));
} else {
for (Uint32 i = 0; i < 6; i++) // FIX
if (!neighborColors.test(i)) {
fprintf(stdout, "\twill color %d as %d\n", range, i);
color[range] = RegisterName(i);
break;
}
}
}
}
#ifdef DEBUG_LOG
if (coloringFailed) {
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring failed:\n"));
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill spill: "));
spill.printPretty(UT_LOG_MODULE(RegAlloc));
} else {
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring succeeded:\n"));
for (Uint32 i = 1; i < rangeCount; i++)
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\trange %d colored as %d\n", i, color[i]));
}
#endif
return !coloringFailed;
}
template <class RegisterPressure>
RegisterName* Coloring<RegisterPressure>::simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack)
{
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
SpillCost* spillCost = registerAllocator.spillCost;
Uint32 rangeCount = registerAllocator.rangeCount;
Uint32* degree = new Uint32[rangeCount];
for (RegisterName i = RegisterName(1); i < rangeCount; i = RegisterName(i + 1)) {
InterferenceVector* vector = iGraph.getInterferenceVector(i);
degree[i] = (vector != NULL) ? vector->count : 0;
}
Pool& pool = registerAllocator.pool;
SparseSet low(pool, rangeCount);
SparseSet high(pool, rangeCount);
SparseSet highInfinite(pool, rangeCount);
SparseSet preColored(pool, rangeCount);
// Get the precolored registers.
//
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
RegisterName* name2range = registerAllocator.name2range;
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
if (machinePtr->id != invalidID)
preColored.set(name2range[getName(machinePtr->id)]);
// Insert the live ranges in the sets.
//
for (Uint32 range = 1; range < rangeCount; range++)
if (!preColored.test(range))
if (degree[range] < 6) // FIX
low.set(range);
else if (!spillCost[range].infinite)
high.set(range);
else
highInfinite.set(range);
#ifdef DEBUG_LOG
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring sets:\n\tlow = "));
low.printPretty(UT_LOG_MODULE(RegAlloc));
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thigh = "));
high.printPretty(UT_LOG_MODULE(RegAlloc));
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thighInfinite = "));
highInfinite.printPretty(UT_LOG_MODULE(RegAlloc));
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tpreColored = "));
preColored.printPretty(UT_LOG_MODULE(RegAlloc));
#endif // DEBUG_LOG
RegisterName* coloringStackPtr = coloringStack;
while (low.getSize() != 0 || high.getSize() != 0) {
while (low.getSize() != 0) {
RegisterName range = RegisterName(low.getOne());
low.clear(range);
*coloringStackPtr++ = range;
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
for (Int32 i = (vector->count - 1); i >= 0; --i) {
RegisterName neighbor = vector->neighbors[i];
degree[neighbor]--;
if (degree[neighbor] < 6) // FIX
if (high.test(neighbor)) {
high.clear(neighbor);
low.set(neighbor);
} else if (highInfinite.test(neighbor)) {
highInfinite.clear(neighbor);
low.set(neighbor);
}
}
}
if (high.getSize() != 0) {
RegisterName best = RegisterName(high.getOne());
double bestCost = spillCost[best].cost;
double bestDegree = degree[best];
// Choose the next best candidate.
//
for (SparseSet::iterator i = high.begin(); !high.done(i); i = high.advance(i)) {
RegisterName range = RegisterName(high.get(i));
double thisCost = spillCost[range].cost;
double thisDegree = degree[range];
if (thisCost * bestDegree < bestCost * thisDegree) {
best = range;
bestCost = thisCost;
bestDegree = thisDegree;
}
}
high.clear(best);
low.set(best);
}
}
assert(highInfinite.getSize() == 0);
delete degree;
#ifdef DEBUG_LOG
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring stack:\n\t"));
for (RegisterName* sp = coloringStack; sp < coloringStackPtr; ++sp)
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("%d ", *sp));
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\n"));
#endif // DEBUG_LOG
return coloringStackPtr;
}
template <class RegisterPressure>
bool Coloring<RegisterPressure>::color(RegisterAllocator& registerAllocator)
{
RegisterName* coloringStack = new RegisterName[registerAllocator.rangeCount];
return select(registerAllocator, coloringStack, simplify(registerAllocator, coloringStack));
}

View File

@@ -0,0 +1,212 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include <string.h>
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "DominatorGraph.h"
DominatorGraph::DominatorGraph(ControlGraph& controlGraph) : controlGraph(controlGraph)
{
Uint32 nNodes = controlGraph.nNodes;
GtoV = new Uint32[nNodes + 1];
VtoG = new Uint32[nNodes + 1];
Uint32 v = 1;
for (Uint32 n = 0; n < nNodes; n++) {
VtoG[v] = n;
GtoV[n] = v++;
}
// Initialize all the 1-based arrays.
//
parent = new Uint32[v];
semi = new Uint32[v];
vertex = new Uint32[v];
label = new Uint32[v];
size = new Uint32[v];
ancestor = new Uint32[v];
child = new Uint32[v];
dom = new Uint32[v];
bucket = new DGLinkedList*[v];
memset(semi, '\0', v * sizeof(Uint32));
memset(bucket, '\0', v * sizeof(DGLinkedList*));
vCount = v;
build();
delete parent;
delete semi;
delete vertex;
delete label;
delete size;
delete ancestor;
delete child;
delete dom;
delete bucket;
}
Uint32 DominatorGraph::DFS(Uint32 vx, Uint32 n)
{
semi[vx] = ++n;
vertex[n] = label[vx] = vx;
ancestor[vx] = child[vx] = 0;
size[vx] = 1;
ControlNode& node = *controlGraph.dfsList[VtoG[vx]];
ControlEdge* successorEnd = node.getSuccessorsEnd();
for (ControlEdge* successorPtr = node.getSuccessorsBegin(); successorPtr < successorEnd; successorPtr++) {
Uint32 w = GtoV[successorPtr->getTarget().dfsNum];
if (semi[w] == 0) {
parent[w] = vx;
n = DFS(w, n);
}
}
return n;
}
void DominatorGraph::LINK(Uint32 vx, Uint32 w)
{
Uint32 s = w;
while (semi[label[w]] < semi[label[child[s]]]) {
if (size[s] + size[child[child[s]]] >= (size[child[s]] << 1)) {
ancestor[child[s]] = s;
child[s] = child[child[s]];
} else {
size[child[s]] = size[s];
s = ancestor[s] = child[s];
}
}
label[s] = label[w];
size[vx] += size[w];
if(size[vx] < (size[w] << 1)) {
Uint32 t = s;
s = child[vx];
child[vx] = t;
}
while( s != 0 ) {
ancestor[s] = vx;
s = child[s];
}
}
void DominatorGraph::COMPRESS(Uint32 vx)
{
if(ancestor[ancestor[vx]] != 0) {
COMPRESS(ancestor[vx]);
if(semi[label[ancestor[vx]]] < semi[label[vx]])
label[vx] = label[ancestor[vx]];
ancestor[vx] = ancestor[ancestor[vx]];
}
}
Uint32 DominatorGraph::EVAL(Uint32 vx)
{
if(ancestor[vx] == 0)
return label[vx];
COMPRESS(vx);
return (semi[label[ancestor[vx]]] >= semi[label[vx]]) ? label[vx] : label[ancestor[vx]];
}
void DominatorGraph::build()
{
Uint32 n = DFS(GtoV[0], 0);
size[0] = label[0] = semi[0];
for (Uint32 i = n; i >= 2; i--) {
Uint32 w = vertex[i];
ControlNode& node = *controlGraph.dfsList[VtoG[w]];
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p)) {
Uint32 vx = GtoV[predecessors.get(p).getSource().dfsNum];
Uint32 u = EVAL(vx);
if(semi[u] < semi[w])
semi[w] = semi[u];
}
DGLinkedList* elem = new DGLinkedList();
elem->next = bucket[vertex[semi[w]]];
elem->index = w;
bucket[vertex[semi[w]]] = elem;
LINK(parent[w], w);
elem = bucket[parent[w]];
while(elem != NULL) {
Uint32 vx = elem->index;
Uint32 u = EVAL(vx);
dom[vx] = (semi[u] < semi[vx]) ? u : parent[w];
elem = elem->next;
}
}
memset(size, '\0', n * sizeof(Uint32));
Pool& pool = controlGraph.pool;
nodes = new(pool) DGNode[n];
for(Uint32 j = 2; j <= n; j++) {
Uint32 w = vertex[j];
Uint32 d = dom[w];
if(d != vertex[semi[w]]) {
d = dom[d];
dom[w] = d;
}
size[d]++;
}
dom[GtoV[0]] = 0;
for (Uint32 k = 1; k <= n; k++) {
DGNode& node = nodes[VtoG[k]];
Uint32 count = size[k];
node.successorsEnd = node.successorsBegin = (count) ? new(pool) Uint32[count] : (Uint32*) 0;
}
for (Uint32 l = 2; l <= n; l++)
*(nodes[VtoG[dom[l]]].successorsEnd)++ = VtoG[l];
}
#ifdef DEBUG_LOG
void DominatorGraph::printPretty(LogModuleObject log)
{
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Dominator Graph:\n"));
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 i = 0; i < nNodes; i++) {
DGNode& node = nodes[i];
if (node.successorsBegin != node.successorsEnd) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tN%d dominates ", i));
for (Uint32* successorsPtr = node.successorsBegin; successorsPtr < node.successorsEnd; successorsPtr++)
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d ", *successorsPtr));
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
}
}
#endif // DEBUG_LOG

View File

@@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _DOMINATOR_GRAPH_H_
#define _DOMINATOR_GRAPH_H_
#include "LogModule.h"
class ControlGraph;
struct DGNode
{
Uint32* successorsBegin;
Uint32* successorsEnd;
};
struct DGLinkedList
{
DGLinkedList* next;
Uint32 index;
};
class DominatorGraph
{
private:
ControlGraph& controlGraph;
Uint32 vCount;
Uint32* VtoG;
Uint32* GtoV;
Uint32* parent;
Uint32* semi;
Uint32* vertex;
Uint32* label;
Uint32* size;
Uint32* ancestor;
Uint32* child;
Uint32* dom;
DGLinkedList** bucket;
DGNode* nodes;
private:
void build();
Uint32 DFS(Uint32 vx, Uint32 n);
void LINK(Uint32 vx, Uint32 w);
void COMPRESS(Uint32 vx);
Uint32 EVAL(Uint32 vx);
public:
DominatorGraph(ControlGraph& controlGraph);
Uint32* getSuccessorsBegin(Uint32 n) const {return nodes[n].successorsBegin;}
Uint32* getSuccessorsEnd(Uint32 n) const {return nodes[n].successorsEnd;}
#ifdef DEBUG_LOG
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
#endif // _DOMINATOR_GRAPH_H_

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -16,6 +16,5 @@
* Reserved.
*/
#include "MacPrefix.h"
#include "Fundamentals.h"
#include "HashSet.h"

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _HASH_SET_H_
#define _HASH_SET_H_
#include "Fundamentals.h"
#include "Pool.h"
#include <string.h>
struct HashSetElement
{
Uint32 index;
HashSetElement* next;
};
class HashSet
{
private:
static const hashSize = 64;
// Return the hash code for the given element index.
static Uint32 getHashCode(Uint32 index) {return index & (hashSize - 1);} // Could be better !
private:
Pool& allocationPool;
HashSetElement** bucket;
HashSetElement* free;
private:
// No copy constructor.
HashSet(const HashSet&);
// No copy operator.
void operator = (const HashSet&);
public:
// Create a new HashSet.
inline HashSet(Pool& pool, Uint32 universeSize);
// Clear the hashset.
void clear();
// Clear the element for the given index.
void clear(Uint32 index);
// Set the element for the given index.
void set(Uint32 index);
// Return true if the element at index is a member.
bool test(Uint32 index) const;
// Union with the given hashset.
inline void or(const HashSet& set);
// Intersection with the given hashset.
inline void and(const HashSet& set);
// Difference with the given hashset.
inline void difference(const HashSet& set);
// Logical operators.
HashSet& operator |= (const HashSet& set) {or(set); return *this;}
HashSet& operator &= (const HashSet& set) {and(set); return *this;}
HashSet& operator -= (const HashSet& set) {difference(set); return *this;}
// Iterator to conform with the set API.
typedef HashSetElement* iterator;
// Return the iterator for the first element of this set.
iterator begin() const;
// Return the next iterator.
iterator advance(iterator pos) const;
// Return true if the iterator is at the end of the set.
bool done(iterator pos) const {return pos == NULL;}
};
inline HashSet::HashSet(Pool& pool, Uint32 /*universeSize*/)
: allocationPool(pool), free(NULL)
{
bucket = new(pool) HashSetElement*[hashSize];
memset(bucket, '\0', sizeof(HashSetElement*));
}
#endif // _HASH_SET_H_

View File

@@ -0,0 +1,213 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _INDEXED_POOL_H_
#define _INDEXED_POOL_H_
#include "Fundamentals.h"
#include <string.h>
#include <stdlib.h>
//------------------------------------------------------------------------------
// IndexedPool<IndexedObjectSubclass> is an indexed pool of objects. The
// template parameter 'IndexedObjectSubclass' must be a subclass of the struct
// IndexedObject.
//
// When the indexed pool is ask to allocate and initialize a new object (using
// the operator new(anIndexedPool) it will zero the memory used to store the
// object and initialize the field 'index' of this object to its position in
// the pool.
//
// An object allocated by the indexed pool can be freed by calling the method
// IndexedPool::release(IndexedElement& objectIndex).
//
// example:
//
// IndexedPool<IndexedElement> elementPool;
//
// IndexedElement& element1 = *new(elementPool) IndexedElement();
// IndexedElement& element2 = *new(elementPool) IndexedElement();
//
// indexedPool.release(element1);
// IndexedElement& element3 = *new(elementPool) IndexedElement();
//
// At this point element1 is no longer a valid object, element2 is at
// index 2 and element3 is at index 1.
//
//------------------------------------------------------------------------------
// IndexedObject -
//
template<class Object>
struct IndexedObject
{
Uint32 index; // Index in the pool.
Object* next; // Used to link IndexedObject together.
Uint32 getIndex() {return index;}
};
//------------------------------------------------------------------------------
// IndexedPool<IndexedObject> -
//
template <class IndexedObject>
class IndexedPool
{
private:
static const blockSize = 4; // Size of one block.
Uint32 nBlocks; // Number of blocks in the pool.
IndexedObject** block; // Array of block pointers.
IndexedObject* freeObjects; // Chained list of free IndexedObjects.
Uint32 nextIndex; // Index of the next free object in the last block.
private:
void allocateAnotherBlock();
IndexedObject& newObject();
public:
IndexedPool() : nBlocks(0), block(NULL), freeObjects(NULL), nextIndex(1) {}
~IndexedPool();
IndexedObject& get(Uint32 index) const;
void release(IndexedObject& object);
void setSize(Uint32 size) {assert(size < nextIndex); nextIndex = size;}
// Return the universe size.
Uint32 getSize() {return nextIndex;}
friend void* operator new(size_t, IndexedPool<IndexedObject>& pool); // Needs to call newObject().
};
// Free all the memory allocated for this object.
//
template <class IndexedObject>
IndexedPool<IndexedObject>::~IndexedPool()
{
for (Uint32 n = 0; n < nBlocks; n++)
free(&((IndexedObject **) &block[n][n*blockSize])[-(n + 1)]);
}
// Release the given. This object will be iserted in the chained
// list of free IndexedObjects. To minimize the fragmentation the chained list
// is ordered by ascending indexes.
//
template <class IndexedObject>
void IndexedPool<IndexedObject>::release(IndexedObject& object)
{
Uint32 index = object.index;
IndexedObject* list = freeObjects;
assert(&object == &get(index)); // Make sure that object is owned by this pool.
if (list == NULL) { // The list is empty.
freeObjects = &object;
object.next = NULL;
} else { // The list contains at least 1 element.
if (index < list->index) { // insert as first element.
freeObjects = &object;
object.next = list;
} else { // Find this object's place.
while ((list->next) != NULL && (list->next->index < index))
list = list->next;
object.next = list->next;
list->next = &object;
}
}
#ifdef DEBUG
// Sanity check to be sure that the list is correctly ordered.
for (IndexedObject* obj = freeObjects; obj != NULL; obj = obj->next)
if (obj->next != NULL)
assert(obj->index < obj->next->index);
#endif
}
// Create a new block of IndexedObjects. We will allocate the memory to
// store IndexedPool::blockSize IndexedObject and the new Array of block
// pointers.
// The newly created IndexedObjects will not be initialized.
//
template <class IndexedObject>
void IndexedPool<IndexedObject>::allocateAnotherBlock()
{
void* memory = (void *) malloc((nBlocks + 1) * sizeof(Uint32) + blockSize * sizeof(IndexedObject));
memcpy(memory, block, nBlocks * sizeof(Uint32));
block = (IndexedObject **) memory;
IndexedObject* objects = (IndexedObject *) &block[nBlocks + 1];
block[nBlocks] = &objects[-(nBlocks * blockSize)];
nBlocks++;
}
// Return the IndexedObject at the position 'index' in the pool.
//
template <class IndexedObject>
IndexedObject& IndexedPool<IndexedObject>::get(Uint32 index) const
{
Uint32 blockIndex = index / blockSize;
assert(blockIndex < nBlocks);
return block[blockIndex][index];
}
// Return the reference of an unused object in the pool.
//
template <class IndexedObject>
IndexedObject& IndexedPool<IndexedObject>::newObject()
{
if (freeObjects != NULL) {
IndexedObject& newObject = *freeObjects;
freeObjects = newObject.next;
return newObject;
}
Uint32 nextIndex = this->nextIndex++;
Uint32 blockIndex = nextIndex / blockSize;
while (blockIndex >= nBlocks)
allocateAnotherBlock();
IndexedObject& newObject = block[blockIndex][nextIndex];
newObject.index = nextIndex;
return newObject;
}
// Return the address of the next unsused object in the given
// indexed pool. The field index of the newly allocated object
// will be initialized to the corresponding index of this object
// in the pool.
//
template <class IndexedObject>
void* operator new(size_t size, IndexedPool<IndexedObject>& pool)
{
assert(size == sizeof(IndexedObject));
return (void *) &pool.newObject();
}
#endif // _INDEXED_POOL_H_

View File

@@ -0,0 +1,258 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _INTERFERENCE_GRAPH_H_
#define _INTERFERENCE_GRAPH_H_
#include "Fundamentals.h"
#include "ControlGraph.h"
#include "Primitives.h"
#include "Instruction.h"
#include "VirtualRegister.h"
#include "RegisterPressure.h"
#include "SparseSet.h"
#include <string.h>
struct InterferenceVector
{
Uint32 count;
InterferenceVector* next;
RegisterName* neighbors;
InterferenceVector() : count(0), next(NULL) {}
};
class RegisterAllocator;
template <class RegisterPressure>
class InterferenceGraph
{
private:
RegisterAllocator& registerAllocator;
RegisterPressure::Set* interferences;
InterferenceVector** vector;
Uint32* offset;
Uint32 rangeCount;
private:
// No copy constructor.
InterferenceGraph(const InterferenceGraph&);
// No copy operator.
void operator = (const InterferenceGraph&);
// Check if reg is a member of the universe.
void checkMember(RegisterName name) {assert(name < rangeCount);}
// Return the edge index for the interference between name1 and name2.
Uint32 getEdgeIndex(RegisterName name1, RegisterName name2);
public:
InterferenceGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
// Calculate the interferences.
void build();
// Return true if reg1 and reg2 interfere.
bool interfere(RegisterName name1, RegisterName name2);
// Return the interference vector for the given register or NULL if there is none.
InterferenceVector* getInterferenceVector(RegisterName name) {return vector[name];}
// Set the interference between name1 and name2.
void setInterference(RegisterName name1, RegisterName name2);
// Set the interference vector for the given register.
void setInterferenceVector(RegisterName name, InterferenceVector* v) {vector[name] = v;}
#ifdef DEBUG_LOG
// Print the interferences.
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
template <class RegisterPressure>
void InterferenceGraph<RegisterPressure>::build()
{
Pool& pool = registerAllocator.pool;
Uint32 rangeCount = registerAllocator.rangeCount;
this->rangeCount = rangeCount;
// Initialize the structures.
//
offset = new(pool) Uint32[rangeCount + 1];
vector = new(pool) InterferenceVector*[rangeCount];
memset(vector, '\0', sizeof(InterferenceVector*) * rangeCount);
Uint32 o = 0;
offset[0] = 0;
for (Uint32 i = 1; i <= rangeCount; ++i) {
offset[i] = o;
o += i;
}
interferences = new(pool) RegisterPressure::Set(pool, (rangeCount * rangeCount) / 2);
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
RegisterName* name2range = registerAllocator.name2range;
LivenessInfo<RegisterPressure> liveness = Liveness<RegisterPressure>::analysis(controlGraph, rangeCount, name2range);
registerAllocator.liveness = liveness;
SparseSet currentLive(pool, rangeCount);
for (Uint32 n = 0; n < nNodes; n++) {
ControlNode& node = *nodes[n];
currentLive = liveness.liveOut[n];
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
InstructionDefine* definePtr;
// Handle the copy instruction to avoid unnecessary interference between the 2 registers.
if ((instruction.getFlags() & ifCopy) != 0) {
assert(useBegin != useEnd && useBegin[0].isRegister());
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
}
// Create the interferences.
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName define = name2range[definePtr->getRegisterName()];
for (SparseSet::iterator e = currentLive.begin(); !currentLive.done(e); e = currentLive.advance(e)) {
RegisterName live = RegisterName(currentLive.get(e));
if ((live != define) && !interfere(live, define) && registerAllocator.canInterfere(live, define)) {
if (vector[define] == NULL)
vector[define] = new(pool) InterferenceVector();
vector[define]->count++;
if (vector[live] == NULL)
vector[live] = new(pool) InterferenceVector();
vector[live]->count++;
setInterference(live, define);
}
}
}
// Now update the liveness.
//
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
currentLive.clear(name2range[definePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
currentLive.set(name2range[usePtr->getRegisterName()]);
}
}
// Allocate the memory to store the interferences.
//
for (Uint32 e = 0; e < rangeCount; e++)
if (vector[e] != NULL) {
InterferenceVector& v = *vector[e];
v.neighbors = new(pool) RegisterName[v.count];
v.count = 0;
}
// Initialize the edges.
//
if (RegisterPressure::Set::isOrdered()) {
RegisterName name1 = RegisterName(0);
for (RegisterPressure::Set::iterator i = interferences->begin(); !interferences->done(i); i = interferences->advance(i)) {
Uint32 interferenceIndex = interferences->get(i);
while(interferenceIndex >= offset[name1 + 1])
name1 = RegisterName(name1 + 1);
assert((interferenceIndex >= offset[name1]) && (interferenceIndex < offset[name1 + 1]));
RegisterName name2 = RegisterName(interferenceIndex - offset[name1]);
assert(interfere(name1, name2));
InterferenceVector& vector1 = *vector[name1];
vector1.neighbors[vector1.count++] = name2;
InterferenceVector& vector2 = *vector[name2];
vector2.neighbors[vector2.count++] = name1;
}
} else {
trespass("not Implemented"); // FIX: need one more pass to initialize the vectors.
}
}
template <class RegisterPressure>
Uint32 InterferenceGraph<RegisterPressure>::getEdgeIndex(RegisterName name1, RegisterName name2)
{
checkMember(name1); checkMember(name2);
assert(name1 != name2); // This is not possible.
return (name1 < name2) ? offset[name2] + name1 : offset[name1] + name2;
}
template <class RegisterPressure>
void InterferenceGraph<RegisterPressure>::setInterference(RegisterName name1, RegisterName name2)
{
interferences->set(getEdgeIndex(name1, name2));
}
template <class RegisterPressure>
bool InterferenceGraph<RegisterPressure>::interfere(RegisterName name1, RegisterName name2)
{
return interferences->test(getEdgeIndex(name1, name2));
}
#ifdef DEBUG_LOG
template <class RegisterPressure>
void InterferenceGraph<RegisterPressure>::printPretty(LogModuleObject log)
{
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Vectors:\n"));
for (Uint32 i = 1; i < rangeCount; i++) {
if (vector[i] != NULL) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tvr%d: (", i));
for (InterferenceVector* v = vector[i]; v != NULL; v = v->next)
for (Uint32 j = 0; j < v->count; j++) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", v->neighbors[j]));
if (v->next != NULL || j != (v->count - 1))
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (","));
}
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (")\n"));
}
}
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Matrix:\n"));
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && interfere(name1, name2)) ? '1' : '0'));
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
}
#endif // DEBUG_LOG
#endif // _INTERFERENCE_GRAPH_H_

View File

@@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _LIVE_RANGE_H_
#define _LIVE_RANGE_H_
#include "Fundamentals.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Primitives.h"
#include "Instruction.h"
#include "RegisterAllocator.h"
#include "RegisterAllocatorTools.h"
template <class RegisterPressure>
struct LiveRange
{
static void build(RegisterAllocator& registerAllocator);
};
template <class RegisterPressure>
void LiveRange<RegisterPressure>::build(RegisterAllocator& registerAllocator)
{
// Intialize the lookup table.
//
Uint32 nameCount = registerAllocator.nameCount;
RegisterName* nameTable = new(registerAllocator.pool) RegisterName[2*nameCount];
RegisterName* rangeName = &nameTable[nameCount];
init(rangeName, nameCount);
// Walk the graph.
//
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
SparseSet destination(registerAllocator.pool, nameCount);
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
destination.clear();
for (InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
Instruction& phiNode = phiNodes.get(i);
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
destination.set(findRoot(phiNode.getInstructionDefineBegin()[0].getRegisterName(), rangeName));
}
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& phiNode = phiNodes.get(p);
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
RegisterName destinationName = phiNode.getInstructionDefineBegin()[0].getRegisterName();
RegisterName destinationRoot = findRoot(destinationName, rangeName);
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
assert(usePtr->isRegister());
RegisterName sourceName = usePtr->getRegisterName();
RegisterName sourceRoot = findRoot(sourceName, rangeName);
if (sourceRoot != destinationRoot && !destination.test(sourceRoot))
rangeName[sourceRoot] = destinationRoot;
}
}
}
registerAllocator.rangeCount = compress(registerAllocator.name2range, rangeName, nameCount, nameCount);
}
#endif // _LIVE_RANGE_H_

View File

@@ -0,0 +1,163 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _LIVE_RANGE_GRAPH_
#define _LIVE_RANGE_GRAPH_
#include "Fundamentals.h"
#include "Pool.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "RegisterTypes.h"
class RegisterAllocator;
template <class RegisterPressure>
class LiveRangeGraph
{
private:
RegisterAllocator& registerAllocator;
RegisterPressure::Set* edges;
Uint32 rangeCount;
public:
//
//
LiveRangeGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
//
//
void build();
//
//
void addEdge(RegisterName name1, RegisterName name2);
//
//
bool haveEdge(RegisterName name1, RegisterName name2);
#ifdef DEBUG_LOG
//
//
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
template <class RegisterPressure>
void LiveRangeGraph<RegisterPressure>::build()
{
Pool& pool = registerAllocator.pool;
Uint32 rangeCount = registerAllocator.rangeCount;
this->rangeCount = rangeCount;
edges = new(pool) RegisterPressure::Set(pool, rangeCount * rangeCount);
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
RegisterName* name2range = registerAllocator.name2range;
LivenessInfo<RegisterPressure>& liveness = registerAllocator.liveness;
SparseSet currentLive(pool, rangeCount);
for (Uint32 n = 0; n < nNodes; n++) {
ControlNode& node = *nodes[n];
currentLive = liveness.liveOut[n];
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
InstructionDefine* definePtr;
if ((instruction.getFlags() & ifCopy) != 0) {
assert(useBegin != useEnd && useBegin[0].isRegister());
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName define = name2range[definePtr->getRegisterName()];
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
RegisterName live = RegisterName(currentLive.get(l));
if (define != live && registerAllocator.canInterfere(define, live))
addEdge(define, live);
}
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
currentLive.clear(name2range[definePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
currentLive.set(name2range[usePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName use = name2range[usePtr->getRegisterName()];
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
RegisterName live = RegisterName(currentLive.get(l));
if (use != live && registerAllocator.canInterfere(use, live))
addEdge(use, live);
}
}
}
}
}
template <class RegisterPressure>
void LiveRangeGraph<RegisterPressure>::addEdge(RegisterName name1, RegisterName name2)
{
assert(name1 != name2);
edges->set(name1 * rangeCount + name2);
}
template <class RegisterPressure>
bool LiveRangeGraph<RegisterPressure>::haveEdge(RegisterName name1, RegisterName name2)
{
assert(name1 != name2);
return edges->test(name1 * rangeCount + name2);
}
#ifdef DEBUG_LOG
template <class RegisterPressure>
void LiveRangeGraph<RegisterPressure>::printPretty(LogModuleObject log)
{
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Live ranges graph:\n"));
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && haveEdge(name1, name2)) ? '1' : '0'));
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
}
#endif // DEBUG_LOG
#endif // _LIVE_RANGE_GRAPH_

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -16,6 +16,6 @@
* Reserved.
*/
#include "Fundamentals.h"
#include "Liveness.h"
#include "MacPrefix_debug.h"

View File

@@ -0,0 +1,301 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _LIVENESS_H_
#define _LIVENESS_H_
#include "Fundamentals.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "RegisterTypes.h"
// ----------------------------------------------------------------------------
// LivenessInfo -
template <class RegisterPressure>
struct LivenessInfo
{
RegisterPressure::Set* liveIn;
RegisterPressure::Set* liveOut;
DEBUG_LOG_ONLY(Uint32 size);
#ifdef DEBUG_LOG
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
// ----------------------------------------------------------------------------
// Liveness
//
// The liveness is defined by the following data-flow equations:
//
// LiveIn(n) = LocalLive(n) U (LiveOut(n) - Killed(n)).
// LiveOut(n) = U LiveIn(s) (s a successor of n).
//
// where LocalLive(n) is the set of used registers in the block n, Killed(n)
// is the set of defined registers in the block n, LiveIn(n) is the set of
// live registers at the begining of the block n and LiveOut(n) is the set
// of live registers at the end of the block n.
//
//
// We will compute the liveness analysis in two stages:
//
// 1- Build LocalLive(n) (wich is an approximation of LiveIn(n)) and Killed(n)
// for each block n.
// 2- Perform a backward data-flow analysis to propagate the liveness information
// through the entire control-flow graph.
//
template <class RegisterPressure>
struct Liveness
{
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range);
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 nameCount);
};
template <class RegisterPressure>
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range)
{
Pool& pool = controlGraph.pool;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
// Allocate the temporary sets.
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
// Allocate the globals sets.
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
//
for (Uint32 n = 0; n < (nNodes - 1); n++) {
ControlNode& node = *nodes[n];
RegisterPressure::Set& currentLocalLive = liveIn[n];
RegisterPressure::Set& currentKilled = killed[n];
// Find the instructions contributions to the sets LocalLive and Killed.
//
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
Uint32 index = name2range[usePtr->getRegisterName()];
if (!currentKilled.test(index))
currentLocalLive.set(index);
}
// If a Virtualregister is 'defined' then we add it to the set Killed.
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
currentKilled.set(name2range[definePtr->getRegisterName()]);
}
}
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
// control-flow graph.
//
RegisterPressure::Set temp(pool, rangeCount);
bool changed;
do {
changed = false;
// For all nodes is this graph except the endNode.
for (Int32 n = (nNodes - 2); n >= 0; n--) {
ControlNode& node = *nodes[n];
RegisterPressure::Set& currentLiveIn = liveIn[n];
RegisterPressure::Set& currentLiveOut = liveOut[n];
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
// temp will be the new LiveOut(n).
Uint32 nSuccessors = node.nSuccessors();
if (nSuccessors != 0) {
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
for (Uint32 s = 1; s < nSuccessors; s++)
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
} else
temp.clear();
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
// new LiveIn(n).
if (currentLiveOut != temp) {
currentLiveOut = temp;
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
temp |= currentLiveIn;
if (currentLiveIn != temp) {
currentLiveIn = temp;
changed = true;
}
}
}
} while(changed);
LivenessInfo<RegisterPressure> liveness;
liveness.liveIn = liveIn;
liveness.liveOut = liveOut;
DEBUG_LOG_ONLY(liveness.size = nNodes);
return liveness;
}
template <class RegisterPressure>
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 nameCount)
{
Pool& pool = controlGraph.pool;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
// Allocate the temporary sets.
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
RegisterPressure::Set* usedByPhiNodes = NULL;
// Allocate the globals sets.
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
//
for (Uint32 n = 0; n < (nNodes - 1); n++) {
ControlNode& node = *nodes[n];
RegisterPressure::Set& currentLocalLive = liveIn[n];
RegisterPressure::Set& currentKilled = killed[n];
InstructionList& phiNodes = node.getPhiNodeInstructions();
if ((usedByPhiNodes == NULL) && !phiNodes.empty())
usedByPhiNodes = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& phiNode = phiNodes.get(p);
InstructionDefine& define = phiNode.getInstructionDefineBegin()[0];
currentKilled.set(define.getRegisterName());
typedef DoublyLinkedList<ControlEdge> ControlEdgeList;
const ControlEdgeList& predecessors = node.getPredecessors();
ControlEdgeList::iterator p = predecessors.begin();
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++, p = predecessors.advance(p))
if (usePtr->isRegister())
usedByPhiNodes[predecessors.get(p).getSource().dfsNum].set(usePtr->getRegisterName());
}
// Find the instructions contributions to the sets LocalLive and Killed.
//
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
Uint32 index = usePtr->getRegisterName();
if (!currentKilled.test(index))
currentLocalLive.set(index);
}
// If a Virtualregister is 'defined' then we add it to the set Killed.
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
currentKilled.set(definePtr->getRegisterName());
}
}
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
// control-flow graph.
//
RegisterPressure::Set temp(pool, nameCount);
bool changed;
do {
changed = false;
// For all nodes is this graph except the endNode.
for (Int32 n = (nNodes - 2); n >= 0; n--) {
ControlNode& node = *nodes[n];
RegisterPressure::Set& currentLiveIn = liveIn[n];
RegisterPressure::Set& currentLiveOut = liveOut[n];
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
// temp will be the new LiveOut(n).
Uint32 nSuccessors = node.nSuccessors();
if (nSuccessors != 0) {
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
for (Uint32 s = 1; s < nSuccessors; s++)
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
} else
temp.clear();
// Insert the phiNodes contribution.
if (usedByPhiNodes != NULL)
temp |= usedByPhiNodes[n];
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
// new LiveIn(n).
if (currentLiveOut != temp) {
currentLiveOut = temp;
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
temp |= currentLiveIn;
if (currentLiveIn != temp) {
currentLiveIn = temp;
changed = true;
}
}
}
} while(changed);
LivenessInfo<RegisterPressure> liveness;
liveness.liveIn = liveIn;
liveness.liveOut = liveOut;
DEBUG_LOG_ONLY(liveness.size = nNodes);
return liveness;
}
#ifdef DEBUG_LOG
template <class RegisterPressure>
void LivenessInfo<RegisterPressure>::printPretty(LogModuleObject log)
{
for (Uint32 n = 0; n < size; n++) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Node N%d:\n\tliveIn = ", n));
liveIn[n].printPretty(log);
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tliveOut = "));
liveOut[n].printPretty(log);
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
}
#endif // DEBUG_LOG
#endif // _LIVENESS_H_

View File

@@ -0,0 +1,40 @@
#! gmake
DEPTH = ../..
MODULE_NAME = RegisterAllocator
include $(DEPTH)/config/config.mk
INCLUDES += \
-I$(DEPTH)/Utilities/General \
-I$(DEPTH)/Utilities/zlib \
-I$(DEPTH)/Runtime/ClassReader \
-I$(DEPTH)/Runtime/NativeMethods \
-I$(DEPTH)/Runtime/System \
-I$(DEPTH)/Runtime/ClassInfo \
-I$(DEPTH)/Runtime/FileReader \
-I$(DEPTH)/Compiler/PrimitiveGraph \
-I$(DEPTH)/Compiler/FrontEnd \
-I$(DEPTH)/Compiler/Optimizer \
-I$(DEPTH)/Compiler/CodeGenerator \
-I$(DEPTH)/Compiler/CodeGenerator/md \
-I$(DEPTH)/Compiler/CodeGenerator/md/$(CPU_ARCH) \
-I$(DEPTH)/Compiler/RegisterAllocator \
-I$(DEPTH)/Driver/StandAloneJava \
-I$(DEPTH)/Debugger \
$(NULL)
CXXSRCS = \
RegisterAllocator.cpp \
RegisterAllocatorTools.cpp \
DominatorGraph.cpp \
VirtualRegister.cpp \
BitSet.cpp \
SparseSet.cpp \
$(NULL)
include $(DEPTH)/config/rules.mk
libs:: $(MODULE)

View File

@@ -0,0 +1,392 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _PHI_NODE_REMOVER_H_
#define _PHI_NODE_REMOVER_H_
#include "Fundamentals.h"
#include "Pool.h"
#include "ControlGraph.h"
#include "DominatorGraph.h"
#include "VirtualRegister.h"
#include "RegisterPressure.h"
#include "Liveness.h"
#include "Instruction.h"
#include "InstructionEmitter.h"
#include "SparseSet.h"
#include <string.h>
//------------------------------------------------------------------------------
// RegisterNameNode -
struct RegisterNameNode
{
RegisterNameNode* next;
RegisterName newName;
Uint32 nextPushed;
};
//------------------------------------------------------------------------------
// CopyData -
struct CopyData
{
RegisterName source;
RegisterClassKind classKind;
Uint32 useCount;
bool isLiveOut;
RegisterName sourceNameToUse;
RegisterName temporaryName;
RegisterNameNode* newName;
};
//------------------------------------------------------------------------------
// PhiNodeRemover<RegisterPressure> -
template <class RegisterPressure>
struct PhiNodeRemover
{
// Replace the phi nodes by copy instructions.
static void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
};
// Split some of the critical edges and return true if there are still some
// in the graph after that.
//
static bool splitCriticalEdges(ControlGraph& /*cg*/)
{
// FIX: not implemented.
return true;
}
inline void pushName(Pool& pool, RegisterNameNode** stack, SparseSet& pushed, Uint32* nodeListPointer, RegisterName oldName, RegisterName newName)
{
RegisterNameNode& newNode = *new(pool) RegisterNameNode();
if (pushed.test(oldName))
(*stack)->newName = newName;
else {
newNode.newName = newName;
newNode.nextPushed = *nodeListPointer;
*nodeListPointer = oldName;
newNode.next = *stack;
*stack = &newNode;
pushed.set(oldName);
}
}
template <class RegisterPressure>
void PhiNodeRemover<RegisterPressure>::replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
{
Pool& pool = controlGraph.pool;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
// Initialize the local variables.
//
// When we insert the copies we will also need to create new VirtualRegisters for
// the insertion of temporaries. The maximum number of temporary register will not
// exceed the number of phiNodes in the primitive graph.
Uint32 nameCount = vrManager.getSize();
Uint32 maxNameCount = nameCount;
for (Uint32 n = 0; n < nNodes; n++)
maxNameCount += nodes[n]->getPhiNodes().length();
// If the CFG contains some critical edges (backward edge which source has more than one
// outgoing edge and destination has more than one incomimg edge) then we need the liveness
// information to be able to insert temporary copies.
RegisterPressure::Set* liveOut = NULL;
if (splitCriticalEdges(controlGraph))
liveOut = Liveness<LowRegisterPressure>::analysis(controlGraph, nameCount).liveOut;
DominatorGraph dGraph(controlGraph);
SparseSet pushed(pool, maxNameCount);
SparseSet destinationList(pool, maxNameCount);
SparseSet workList(pool, maxNameCount);
CopyData* copyStats = new(pool) CopyData[maxNameCount];
memset(copyStats, '\0', maxNameCount*sizeof(CopyData));
struct NodeStack {
Uint32* next;
Uint32* limit;
Uint32 pushedList;
};
// Allocate the node stack and initialize the node stack pointer.
NodeStack* nodeStack = new(pool) NodeStack[nNodes + 1];
NodeStack* nodeStackPtr = nodeStack;
// We start by the begin node.
Uint32 startNode = 0;
Uint32* next = &startNode;
Uint32* limit = &startNode + 1;
while (true) {
if (next == limit) {
// If there are no more node in the sibling, we have to pop the current
// frame from the stack and update the copyStats of the pushed nodes.
//
if (nodeStackPtr == nodeStack)
// We are at the bottom of the stack and there are no more nodes
// to look at. We are done !
break;
--nodeStackPtr;
// We are done with all the children of this node in the dominator tree.
// We need to update the copy information of all the new names pushed
// during the walk over this node.
Uint32 pushedList = nodeStackPtr->pushedList;
while (pushedList != 0) {
Uint32 nextName = copyStats[pushedList].newName->nextPushed;
copyStats[pushedList].newName = copyStats[pushedList].newName->next;
pushedList = nextName;
}
// restore the previous frame.
next = nodeStackPtr->next;
limit = nodeStackPtr->limit;
} else {
Uint32 currentNode = *next++;
Uint32 pushedList = 0;
// Initialize the sets.
pushed.clear();
destinationList.clear();
// STEP1:
// Walk the instruction list and to replace all the instruction uses with their new name.
// If the instruction is a phi node and its defined register is alive at the end of this
// block then we push the defined register into the stack.
//
ControlNode& node = *nodes[currentNode];
RegisterPressure::Set* currentLiveOut = (liveOut != NULL) ? &liveOut[currentNode] : (RegisterPressure::Set*) 0;
InstructionList& phiNodes = node.getPhiNodeInstructions();
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& phiNode = phiNodes.get(p);
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
assert(usePtr->isRegister());
RegisterName name = usePtr->getRegisterName();
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
usePtr->setRegisterName(copyStats[name].newName->newName);
}
if (currentLiveOut != NULL) {
// This is a phi node and we have to push its defined name if it is live
// at the end of the node. We only need to do this if the CFG has critical edges.
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
RegisterName name = phiNode.getInstructionDefineBegin()[0].getRegisterName();
if (currentLiveOut->test(name))
pushName(pool, &(copyStats[name].newName), pushed, &pushedList, name, name);
}
}
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName name = usePtr->getRegisterName();
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
usePtr->setRegisterName(copyStats[name].newName->newName);
}
}
// STEP2:
// Look at this node's successors' phiNodes. We keep track of the number of time
// a VR will be used by another copy instruction and insert each definition into the
// destinationList. This is the only pass over this node's successors as we will
// get all the information we need in the CopyData structures.
//
ControlEdge* successorEdgeEnd = node.getSuccessorsEnd();
for (ControlEdge* successorEdgePtr = node.getSuccessorsBegin(); successorEdgePtr < successorEdgeEnd; successorEdgePtr++) {
Uint32 useIndex = successorEdgePtr->getIndex();
ControlNode& successor = successorEdgePtr->getTarget();
// Look at its phi nodes. The phi nodes are at the top of the instruction list. We exit
// as soon as we find an instruction which is not a phi node
InstructionList& phiNodes = successor.getPhiNodeInstructions();
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& phiNode = phiNodes.get(p);
assert((phiNode.getInstructionUseBegin() + useIndex) < phiNode.getInstructionUseEnd());
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd());
InstructionUse& source = phiNode.getInstructionUseBegin()[useIndex];
InstructionDefine& destination = phiNode.getInstructionDefineBegin()[0];
assert(source.isRegister() && destination.isRegister());
RegisterName sourceName = source.getRegisterName();
RegisterName destinationName = destination.getRegisterName();
// Get the correct name for the source.
if (copyStats[sourceName].newName != NULL)
sourceName = copyStats[sourceName].newName->newName;
// Update the CopyData structures.
if ((sourceName != rnInvalid) && (sourceName != destinationName)) {
copyStats[destinationName].source = sourceName;
copyStats[destinationName].classKind = destination.getRegisterClass();
copyStats[destinationName].isLiveOut = (currentLiveOut != NULL) ? currentLiveOut->test(destinationName) : false;
copyStats[destinationName].sourceNameToUse = destinationName;
copyStats[sourceName].sourceNameToUse = sourceName;
copyStats[sourceName].useCount++;
destinationList.set(destinationName);
}
}
}
// STEP3:
// Insert into the worklist only the destination registers that will be not used in
// another copy instruction in this block.
//
assert(workList.getSize() == 0);
for (SparseSet::iterator d = destinationList.begin(); !destinationList.done(d); d = destinationList.advance(d)) {
Uint32 dest = destinationList.get(d);
if (copyStats[dest].useCount == 0)
workList.set(dest);
}
// STEP4:
// Insert the copy instructions.
//
Uint32 destinationListSize = destinationList.getSize();
InstructionList::iterator endOfTheNode = instructions.end();
// Find the right place to insert the copy instructions.
if (destinationListSize != 0)
while (instructions.get(endOfTheNode).getFlags() & ifControl)
endOfTheNode = instructions.retreat(endOfTheNode);
while (destinationListSize != 0) {
while(workList.getSize()) {
RegisterName destinationName = RegisterName(workList.getOne());
RegisterName sourceName = copyStats[destinationName].source;
workList.clear(destinationName);
if (copyStats[destinationName].isLiveOut && !copyStats[destinationName].temporaryName) {
// Lost copy problem.
copyStats[destinationName].isLiveOut = false;
RegisterName sourceName = destinationName;
RegisterClassKind classKind = copyStats[sourceName].classKind;
RegisterName destinationName = getName(vrManager.newVirtualRegister(classKind));
assert(destinationName < maxNameCount);
copyStats[destinationName].classKind = classKind;
copyStats[sourceName].useCount = 0;
// We need to insert a copy to a temporary register to keep the
// source register valid at the end of the node defining it.
// This copy will be inserted right after the phi node defining it.
RegisterName from = copyStats[sourceName].sourceNameToUse;
Instruction* definingPhiNode = vrManager.getVirtualRegister(from).getDefiningInstruction();
assert(definingPhiNode && (definingPhiNode->getFlags() & ifPhiNode) != 0);
RegisterID fromID = buildRegisterID(from, classKind);
RegisterID toID = buildRegisterID(destinationName, classKind);
Instruction& copy = emitter.newCopy(*definingPhiNode->getPrimitive(), fromID, toID);
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
definingPhiNode->getPrimitive()->getContainer()->getInstructions().addFirst(copy);
copyStats[sourceName].temporaryName = destinationName;
copyStats[sourceName].sourceNameToUse = destinationName;
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
}
// Insert the copy instruction at the end of the current node.
RegisterName from = copyStats[sourceName].sourceNameToUse;
RegisterClassKind classKind = copyStats[destinationName].classKind;
RegisterID fromID = buildRegisterID(from, classKind);
RegisterID toID = buildRegisterID(destinationName, classKind);
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
instructions.insertAfter(copy, endOfTheNode);
endOfTheNode = instructions.advance(endOfTheNode);
copyStats[sourceName].useCount = 0;
if (destinationList.test(sourceName) && copyStats[sourceName].isLiveOut)
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
copyStats[sourceName].isLiveOut = false;
copyStats[sourceName].sourceNameToUse = destinationName;
if (destinationList.test(sourceName))
workList.set(sourceName);
destinationList.clear(destinationName);
}
destinationListSize = destinationList.getSize();
if (destinationListSize != 0) {
RegisterName sourceName = RegisterName(destinationList.getOne());
RegisterName destinationName;
if (!copyStats[sourceName].temporaryName) {
// Cycle problem.
RegisterClassKind classKind = copyStats[sourceName].classKind;
destinationName = getName(vrManager.newVirtualRegister(classKind));
assert(destinationName < maxNameCount);
copyStats[destinationName].classKind = classKind;
copyStats[sourceName].temporaryName = destinationName;
// Insert the copy instruction at the end of the current node.
RegisterName from = copyStats[sourceName].sourceNameToUse;
RegisterID fromID = buildRegisterID(from, classKind);
RegisterID toID = buildRegisterID(destinationName, classKind);
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
instructions.insertAfter(copy, endOfTheNode);
endOfTheNode = instructions.advance(endOfTheNode);
} else
destinationName = copyStats[sourceName].temporaryName;
copyStats[sourceName].useCount = 0;
copyStats[sourceName].isLiveOut = false;
copyStats[sourceName].sourceNameToUse = destinationName;
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
workList.set(sourceName);
}
}
nodeStackPtr->pushedList = pushedList;
nodeStackPtr->next = next;
nodeStackPtr->limit = limit;
++nodeStackPtr;
next = dGraph.getSuccessorsBegin(currentNode);
limit = dGraph.getSuccessorsEnd(currentNode);
}
}
}
#endif // _PHI_NODE_REMOVER_H_

View File

@@ -0,0 +1,155 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "LogModule.h"
#include "RegisterAllocator.h"
#include "RegisterPressure.h"
#include "RegisterAllocatorTools.h"
#include "PhiNodeRemover.h"
#include "LiveRange.h"
#include "Liveness.h"
#include "InterferenceGraph.h"
#include "LiveRangeGraph.h"
#include "Coalescing.h"
#include "Spilling.h"
#include "Coloring.h"
#include "Splits.h"
class Pool;
class ControlGraph;
class VirtualRegisterManager;
class InstructionEmitter;
UT_DEFINE_LOG_MODULE(RegAlloc);
void RegisterAllocator::allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
{
// Insert the phi node instructions. We want to do this to have a single defined register per instruction.
// If we keep the PhiNode (as a DataNode) and a PhiNode is of DoubleWordKind then we have to execute
// some special code for the high word annotation.
//
RegisterAllocatorTools::insertPhiNodeInstructions(controlGraph, emitter);
// Perform some tests on the instruction graph.
//
DEBUG_ONLY(RegisterAllocatorTools::testTheInstructionGraph(controlGraph, vrManager));
// Replace the phi node instructions by their equivalent copy instructions.
//
PhiNodeRemover<LowRegisterPressure>::replacePhiNodes(controlGraph, vrManager, emitter);
// Do the register allocation.
//
RegisterAllocator registerAllocator(pool, controlGraph, vrManager, emitter);
registerAllocator.doGraphColoring();
}
void RegisterAllocator::doGraphColoring()
{
// Initialize the liverange map.
//
initLiveRanges();
// Build the live ranges. We do this to compress the number of RegisterNames
// used in the insterference graph.
//
LiveRange<LowRegisterPressure>::build(*this);
// Remove unnecessary copies.
//
RegisterAllocatorTools::removeUnnecessaryCopies(*this);
for (Uint8 loop = 0; loop < 10; loop++) {
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********* RegisterAllocator loop %d *********\n", loop));
while(true) {
// Build the interference graph.
//
iGraph.build();
// Coalesce the copy instructions.
//
if (!Coalescing<LowRegisterPressure>::coalesce(*this))
break;
}
// Print the interference graph.
//
DEBUG_LOG_ONLY(iGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
// Calculate the spill costs.
//
Spilling<LowRegisterPressure>::calculateSpillCosts(*this);
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSpillCosts(*this));
// Calculate the split costs.
//
Splits<LowRegisterPressure>::calculateSplitCosts(*this);
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSplitCosts(*this));
// Build the live range graph.
//
lGraph.build();
DEBUG_LOG_ONLY(lGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
// Color the graph. If it succeeds then we're done with the
// register allocation.
//
if (Coloring<LowRegisterPressure>::color(*this)) {
// Write the final colors in the instruction graph.
//
Coloring<LowRegisterPressure>::finalColoring(*this);
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********** RegisterAllocator done **********\n"));
DEBUG_LOG_ONLY(RegisterAllocatorTools::printInstructions(*this));
return;
}
// We need to spill some registers.
//
Spilling<LowRegisterPressure>::insertSpillCode(*this);
// Insert the split instructions.
//
Splits<LowRegisterPressure>::insertSplitCode(*this);
// Update the live ranges.
//
// FIX
}
#ifdef DEBUG_LOG
RegisterAllocatorTools::updateInstructionGraph(*this);
RegisterAllocatorTools::printInstructions(*this);
#endif
fprintf(stderr, "!!! Coloring failed after 10 loops !!!\n");
abort();
}
void RegisterAllocator::initLiveRanges()
{
Uint32 count = this->nameCount;
RegisterName* name2range = new(pool) RegisterName[nameCount];
for (RegisterName r = RegisterName(1); r < count; r = RegisterName(r + 1))
name2range[r] = r;
this->name2range = name2range;
rangeCount = count;
}

View File

@@ -0,0 +1,88 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _REGISTER_ALLOCATOR_H_
#define _REGISTER_ALLOCATOR_H_
class Pool;
class ControlGraph;
class InstructionEmitter;
struct SpillCost;
struct SplitCost;
#include "Liveness.h"
#include "VirtualRegister.h"
#include "RegisterPressure.h" // This should included by Backend.cpp
#include "InterferenceGraph.h"
#include "LiveRangeGraph.h"
//template <class RegisterPressure>
class RegisterAllocator
{
public:
Pool& pool; //
ControlGraph& controlGraph; //
VirtualRegisterManager& vrManager; //
InstructionEmitter& emitter; //
RegisterName* name2range; //
RegisterName* color; //
SpillCost* spillCost; //
SparseSet* willSpill; //
SplitCost* splitCost; //
NameLinkedList** splitAround; //
InterferenceGraph<LowRegisterPressure> iGraph; //
LiveRangeGraph<LowRegisterPressure> lGraph; //
LivenessInfo<LowRegisterPressure> liveness; //
Uint32 nameCount; //
Uint32 rangeCount; //
bool splitFound; //
private:
//
//
void doGraphColoring();
public:
//
//
inline RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
//
//
bool canInterfere(RegisterName /*name1*/, RegisterName /*name2*/) const {return true;}
//
//
void initLiveRanges();
//
//
static void allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
};
//
//
inline RegisterAllocator::RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
: pool(pool), controlGraph(controlGraph), vrManager(vrManager), emitter(emitter), iGraph(*this), lGraph(*this), nameCount(vrManager.getSize()) {}
#endif // _REGISTER_ALLOCATOR_H_

View File

@@ -0,0 +1,355 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "LogModule.h"
#include "RegisterAllocatorTools.h"
#include "Pool.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Primitives.h"
#include "InstructionEmitter.h"
#include "Instruction.h"
#include "RegisterAllocator.h"
#include "Spilling.h"
#include "Splits.h"
#include "BitSet.h"
UT_EXTERN_LOG_MODULE(RegAlloc);
#ifdef DEBUG
void RegisterAllocatorTools::testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
{
// Test the declared VirtualRegisters. The register allocator tries to condense the register universe.
// Any gap in the VirtualRegister names will be a loss of efficiency !!!!
Uint32 nameCount = vrManager.getSize();
BitSet registerSeen(controlGraph.pool, nameCount);
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
registerSeen.set(usePtr->getRegisterName());
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
registerSeen.set(definePtr->getRegisterName());
}
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& instruction = phiNodes.get(p);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
registerSeen.set(usePtr->getRegisterName());
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
registerSeen.set(definePtr->getRegisterName());
}
}
bool renameRegisters = false;
for (BitSet::iterator i = registerSeen.nextZero(0); !registerSeen.done(i); i = registerSeen.nextZero(i)) {
renameRegisters = true;
fprintf(stderr,
"WARNING: The VirtualRegister vr%d has been allocated during CodeGeneration but\n"
" is never used nor defined by any instruction in the instruction graph\n"
" PLEASE FIX \n",
i);
}
if (renameRegisters) {
Instruction** definingInstruction = new Instruction*[nameCount];
memset(definingInstruction, '\0', nameCount * sizeof(Instruction*));
RegisterName* newName = new RegisterName[nameCount];
memset(newName, '\0', nameCount * sizeof(RegisterName));
RegisterName nextName = RegisterName(1);
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName name = usePtr->getRegisterName();
if (newName[name] == rnInvalid) {
newName[name] = nextName;
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
nextName = RegisterName(nextName + 1);
}
usePtr->setRegisterName(newName[name]);
}
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName name = definePtr->getRegisterName();
if (newName[name] == rnInvalid) {
newName[name] = nextName;
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
nextName = RegisterName(nextName + 1);
}
definePtr->setRegisterName(newName[name]);
}
}
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& instruction = phiNodes.get(p);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName name = usePtr->getRegisterName();
if (newName[name] == rnInvalid) {
newName[name] = nextName;
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
nextName = RegisterName(nextName + 1);
}
usePtr->setRegisterName(newName[name]);
}
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName name = definePtr->getRegisterName();
if (newName[name] == rnInvalid) {
newName[name] = nextName;
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
nextName = RegisterName(nextName + 1);
}
definePtr->setRegisterName(newName[name]);
}
}
}
vrManager.setSize(nextName);
for (RegisterName r = RegisterName(1); r < nextName; r = RegisterName(r + 1))
vrManager.getVirtualRegister(r).definingInstruction = definingInstruction[r];
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("RegisterMap:\n"));
for (Uint32 i = 1; i < nameCount; i++)
if (newName[i] != 0)
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d becomes vr%d.\n", i, newName[i]));
else
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d is dead.\n", i));
delete newName;
delete definingInstruction;
}
}
#endif // DEBUG
void RegisterAllocatorTools::removeUnnecessaryCopies(RegisterAllocator& registerAllocator)
{
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
RegisterName* name2range = registerAllocator.name2range;
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i);) {
Instruction& instruction = instructions.get(i);
i = instructions.advance(i);
if (instruction.getFlags() & ifCopy) {
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
RegisterName source = name2range[instruction.getInstructionUseBegin()[0].getRegisterName()];
RegisterName destination = name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()];
if (source == destination)
instruction.remove();
}
}
}
}
void RegisterAllocatorTools::updateInstructionGraph(RegisterAllocator& registerAllocator)
{
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
RegisterName* name2range = registerAllocator.name2range;
for (Uint32 n = 0; n < nNodes; n++) {
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
}
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
Instruction& instruction = phiNodes.get(p);
InstructionUse* useEnd = instruction.getInstructionUseEnd();
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
}
}
}
void RegisterAllocatorTools::insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter)
{
Pool& pool = controlGraph.pool;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
ControlNode& node = *nodes[n];
DoublyLinkedList<PhiNode>& phiNodes = node.getPhiNodes();
if (!phiNodes.empty()) {
// Set the index of the incoming edges.
Uint32 index = 0;
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p))
predecessors.get(p).setIndex(index++);
// Insert the phi node instruction in the instruction list.
for (DoublyLinkedList<PhiNode>::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
PhiNode& phiNode = phiNodes.get(i);
ValueKind kind = phiNode.getKind();
if (!isStorableKind(kind))
continue;
RegisterClassKind classKind = rckGeneral; // FIX: get class kind from phi node kind.
Uint32 nInputs = phiNode.nInputs();
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drLow);
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drLow);
node.addPhiNodeInstruction(phiNodeInstruction);
if (isDoublewordKind(kind)) {
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drHigh);
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drHigh);
node.addPhiNodeInstruction(phiNodeInstruction);
}
}
}
}
}
#ifdef DEBUG_LOG
void RegisterAllocatorTools::printSpillCosts(RegisterAllocator& registerAllocator)
{
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
Uint32 rangeCount = registerAllocator.rangeCount;
SpillCost* cost = registerAllocator.spillCost;
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Spill costs:\n"));
for (Uint32 i = 1; i < rangeCount; i++) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : ", i));
if (cost[i].infinite)
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("infinite\n"));
else
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%f\n", cost[i].cost));
}
}
void RegisterAllocatorTools::printSplitCosts(RegisterAllocator& registerAllocator)
{
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
Uint32 rangeCount = registerAllocator.rangeCount;
SplitCost* cost = registerAllocator.splitCost;
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Split costs:\n"));
for (Uint32 i = 1; i < rangeCount; i++) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : loads = %f stores = %f\n", i, cost[i].loads, cost[i].stores));
}
}
void RegisterAllocatorTools::printInstructions(RegisterAllocator& registerAllocator)
{
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
ControlNode** nodes = registerAllocator.controlGraph.dfsList;
Uint32 nNodes = registerAllocator.controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d:\n", n));
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
InstructionList& instructions = nodes[n]->getInstructions();
if (!phiNodes.empty()) {
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" PhiNodes:\n", n));
for(InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
phiNodes.get(i).printPretty(log);
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
if (!instructions.empty())
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" Instructions:\n", n));
}
for(InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
instructions.get(i).printPretty(log);
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
}
}
}
#endif // DEBUG_LOG

View File

@@ -0,0 +1,117 @@
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
//
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
// NETSCAPE COMMUNICATIONS CORPORATION
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
// Reserved. Use of this Source Code is subject to the terms of the
// applicable license agreement from Netscape Communications Corporation.
// The copyright notice(s) in this Source Code does not indicate actual or
// intended publication of this Source Code.
//
// $Id: RegisterAllocatorTools.h,v 1.1.2.1 1999-03-02 16:12:05 fur%netscape.com Exp $
//
#ifndef _REGISTER_ALLOCATOR_TOOLS_H_
#define _REGISTER_ALLOCATOR_TOOLS_H_
#include "LogModule.h"
#include "RegisterTypes.h"
#include <string.h>
class RegisterAllocator;
class ControlGraph;
class InstructionEmitter;
class VirtualRegisterManager;
struct RegisterAllocatorTools
{
//
//
static void insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter);
//
//
static void updateInstructionGraph(RegisterAllocator& registerAllocator);
//
//
static void removeUnnecessaryCopies(RegisterAllocator& registerAllocator);
#ifdef DEBUG
//
//
static void testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
#endif // DEBUG
#ifdef DEBUG_LOG
//
//
static void printInstructions(RegisterAllocator& registerAllocator);
//
//
static void printSpillCosts(RegisterAllocator& registerAllocator);
//
//
static void printSplitCosts(RegisterAllocator& registerAllocator);
#endif // DEBUG_LOG
};
//
// FIX: this should go in a class (LookupTable ?)
//
inline RegisterName findRoot(RegisterName name, RegisterName* table)
{
RegisterName* stack = table;
RegisterName* stackPtr = stack;
RegisterName newName;
while((newName = table[name]) != name) {
*--stackPtr = name;
name = newName;
}
while (stackPtr != stack)
table[*stackPtr++] = name;
return name;
}
inline void init(RegisterName* table, Uint32 nameCount)
{
for (RegisterName r = RegisterName(0); r < nameCount; r = RegisterName(r + 1))
table[r] = r;
}
inline Uint32 compress(RegisterName* name2range, RegisterName* table, Uint32 nameCount, Uint32 tableSize)
{
RegisterName* liveRange = new RegisterName[tableSize];
memset(liveRange, '\0', tableSize * sizeof(RegisterName));
// Update the lookup table.
for (RegisterName r = RegisterName(1); r < tableSize; r = RegisterName(r + 1))
findRoot(r, table);
// Count the liveranges.
Uint32 liveRangeCount = 1;
for (RegisterName s = RegisterName(1); s < tableSize; s = RegisterName(s + 1))
if (table[s] == s)
liveRange[s] = RegisterName(liveRangeCount++);
for (RegisterName t = RegisterName(1); t < nameCount; t = RegisterName(t + 1))
name2range[t] = liveRange[table[name2range[t]]];
return liveRangeCount;
}
inline double doLog10(Uint32 power)
{
double log = 1.0;
while (power--)
log *= 10.0;
return log;
}
#endif // _REGISTER_ALLOCATOR_TOOLS_H_

View File

@@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _REGISTER_ASSIGNER_H_
#define _REGISTER_ASSIGNER_H_
#include "Fundamentals.h"
#include "VirtualRegister.h"
class FastBitMatrix;
class RegisterAssigner
{
protected:
VirtualRegisterManager& vRegManager;
public:
RegisterAssigner(VirtualRegisterManager& vrMan) : vRegManager(vrMan) {}
virtual bool assignRegisters(FastBitMatrix& interferenceMatrix) = 0;
};
#endif /* _REGISTER_ASSIGNER_H_ */

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -16,6 +16,10 @@
* Reserved.
*/
#ifndef _REGISTER_CLASS_H_
#define _REGISTER_CLASS_H_
#include "Fundamentals.h"
#include "RegisterTypes.h"
#include "MacPrefix_debug.h"
#endif // _REGISTER_CLASS_H_

View File

@@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _REGISTER_PRESSURE_H_
#define _REGISTER_PRESSURE_H_
#include "BitSet.h"
#include "HashSet.h"
struct LowRegisterPressure
{
typedef BitSet Set;
static const bool setIsOrdered = true;
};
struct HighRegisterPressure
{
typedef HashSet Set;
static const bool setIsOrdered = false;
};
#endif // _REGISTER_PRESSURE_H_

View File

@@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _REGISTER_TYPES_H_
#define _REGISTER_TYPES_H_
#include "Fundamentals.h"
//------------------------------------------------------------------------------
// RegisterName -
//
enum RegisterName {
rnInvalid = 0,
};
//------------------------------------------------------------------------------
// RegisterClassKind -
//
enum RegisterClassKind {
rckInvalid = 0,
rckGeneral,
rckStackSlot,
nRegisterClassKind
};
//------------------------------------------------------------------------------
// RegisterID -
//
enum RegisterID {
invalidID = 0
};
//------------------------------------------------------------------------------
// RegisterKind -
//
enum RegisterKind {
rkCallerSave = 0,
rkCalleeSave,
};
struct NameLinkedList {
RegisterName name;
NameLinkedList* next;
};
#ifdef DEBUG
const registerNameMask = 0x03ffffff;
const coloredRegisterMask = 0x04000000;
const machineRegisterMask = 0x08000000;
const registerClassMask = 0xf0000000;
const registerNameShift = 0;
const coloredRegisterShift = 26;
const machineRegisterShift = 27;
const registerClassShift = 28;
#else // DEBUG
const registerNameMask = 0x0fffffff;
const registerClassMask = 0xf0000000;
const registerNameShift = 0;
const registerClassShift = 28;
#endif // DEBUG
inline RegisterClassKind getClass(RegisterID registerID) {return RegisterClassKind((registerID & registerClassMask) >> registerClassShift);}
inline RegisterName getName(RegisterID registerID) {return RegisterName((registerID & registerNameMask) >> registerNameShift);}
inline void setClass(RegisterID& registerID, RegisterClassKind classKind) {registerID = RegisterID((registerID & ~registerClassMask) | ((classKind << registerClassShift) & registerClassMask));}
inline void setName(RegisterID& registerID, RegisterName name) {assert((name & ~registerNameMask) == 0); registerID = RegisterID((registerID & ~registerNameMask) | ((name << registerNameShift) & registerNameMask));}
inline RegisterID buildRegisterID(RegisterName name, RegisterClassKind classKind) {return RegisterID(((classKind << registerClassShift) & registerClassMask) | ((name << registerNameShift) & registerNameMask));}
#ifdef DEBUG
inline bool isMachineRegister(RegisterID rid) {return (rid & machineRegisterMask) != 0;}
inline void setMachineRegister(RegisterID& rid) {rid = RegisterID(rid | machineRegisterMask);}
inline bool isColoredRegister(RegisterID rid) {return (rid & coloredRegisterMask) != 0;}
inline void setColoredRegister(RegisterID& rid) {rid = RegisterID(rid | coloredRegisterMask);}
#endif // DEBUG
#endif // _REGISTER_TYPES_H_

View File

@@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "SSATools.h"
#include "ControlGraph.h"
#include "VirtualRegister.h"
#include "Liveness.h"
void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
{
if (!controlGraph.hasBackEdges)
return;
Liveness liveness(controlGraph.pool);
liveness.buildLivenessAnalysis(controlGraph, vrManager);
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -16,6 +16,14 @@
* Reserved.
*/
#ifndef _SSA_TOOLS_H_
#define _SSA_TOOLS_H_
#include "Fundamentals.h"
#include "MacPrefix.h"
class ControlGraph;
class VirtualRegisterManager;
extern void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
#endif // _SSA_TOOLS_H_

View File

@@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "SparseSet.h"
#include "BitSet.h"
#include "Pool.h"
#ifdef DEBUG_LOG
// Print the set.
//
void SparseSet::printPretty(LogModuleObject log)
{
Pool pool;
BitSet set(pool, universeSize);
for (Uint32 i = 0; i < count; i++)
set.set(node[i].element);
set.printPretty(log);
}
#endif // DEBUG_LOG

View File

@@ -0,0 +1,168 @@
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
//
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
// NETSCAPE COMMUNICATIONS CORPORATION
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
// Reserved. Use of this Source Code is subject to the terms of the
// applicable license agreement from Netscape Communications Corporation.
// The copyright notice(s) in this Source Code does not indicate actual or
// intended publication of this Source Code.
//
// $Id: SparseSet.h,v 1.1.2.1 1999-03-02 16:12:07 fur%netscape.com Exp $
//
#ifndef _SPARSE_SET_H_
#define _SPARSE_SET_H_
#include "Fundamentals.h"
#include "Pool.h"
#include "LogModule.h"
#include "BitSet.h"
class SparseSet
{
private:
struct Node {
Uint32 element;
Uint32 stackIndex;
};
Node* node;
Uint32 count;
Uint32 universeSize;
private:
// No copy constructor.
SparseSet(const SparseSet&);
// Check if the given set's universe is of the same size than this universe.
void checkUniverseCompatibility(const SparseSet& set) const {assert(set.universeSize == universeSize);}
// Check if pos is valid for this set's universe.
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
public:
SparseSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {node = new(pool) Node[universeSize]; clear();}
// Clear the sparse set.
void clear() {count = 0;}
// Clear the element at index.
inline void clear(Uint32 index);
// Set the element at index.
inline void set(Uint32 index);
// Return true if the element at index is set.
inline bool test(Uint32 index) const;
// Union with the given sparse set.
inline void or(const SparseSet& set);
// Intersection with the given sparse set.
inline void and(const SparseSet& set);
// Difference with the given sparse set.
inline void difference(const SparseSet& set);
// Copy set.
inline SparseSet& operator = (const SparseSet& set);
inline SparseSet& operator = (const BitSet& set);
// Return true if the sparse sets are identical.
friend bool operator == (const SparseSet& set1, const SparseSet& set2);
// Return true if the sparse sets are different.
friend bool operator != (const SparseSet& set1, const SparseSet& set2);
// Logical operators.
SparseSet& operator |= (const SparseSet& set) {or(set); return *this;}
SparseSet& operator &= (const SparseSet& set) {and(set); return *this;}
SparseSet& operator -= (const SparseSet& set) {difference(set); return *this;}
// Iterator to conform with the set API.
typedef Int32 iterator;
// Return the iterator for the first element of this set.
iterator begin() const {return count - 1;}
// Return the next iterator.
iterator advance(iterator pos) const {return --pos;}
// Return true if the iterator is at the end of the set.
bool done(iterator pos) const {return pos < 0;}
// Return the element for the given iterator;
Uint32 get(iterator pos) const {return node[pos].element;}
// Return one element of this set.
Uint32 getOne() const {assert(count > 0); return node[0].element;}
// Return the size of this set.
Uint32 getSize() const {return count;}
#ifdef DEBUG_LOG
// Print the set.
void printPretty(LogModuleObject log);
#endif // DEBUG_LOG
};
inline void SparseSet::clear(Uint32 element)
{
checkMember(element);
Uint32 count = this->count;
Node* node = this->node;
Uint32 stackIndex = node[element].stackIndex;
if ((stackIndex < count) && (node[stackIndex].element == element)) {
Uint32 stackTop = node[count - 1].element;
node[stackIndex].element = stackTop;
node[stackTop].stackIndex = stackIndex;
this->count = count - 1;
}
}
inline void SparseSet::set(Uint32 element)
{
checkMember(element);
Uint32 count = this->count;
Node* node = this->node;
Uint32 stackIndex = node[element].stackIndex;
if ((stackIndex >= count) || (node[stackIndex].element != element)) {
node[count].element = element;
node[element].stackIndex = count;
this->count = count + 1;
}
}
inline bool SparseSet::test(Uint32 element) const
{
checkMember(element);
Node* node = this->node;
Uint32 stackIndex = node[element].stackIndex;
return ((stackIndex < count) && (node[stackIndex].element == element));
}
inline SparseSet& SparseSet::operator = (const SparseSet& set)
{
checkUniverseCompatibility(set);
Uint32 sourceCount = set.getSize();
Node* node = this->node;
memcpy(node, set.node, sourceCount * sizeof(Node));
for (Uint32 i = 0; i < sourceCount; i++) {
Uint32 element = node[i].element;
node[element].stackIndex = i;
}
count = sourceCount;
return *this;
}
inline SparseSet& SparseSet::operator = (const BitSet& set)
{
// FIX: there's room for optimization here.
assert(universeSize == set.getSize());
clear();
for (Int32 i = set.firstOne(); i != -1; i = set.nextOne(i))
this->set(i);
return *this;
}
#endif // _SPARSE_SET_H_

View File

@@ -0,0 +1,270 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef NEW_LAURENTM_CODE
#define INCLUDE_EMITTER
#include "CpuInfo.h"
#include "Fundamentals.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "InstructionEmitter.h"
#include "Spilling.h"
void Spilling::
insertSpillCode(ControlNode** dfsList, Uint32 nNodes)
{
PRUint32 nVirtualRegisters = vRegManager.count();
FastBitSet currentLive(vRegManager.pool, nVirtualRegisters);
FastBitSet usedInThisInstruction(vRegManager.pool, nVirtualRegisters);
RegisterFifo grNeedLoad(nVirtualRegisters);
RegisterFifo fpNeedLoad(nVirtualRegisters);
for (PRInt32 n = nNodes - 1; n >= 0; n--)
{
PR_ASSERT(grNeedLoad.empty() & fpNeedLoad.empty());
ControlNode& node = *dfsList[n];
currentLive = node.liveAtEnd;
PRUint32 nGeneralAlive = 0;
PRUint32 nFloatingPointAlive = 0;
// Get the number of registers alive at the end of this node.
for (PRInt32 j = currentLive.firstOne(); j != -1; j = currentLive.nextOne(j))
{
VirtualRegister& vReg = vRegManager.getVirtualRegister(j);
if (vReg.spillInfo.willSpill)
{
currentLive.clear(j);
}
else
{
switch (vReg.getClass())
{
case vrcInteger:
nGeneralAlive++;
break;
case vrcFloatingPoint:
case vrcFixedPoint:
nFloatingPointAlive++;
break;
default:
break;
}
}
}
// if(node.dfsNum == 8) printf("\n________Begin Node %d________\n", node.dfsNum);
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i))
{
Instruction& instruction = instructions.get(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defEnd = instruction.getInstructionDefineEnd();
InstructionDefine* defPtr;
// if(node.dfsNum == 8) { printf("\n");
// instruction.printPretty(stdout);
// printf("\n"); }
// Handle definitions
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
if (defPtr->isVirtualRegister())
{
VirtualRegister& vReg = defPtr->getVirtualRegister();
currentLive.clear(vReg.getRegisterIndex());
switch (vReg.getClass())
{
case vrcInteger:
nGeneralAlive--;
break;
case vrcFloatingPoint:
case vrcFixedPoint:
nFloatingPointAlive--;
break;
default:
break;
}
}
// Check for deaths
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isVirtualRegister())
{
VirtualRegister& vReg = usePtr->getVirtualRegister();
if (!currentLive.test(vReg.getRegisterIndex()))
// This is the last use of this register.
{
currentLive.set(vReg.getRegisterIndex());
switch (vReg.getClass())
{
case vrcInteger:
nGeneralAlive++;
while (/*(nGeneralAlive > NUMBER_OF_GREGISTERS) &&*/ !grNeedLoad.empty())
{
PRUint32 toLoad = grNeedLoad.get();
currentLive.clear(toLoad);
nGeneralAlive--;
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
nReg.releaseSelf();
}
break;
case vrcFloatingPoint:
case vrcFixedPoint:
nFloatingPointAlive++;
while (/*(nFloatingPointAlive > NUMBER_OF_FPREGISTERS) &&*/ !fpNeedLoad.empty())
{
PRUint32 toLoad = fpNeedLoad.get();
currentLive.clear(toLoad);
nFloatingPointAlive--;
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
nReg.releaseSelf();
}
break;
default:
break;
}
}
}
// Handle uses
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isVirtualRegister())
{
VirtualRegister& vReg = usePtr->getVirtualRegister();
PRUint32 registerIndex = vReg.getRegisterIndex();
if (vReg.spillInfo.willSpill) {
#if defined(GENERATE_FOR_X86)
if (!instruction.switchUseToSpill((usePtr - useBegin), *vReg.equivalentRegister[vrcStackSlot]))
#endif
{
switch (vReg.getClass())
{
case vrcInteger:
if (!grNeedLoad.test(registerIndex))
{
grNeedLoad.put(registerIndex);
VirtualRegister& alias = vRegManager.newVirtualRegister(vrcInteger);
if (vReg.isPreColored())
alias.preColorRegister(vReg.getPreColor());
/* if (vReg.hasSpecialInterference) {
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
alias.specialInterference = vReg.specialInterference;
alias.hasSpecialInterference = true;
} */
vReg.setAlias(alias);
vReg.retainSelf();
}
break;
case vrcFloatingPoint:
case vrcFixedPoint:
if (!fpNeedLoad.test(registerIndex))
{
fpNeedLoad.put(registerIndex);
VirtualRegister& alias = vRegManager.newVirtualRegister(vReg.getClass());
if (vReg.isPreColored())
alias.preColorRegister(vReg.getPreColor());
/*if (vReg.hasSpecialInterference) {
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
alias.specialInterference = vReg.specialInterference;
alias.hasSpecialInterference = true;
} */
vReg.setAlias(alias);
vReg.retainSelf();
}
break;
default:
break;
}
usePtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
usedInThisInstruction.set(registerIndex);
vReg.spillInfo.lastUsingInstruction = &instruction;
}
currentLive.clear(registerIndex);
} else { // will not spill
currentLive.set(registerIndex);
}
}
// Handle definitions
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
if (defPtr->isVirtualRegister())
{
VirtualRegister& vReg = defPtr->getVirtualRegister();
if (vReg.spillInfo.willSpill)
#if defined(GENERATE_FOR_X86)
if (!instruction.switchDefineToSpill((defPtr - defBegin), *vReg.equivalentRegister[vrcStackSlot]))
#endif
{
if (usedInThisInstruction.test(vReg.getRegisterIndex()))
// this virtualRegister was used in this instruction and is also defined. We need to move
// this virtual register to its alias first and then save it to memory.
{
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
vReg.getAlias(), *vReg.equivalentRegister[vrcStackSlot]);
defPtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
}
else
{
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
vReg, *vReg.equivalentRegister[vrcStackSlot]);
}
}
}
}
while (!grNeedLoad.empty())
{
PRUint32 nl = grNeedLoad.get();
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
nlReg.releaseSelf();
}
while (!fpNeedLoad.empty())
{
PRUint32 nl = fpNeedLoad.get();
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
nlReg.releaseSelf();
}
// if(node.dfsNum == 8) printf("\n________End Node %d________\n", node.dfsNum);
}
}
#endif

View File

@@ -0,0 +1,269 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _SPILLING_H_
#define _SPILLING_H_
#include "Fundamentals.h"
#include <string.h>
#include "RegisterAllocator.h"
#include "RegisterAllocatorTools.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "SparseSet.h"
template <class RegisterPressure>
class Spilling
{
private:
static void insertStoreAfter(Instruction& instruction, RegisterName name);
static void insertLoadBefore(Instruction& instruction, RegisterName name);
public:
static void calculateSpillCosts(RegisterAllocator& registerAllocator);
static void insertSpillCode(RegisterAllocator& registerAllocator);
};
struct SpillCost
{
double loads;
double stores;
double copies;
double cost;
bool infinite;
};
template <class RegisterPressure>
void Spilling<RegisterPressure>::insertSpillCode(RegisterAllocator& registerAllocator)
{
Uint32 rangeCount = registerAllocator.rangeCount;
RegisterName* name2range = registerAllocator.name2range;
Pool& pool = registerAllocator.pool;
SparseSet currentLive(pool, rangeCount);
SparseSet needLoad(pool, rangeCount);
SparseSet mustSpill(pool, rangeCount);
SparseSet& willSpill = *registerAllocator.willSpill;
ControlGraph& controlGraph = registerAllocator.controlGraph;
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
needLoad.clear();
currentLive = liveOut[n];
mustSpill = currentLive;
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i);) {
Instruction& instruction = instructions.get(i);
i = instructions.retreat(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
InstructionDefine* definePtr;
bool foundLiveDefine = false;
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
if (currentLive.test(name2range[definePtr->getRegisterName()])) {
foundLiveDefine = true;
break;
}
} else {
foundLiveDefine = true;
break;
}
if (defineBegin != defineEnd && !foundLiveDefine) {
fprintf(stderr, "!!! Removed instruction because it was only defining unused registers !!!\n");
instruction.remove();
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName range = name2range[definePtr->getRegisterName()];
#ifdef DEBUG
if (needLoad.test(range))
if (!mustSpill.test(range) && registerAllocator.spillCost[range].infinite && willSpill.test(range)) {
fprintf(stderr, "Tried to spill a register with infinite spill cost\n");
abort();
}
#endif // DEBUG
if (willSpill.test(range))
insertStoreAfter(instruction, range);
needLoad.clear(range);
}
if (instruction.getFlags() & ifCopy)
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName range = name2range[usePtr->getRegisterName()];
if (!currentLive.test(range))
for (SparseSet::iterator r = needLoad.begin(); !needLoad.done(r); r = needLoad.advance(r)) {
RegisterName load = RegisterName(needLoad.get(r));
if (willSpill.test(load))
insertLoadBefore(instruction, load);
mustSpill.set(load);
}
needLoad.clear();
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
currentLive.clear(name2range[definePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName range = name2range[usePtr->getRegisterName()];
currentLive.set(range);
needLoad.set(range);
}
}
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
RegisterName load = RegisterName(needLoad.get(l));
if (willSpill.test(load))
insertLoadBefore(instructions.first(), load);
}
}
}
template <class RegisterPressure>
void Spilling<RegisterPressure>::insertLoadBefore(Instruction& /*instruction*/, RegisterName name)
{
fprintf(stdout, "will insert load for range %d\n", name);
}
template <class RegisterPressure>
void Spilling<RegisterPressure>::insertStoreAfter(Instruction& /*instruction*/, RegisterName name)
{
fprintf(stdout, "will insert store for range %d\n", name);
}
template <class RegisterPressure>
void Spilling<RegisterPressure>::calculateSpillCosts(RegisterAllocator& registerAllocator)
{
Uint32 rangeCount = registerAllocator.rangeCount;
RegisterName* name2range = registerAllocator.name2range;
Pool& pool = registerAllocator.pool;
SparseSet live(pool, rangeCount);
SparseSet needLoad(pool, rangeCount);
SparseSet mustSpill(pool, rangeCount);
SparseSet alreadyStored(pool, rangeCount); // FIX: should get this from previous spilling.
SpillCost* cost = new SpillCost[rangeCount];
memset(cost, '\0', rangeCount * sizeof(SpillCost));
ControlGraph& controlGraph = registerAllocator.controlGraph;
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
ControlNode& node = *nodes[n];
double weight = doLog10(node.loopDepth);
needLoad.clear();
live = liveOut[n];
mustSpill = live;
InstructionList& instructions = nodes[n]->getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
InstructionDefine* definePtr;
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister()) {
RegisterName range = name2range[definePtr->getRegisterName()];
if (needLoad.test(range))
if (!mustSpill.test(range))
cost[range].infinite = true;
if ((false /* !rematerializable(range) */ || !needLoad.test(range)) && !alreadyStored.test(range))
cost[range].stores += weight;
needLoad.clear(range);
}
if (instruction.getFlags() & ifCopy)
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
if (!live.test(name2range[usePtr->getRegisterName()])) {
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
Uint32 range = needLoad.get(l);
cost[range].loads += weight;
mustSpill.set(range);
}
needLoad.clear();
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
live.clear(name2range[definePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName range = name2range[usePtr->getRegisterName()];
live.set(range);
needLoad.set(range);
}
if (instruction.getFlags() & ifCopy) {
assert(useBegin != useEnd && useBegin[0].isRegister());
assert(defineBegin != defineEnd && defineBegin[0].isRegister());
RegisterName source = name2range[useBegin[0].getRegisterName()];
RegisterName destination = name2range[defineBegin[0].getRegisterName()];
cost[source].copies += weight;
cost[destination].copies += weight;
}
}
for (SparseSet::iterator s = needLoad.begin(); !needLoad.done(s); s = needLoad.advance(s))
cost[needLoad.get(s)].loads += weight;
}
for (Uint32 r = 0; r < rangeCount; r++) {
SpillCost& c = cost[r];
c.cost = 2 * (c.loads + c.stores) - c.copies;
}
registerAllocator.spillCost = cost;
}
#endif // _SPILLING_H_

View File

@@ -0,0 +1,239 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _SPLITS_H_
#define _SPLITS_H_
#include "Fundamentals.h"
#include <string.h>
#include "Pool.h"
#include "ControlGraph.h"
#include "ControlNodes.h"
#include "Instruction.h"
#include "RegisterAllocator.h"
#include "RegisterAllocatorTools.h"
UT_EXTERN_LOG_MODULE(RegAlloc);
template <class RegisterPressure>
struct Splits
{
static void calculateSplitCosts(RegisterAllocator& registerAllocator);
static bool findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range);
static void insertSplitCode(RegisterAllocator& registerAllocator);
};
struct SplitCost
{
double loads;
double stores;
};
template <class RegisterPressure>
void Splits<RegisterPressure>::insertSplitCode(RegisterAllocator& /*registerAllocator*/)
{
// FIX
}
template <class RegisterPressure>
bool Splits<RegisterPressure>::findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range)
{
Pool& pool = registerAllocator.pool;
NameLinkedList** neighborsWithColor = new(pool) NameLinkedList*[6]; // FIX
memset(neighborsWithColor, '\0', 6 * sizeof(NameLinkedList*));
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
for (Int32 i = vector->count - 1; i >=0; --i) {
RegisterName neighbor = vector->neighbors[i];
RegisterName c = color[neighbor];
if (c < 6) { // FIX
NameLinkedList* node = new(pool) NameLinkedList();
node->name = neighbor;
node->next = neighborsWithColor[c];
neighborsWithColor[c] = node;
}
}
bool splitAroundName = true;
LiveRangeGraph<RegisterPressure>& lGraph = registerAllocator.lGraph;
RegisterName bestColor = RegisterName(6); // FIX
double bestCost = registerAllocator.spillCost[range].cost;
SplitCost* splitCost = registerAllocator.splitCost;
for (RegisterName i = RegisterName(0); i < 6; i = RegisterName(i + 1)) { // FIX
double splitAroundNameCost = 0.0;
bool canSplitAroundName = true;
SplitCost& sCost = splitCost[range];
double addedCost = 2.0 * (sCost.stores + sCost.loads);
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
RegisterName neighbor = node->name;
if (lGraph.haveEdge(neighbor, range)) {
canSplitAroundName = false;
break;
} else
splitAroundNameCost += addedCost;
}
if (canSplitAroundName && splitAroundNameCost < bestCost) {
bestCost = splitAroundNameCost;
bestColor = i;
splitAroundName = true;
}
double splitAroundColorCost = 0.0;
bool canSplitAroundColor = true;
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
RegisterName neighbor = node->name;
if (lGraph.haveEdge(range, neighbor)) {
canSplitAroundColor = false;
break;
} else {
SplitCost& sCost = splitCost[neighbor];
double addedCost = 2.0 * (sCost.stores + sCost.loads);
splitAroundColorCost += addedCost;
}
}
if (canSplitAroundColor && splitAroundColorCost < bestCost) {
bestCost = splitAroundColorCost;
bestColor = i;
splitAroundName = false;
}
}
if (bestColor < RegisterName(6)) {
color[range] = bestColor;
registerAllocator.splitFound = true;
NameLinkedList** splitAround = registerAllocator.splitAround;
if (splitAroundName)
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
NameLinkedList* newNode = new(pool) NameLinkedList();
newNode->name = node->name;
newNode->next = splitAround[range];
splitAround[range] = newNode;
}
else
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
NameLinkedList* newNode = new(pool) NameLinkedList();
RegisterName neighbor = node->name;
newNode->name = range;
newNode->next = splitAround[neighbor];
splitAround[neighbor] = newNode;
}
trespass("Found a split");
return true;
}
return false;
}
template <class RegisterPressure>
void Splits<RegisterPressure>::calculateSplitCosts(RegisterAllocator& registerAllocator)
{
Pool& pool = registerAllocator.pool;
Uint32 rangeCount = registerAllocator.rangeCount;
RegisterName* name2range = registerAllocator.name2range;
SplitCost* splitCost = new(pool) SplitCost[rangeCount];
memset(splitCost, '\0', rangeCount * sizeof(SplitCost));
SparseSet live(pool, rangeCount);
RegisterPressure::Set* liveIn = registerAllocator.liveness.liveIn;
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
ControlGraph& controlGraph = registerAllocator.controlGraph;
ControlNode** nodes = controlGraph.dfsList;
Uint32 nNodes = controlGraph.nNodes;
for (Uint32 n = 0; n < nNodes; n++) {
ControlNode& node = *nodes[n];
double weight = doLog10(node.loopDepth);
live = liveOut[n];
ControlEdge* successorsEnd = node.getSuccessorsEnd();
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++) {
ControlNode& successor = successorsPtr->getTarget();
if (successor.getControlKind() != ckEnd) {
RegisterPressure::Set& successorLiveIn = liveIn[successor.dfsNum];
for (SparseSet::iterator i = live.begin(); !live.done(i); i = live.advance(i)) {
RegisterName name = RegisterName(live.get(i));
if (!successorLiveIn.test(name))
splitCost[name].loads += doLog10(successor.loopDepth);
}
}
}
InstructionList& instructions = node.getInstructions();
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
Instruction& instruction = instructions.get(i);
InstructionUse* useBegin = instruction.getInstructionUseBegin();
InstructionUse* useEnd = instruction.getInstructionUseEnd();
InstructionUse* usePtr;
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
InstructionDefine* definePtr;
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
splitCost[name2range[definePtr->getRegisterName()]].stores += weight;
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister()) {
RegisterName range = name2range[usePtr->getRegisterName()];
if (!live.test(range)) {
if (&instruction != &instructions.last())
splitCost[range].loads += weight;
else {
ControlEdge* successorsEnd = node.getSuccessorsEnd();
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++)
splitCost[range].loads += doLog10(successorsPtr->getTarget().loopDepth);
}
}
}
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
if (definePtr->isRegister())
live.clear(name2range[definePtr->getRegisterName()]);
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
if (usePtr->isRegister())
live.set(name2range[usePtr->getRegisterName()]);
}
}
NameLinkedList** splitAround = new(pool) NameLinkedList*[rangeCount];
memset(splitAround, '\0', rangeCount * sizeof(NameLinkedList*));
registerAllocator.splitAround = splitAround;
registerAllocator.splitCost = splitCost;
registerAllocator.splitFound = false;
}
#endif // _SPLITS_H_

View File

@@ -0,0 +1,186 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "Fundamentals.h"
#include "HashTable.h"
#include "Timer.h"
#include "Pool.h"
static Pool pool; // Pool for the Timer class.
static HashTable<TimerEntry*> timerEntries(pool); // Timers hashtable.
const nTimersInABlock = 128; // Number of timers in a block.
static PRTime *timers = new(pool) PRTime[nTimersInABlock]; // A block of timers.
static Uint8 nextTimer = 0; // nextAvailableTimer.
//
// Calibrate the call to PR_Now().
//
static PRTime calibrate()
{
PRTime t = PR_Now();
PRTime& a = *new(pool) PRTime();
// Call 10 times the PR_Now() function.
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
t = (PR_Now() - t + 9) / 10;
return t;
}
static PRTime adjust = calibrate();
//
// Return the named timer..
//
TimerEntry& Timer::getTimerEntry(const char* name)
{
if (!timerEntries.exists(name)) {
TimerEntry* newEntry = new(pool) TimerEntry();
newEntry->accumulator = 0;
newEntry->running = false;
timerEntries.add(name, newEntry);
}
return *timerEntries[name];
}
//
// Return a reference to a new timer.
//
PRTime& Timer::getNewTimer()
{
if (nextTimer >= nTimersInABlock) {
timers = new(pool) PRTime[nTimersInABlock];
nextTimer = 0;
}
return timers[nextTimer++];
}
static Uint32 timersAreFrozen = 0;
//
// Start the named timer.
//
void Timer::start(const char* name)
{
if (timersAreFrozen)
return;
freezeTimers();
TimerEntry& timer = getTimerEntry(name);
PR_ASSERT(!timer.running);
timer.accumulator = 0;
timer.running = true;
timer.done = false;
unfreezeTimers();
}
//
// Stop the named timer.
//
void Timer::stop(const char* name)
{
if (timersAreFrozen)
return;
freezeTimers();
TimerEntry& timer = getTimerEntry(name);
PR_ASSERT(timer.running);
timer.running = false;
timer.done = true;
unfreezeTimers();
}
//
// Freeze all the running timers.
//
void Timer::freezeTimers()
{
PRTime when = PR_Now() - adjust;
if (timersAreFrozen == 0) {
Vector<TimerEntry*> entries = timerEntries;
Uint32 count = entries.size();
for (Uint32 i = 0; i < count; i++) {
TimerEntry& entry = *entries[i];
if (entry.running) {
entry.accumulator += (when - *entry.startTime);
}
}
}
timersAreFrozen++;
}
//
// Unfreeze all the running timers.
//
void Timer::unfreezeTimers()
{
PR_ASSERT(timersAreFrozen != 0);
timersAreFrozen--;
if (timersAreFrozen == 0) {
Vector<TimerEntry *> entries = timerEntries;
Uint32 count = entries.size();
PRTime& newStart = getNewTimer();
for (Uint32 i = 0; i < count; i++) {
TimerEntry& entry = *entries[i];
if (entry.running) {
entry.startTime = &newStart;
}
}
newStart = PR_Now();
}
}
//
// Print the named timer in the file f.
//
void Timer::print(FILE* f, const char *name)
{
if (timersAreFrozen)
return;
freezeTimers();
TimerEntry& timer = getTimerEntry(name);
PR_ASSERT(timer.done);
PRTime elapsed = timer.accumulator;
if (elapsed >> 32) {
fprintf(f, "[timer %s out of range]\n", name);
} else {
fprintf(f, "[%dus in %s]\n", Uint32(elapsed), name);
}
fflush(f);
unfreezeTimers();
}

View File

@@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _TIMER_H_
#define _TIMER_H_
#include "Fundamentals.h"
#include "HashTable.h"
#include "prtime.h"
//
// Naming convention:
// As the class Timer contains only static methods, the timer's name should start with the
// module name. Otherwise starting 2 timers with the same name will assert.
//
#ifndef NO_TIMER
struct TimerEntry
{
PRTime *startTime; // Current time when we start the timer.
PRTime accumulator; // Time spent in this timer.
bool running; // True if the timer is running.
bool done; // True if the timer was running and was stopped.
};
class Timer
{
private:
// Return the named timer.
static TimerEntry& getTimerEntry(const char* name);
// Return a reference to a new Timer.
static PRTime& getNewTimer();
public:
// Start the timer.
static void start(const char* name);
// Stop the timer.
static void stop(const char* name);
// Freeze all the running timers.
static void freezeTimers();
// Unfreeze all the running timers.
static void unfreezeTimers();
// Print the timer.
static void print(FILE* f, const char *name);
};
inline void startTimer(const char* name) {Timer::start(name);}
inline void stopTimer(const char* name) {Timer::stop(name); Timer::print(stdout, name);}
#define START_TIMER_SAFE Timer::freezeTimers();
#define END_TIMER_SAFE Timer::unfreezeTimers();
#define TIMER_SAFE(x) START_TIMER_SAFE x; END_TIMER_SAFE
#else /* NO_TIMER */
inline void startTimer(const char* /*name*/) {}
inline void stopTimer(const char* /*name*/) {}
#define START_TIMER_SAFE
#define END_TIMER_SAFE
#define TIMER_SAFE(x) x;
#endif /* NO_TIMER */
#endif /* _TIMER_H_ */

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -16,30 +16,25 @@
* Reserved.
*/
#ifndef TextDebugLog_h___
#define TextDebugLog_h___
#include "Fundamentals.h"
#include "VirtualRegister.h"
#include "Instruction.h"
#ifdef NS_DEBUG
#define IMPORT_DEBUG 1
//------------------------------------------------------------------------------
// VirtualRegister -
#ifdef MANUAL_TEMPLATES
template class IndexedPool<VirtualRegister>;
#endif
#ifdef IMPORT_DEBUG
#include <stdio.h>
// Set the defining instruction.
//
void VirtualRegister::setDefiningInstruction(Instruction& instruction)
{
if (definingInstruction != NULL) {
if ((instruction.getFlags() & ifCopy) && (definingInstruction->getFlags() & ifPhiNode))
return;
}
definingInstruction = &instruction;
}
#define IMPORT_LOG0( x) printf( x)
#define IMPORT_LOG1( x, y) printf( x, y)
#define IMPORT_LOG2( x, y, z) printf( x, y, z)
#define IMPORT_LOG3( a, b, c, d) printf( a, b, c, d)
#else
#define IMPORT_LOG0( x)
#define IMPORT_LOG1( x, y)
#define IMPORT_LOG2( x, y, z)
#define IMPORT_LOG3( a, b, c, d)
#endif
#endif /* TextDebugLog_h___ */

View File

@@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _VIRTUAL_REGISTER_H_
#define _VIRTUAL_REGISTER_H_
#include "Fundamentals.h"
#include "IndexedPool.h"
#include <string.h>
#include "RegisterTypes.h"
#include "RegisterClass.h"
//------------------------------------------------------------------------------
// VirtualRegister - 24b
class Instruction;
class VirtualRegister : public IndexedObject<VirtualRegister>
{
public:
Instruction* definingInstruction; // Instruction defining this VR.
// Initialize a VR of the given classKind.
VirtualRegister(RegisterClassKind /*classKind*/) : definingInstruction(NULL) {}
// Return the defining instruction for this VR.
Instruction* getDefiningInstruction() const {return definingInstruction;}
// Set the defining instruction.
void setDefiningInstruction(Instruction& insn);
};
// Return true if the VirtualRegisters are equals. The only way 2 VRs can be equal is if
// they have the same index. If they have the same index then they are at the same
// address in the indexed pool.
//
inline bool operator == (const VirtualRegister& regA, const VirtualRegister& regB) {return &regA == &regB;}
//------------------------------------------------------------------------------
// VirtualRegisterManager -
struct PreColoredRegister
{
RegisterID id;
RegisterName color;
};
class VirtualRegisterManager
{
private:
IndexedPool<VirtualRegister> registerPool;
PreColoredRegister machineRegister[6];
public:
VirtualRegisterManager()
{
for (Uint32 i = 0; i < 6; i++)
machineRegister[i].id = invalidID;
}
// Return the VirtualRegister at the given index.
VirtualRegister& getVirtualRegister(RegisterName name) const {return registerPool.get(name);}
// Return a new VirtualRegister.
RegisterID newVirtualRegister(RegisterClassKind classKind)
{
VirtualRegister& vReg = *new(registerPool) VirtualRegister(classKind);
RegisterID rid;
setName(rid, RegisterName(vReg.getIndex()));
setClass(rid, classKind);
return rid;
}
RegisterID newMachineRegister(RegisterName name, RegisterClassKind classKind)
{
RegisterID rid = machineRegister[name].id;
if (rid == invalidID) {
rid = newVirtualRegister(classKind);
DEBUG_ONLY(setMachineRegister(rid));
machineRegister[name].id = rid;
machineRegister[name].color = name;
}
return rid;
}
PreColoredRegister* getMachineRegistersBegin() const {return (PreColoredRegister*) machineRegister;} // FIX
PreColoredRegister* getMachineRegistersEnd() const {return (PreColoredRegister*) &machineRegister[6];} // FIX
// Return the VirtualRegister universe size.
Uint32 getSize() {return registerPool.getSize();}
void setSize(Uint32 size) {registerPool.setSize(size);}
};
#endif // _VIRTUAL_REGISTER_H_

View File

@@ -1,36 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public base db/msgdb news local mime compose imap addrbook import absync extensions
ifeq ($(OS_ARCH),WINNT)
DIRS += mapi
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,32 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src build
include $(topsrcdir)/config/rules.mk

View File

@@ -1,21 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
nsAbSyncCID.h

View File

@@ -1,69 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
LIBRARY_NAME = absyncsvc
META_COMPONENT = mail
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsAbSyncModule
SHORT_LIBNAME = absyncsv
REQUIRES = xpcom \
string \
necko \
docshell \
uriloader \
msgbase \
intl \
addrbook \
mork \
$(NULL)
ifeq ($(USE_SHORT_LIBNAME),1)
EXTRA_DSO_LIBS = msgbsutl
else
EXTRA_DSO_LIBS = msgbaseutil
endif
CPPSRCS = nsAbSyncFactory.cpp
EXPORTS = nsAbSyncCID.h
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)absync_s.$(LIB_SUFFIX) \
$(NULL)
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_JS_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAbSyncCID_h__
#define nsAbSyncCID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
//
// Ab Sync Service
//
#define NS_ABSYNC_SERVICE_CID \
{ /* {3C21BB39-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb39, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_SERVICE_CONTRACTID \
"@mozilla.org/absync;1"
//
// Ab Sync Listener
//
#define NS_ABSYNC_LISTENER_CID \
{ /* {3C21BB44-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb44, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_LISTENER_CONTRACTID \
"@mozilla.org/absync/listener;1"
//
// Ab Sync Post Engine
//
#define NS_ABSYNC_POST_ENGINE_CID \
{ /* {3C21BB9f-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb9f, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_POST_ENGINE_CONTRACTID \
"@mozilla.org/absync/postengine;1"
//
// Ab Sync Post Listener
//
#define NS_ABSYNC_POST_LISTENER_CID \
{ /* {3C21BBcc-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bbcc, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_POST_LISTENER_CONTRACTID \
"@mozilla.org/absync/postlistener;1"
//
// Sync Driver
//
#define NS_ADDBOOK_SYNCDRIVER_CONTRACTID \
"@mozilla.org/addressbook/services/syncdriver;1"
#define NS_ADDBOOK_SYNCDRIVER_CID \
{ /* 40D1D3DA-1637-11d4-8FE1-00A024A7D144 */ \
0x40d1d3da, 0x1637, 0x11d4, \
{ 0x8f, 0xe1, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } \
}
#endif // nsAbSyncCID_h__

View File

@@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "msgCore.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIFactory.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIModule.h"
#include "pratom.h"
#include "nsAbSyncCID.h"
/* Include all of the interfaces our factory can generate components for */
#include "nsAbSync.h"
#include "nsAbSyncPostEngine.h"
#include "nsABSyncDriver.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbSync);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbSyncDriver)
////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////
static const nsModuleComponentInfo components[] =
{
{ "Addressbook Sync",
NS_ABSYNC_SERVICE_CID,
NS_ABSYNC_SERVICE_CONTRACTID,
nsAbSyncConstructor },
{ "Addressbook Sync Post Engine",
NS_ABSYNC_POST_ENGINE_CID,
NS_ABSYNC_POST_ENGINE_CONTRACTID,
nsAbSyncPostEngine::Create },
{ "The Address Book Sync Driver",
NS_ADDBOOK_SYNCDRIVER_CID,
NS_ADDBOOK_SYNCDRIVER_CONTRACTID,
nsAbSyncDriverConstructor }
};
NS_IMPL_NSGETMODULE(nsAbSyncModule, components)

View File

@@ -1 +0,0 @@
_NSGetModule ; 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacPrefix.h"

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacPrefix_debug.h"

View File

@@ -1,42 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
XPIDL_MODULE = absync
XPIDLSRCS = \
nsIAbSync.idl \
nsIAbSyncMojo.idl \
nsIAbSyncListener.idl \
nsIAbSyncPostEngine.idl \
nsIAbSyncPostListener.idl \
nsIAbSyncDriver.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsrootidl.idl"
#include "nsIAbSyncListener.idl"
#include "nsIMsgStatusFeedback.idl"
[uuid(3c9cbef8-070b-4123-98b2-9297443a8cd1)]
interface nsIAbSyncState
{
const long nsIAbSyncIdle = 0;
const long nsIAbSyncRunning = 1;
};
[scriptable, uuid(74872D27-0A4E-11d4-8FD6-00A024A7D144)]
interface nsIAbSync : nsISupports {
/*
* This is the primary interface for performing AB Sync operations
*/
/* Add or remove a listener for this particular sync operation */
void AddSyncListener(in nsIAbSyncListener aListener);
void RemoveSyncListener(in nsIAbSyncListener aListener);
/* Get the nsIAbSyncPostEngineState of the sync operation */
PRInt32 GetCurrentState();
/*
* Send the protocol request and get a transaction ID in return that
* will be sent along with all sync listener operations
*/
void PerformAbSync(in nsIDOMWindowInternal aDOMWindow, out PRInt32 aTransactionID);
void CancelAbSync();
void SetAbSyncUser(in string aUser);
};

View File

@@ -1,48 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsrootidl.idl"
#include "nsIAbSyncListener.idl"
#include "nsIMsgStatusFeedback.idl"
[scriptable, uuid(91FDFEE1-EFBC-11d3-8F97-000073757374)]
interface nsIAbSyncDriver : nsIAbSyncListener
{
void KickIt(in nsIMsgStatusFeedback aStatus, in nsIDOMWindowInternal aDOMWindow);
void CancelIt();
};

View File

@@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
%{C++
%}
[scriptable, uuid(E0ED29E0-098A-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncListener : nsISupports {
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
void OnStartAuthOperation();
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
void OnStopAuthOperation(in nsresult aStatus, in wstring aMsg, in string aCookie);
/**
* Notify the observer that the AB Sync operation has begun. This method is
* called only once, at the beginning of a sync transaction
*
*/
void OnStartOperation(in PRInt32 aTransactionID, in PRUint32 aMsgSize);
/**
* Notify the observer that progress as occurred for the AB Sync operation
*/
void OnProgress(in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax);
/**
* Notify the observer with a status message for sync operation
*/
void OnStatus(in PRInt32 aTransactionID, in wstring aMsg);
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
*/
void OnStopOperation(in PRInt32 aTransactionID, in nsresult aStatus,
in wstring aMsg);
};

View File

@@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIStreamListener.idl"
#include "nsIDocShell.idl"
%{C++
#define NS_AB_SYNC_MOJO_CID \
{ 0x842cc263, 0x5255, 0x1144, \
{ 0xcc, 0xb8, 0x44, 0x45, 0x53, 0xff, 0x0, 0x2 } }
#define NS_AB_SYNC_MOJO_CONTRACTID \
"@mozilla.org/absync/absyncmojo;1"
%}
[scriptable, uuid(74872D27-0A4E-11d4-8FD6-BEEF24A7D144)]
interface nsIAbSyncMojo : nsISupports {
/*
* This is the primary interface for performing AB Sync mojo operations
*/
string BuildMojoString(in nsIDocShell aRootDocShell);
void StartAbSyncMojo(in nsIStreamListener aListener,
in nsIDocShell aRootDocShell,
in string aUser);
void GetAbSyncMojoResults(out string aMojoUser, out string aMojoString,
out string aMojoSpec, out long aMojoPort);
void CancelTheMojo();
};

View File

@@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIAbSyncPostListener.idl"
#include "nsIDocShell.idl"
[scriptable, uuid(E0ED29D3-BEEF-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncPostEngineState
{
const long nsIAbSyncPostIdle = 0;
const long nsIAbSyncPostRunning = 1;
const long nsIAbSyncAuthenticationRunning = 2;
};
[scriptable, uuid(E0ED29D3-098A-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncPostEngine : nsISupports {
/*
* This is the primary interface for posting operations to the
* Address Book server in the sky
*/
/* Add or remove a listener for this particular sync operation */
void AddPostListener(in nsIAbSyncPostListener aListener);
void RemovePostListener(in nsIAbSyncPostListener aListener);
/* Get the nsIAbSyncPostEngineState of the sync operation */
string BuildMojoString(in nsIDocShell aRootDocShell);
PRInt32 GetCurrentState();
void GetMojoUserAndSnack(out string aMojoUser, out string aMojoSnack);
/*
* Send the protocol request and get a transaction ID in return that
* will be sent along with all sync listener operations
*/
void SendAbRequest(in string aSpec, in PRInt32 aPort, in string aProtocolRequest, in PRInt32 aTransactionID,
in nsIDocShell aDocShell, in string aUser);
/*
* Cancel it!
*/
void CancelAbSync();
};

View File

@@ -1,99 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
%{C++
%}
[scriptable, uuid(E0ED29E0-098A-11d4-8FD6-00A024A7BEEF)]
interface nsIAbSyncPostListener : nsISupports {
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
void OnStartAuthOperation();
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
void OnStopAuthOperation(in nsresult aStatus, in wstring aMsg, in string aCookie);
/**
* Notify the observer that the AB Sync operation has begun. This method is
* called only once, at the beginning of a sync transaction
*
*/
void OnStartOperation(in PRInt32 aTransactionID, in PRUint32 aMsgSize);
/**
* Notify the observer that progress as occurred for the AB Sync operation
*/
void OnProgress(in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax);
/**
* Notify the observer with a status message for sync operation
*/
void OnStatus(in PRInt32 aTransactionID, in wstring aMsg);
/**
* Notify the observer that the AB Sync operation has been sent. This
* method is called once when the networking library has finished processing
* the sync operation.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aProtocolResponse - The protocol response sent by the AB server
*/
void OnStopOperation(in PRInt32 aTransactionID, in nsresult aStatus,
in wstring aMsg, in string aProtocolResponse);
};

View File

@@ -1 +0,0 @@
absync.properties

View File

@@ -1,40 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
#
# The following are used by the Mailing list dialog
#
syncDoneSuccess=Synchronization completed.
syncDoneFailed=Synchronization Failed.
syncDoneCancelled=Synchronization cancelled by user.
syncProgress=Synchronization received %d bytes...
syncStarting=Synchronization starting with %d byte request...
syncConnect=Synchronization connecting to server...
syncStartingAuth=Synchronization authentication started...
syncAuthSuccess=Synchronization authentication complete.
syncAuthFailed=Synchronization authentication failed.
syncInvalidResponse=The server returned invalid response!
syncServerError=The server returned the error: %s
syncNeedPrefs=You need to fill in your Address Book Synchronization preferences before attempting a synchronization operation.
passwordPrompt=Enter your Netscape.com User Name and Password for Address Book Synchronization
passwordTitle=Enter Password
passwordError=You must enter a valid screen name and password for Address Book Synchronization
syncInProgress=Address Book Synchronization in progress...please wait...
exceedMaxRecordError=Synchronization failed because your Personal Address Book has exceeded the maximum limit of 1500 entries. Remove some entries from your Personal Address Book, and then try again.

View File

@@ -1,77 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
XPIDL_MODULE = absync
LIBRARY_NAME = absync_s
META_COMPONENT = mail
REQUIRES = xpcom \
string \
necko \
mime \
docshell \
uriloader \
pref \
widget \
msgbase \
msgbaseutil \
dom \
rdf \
addrbook \
intl \
mork \
mimetype \
windowwatcher \
unicharutil \
$(NULL)
CPPSRCS = \
nsAbSyncPostEngine.cpp \
nsAbSync.cpp \
nsAbSyncCRCModel.cpp \
nsABSyncDriver.cpp \
nsSyncDecoderRing.cpp \
$(NULL)
EXPORTS = \
nsAbSyncPostEngine.h \
nsAbSync.h \
nsAbSyncCRCModel.h \
nsABSyncDriver.h \
nsSyncDecoderRing.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif

View File

@@ -1,285 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsABSyncDriver.h"
#include "nsIAbSync.h"
#include "nsAbSyncCID.h"
#include "nsIServiceManager.h"
#include "nsTextFormatter.h"
#include "nsIStringBundle.h"
#include "prmem.h"
#include "nsString.h"
#include "nsCRT.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbSyncDriver, nsIAbSyncDriver)
//NS_IMPL_ISUPPORTS1(nsAbSyncDriver, nsIAbSyncDriver)
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsAbSyncDriver::nsAbSyncDriver()
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mTransactionID = -1;
mStatus = nsnull;
}
nsAbSyncDriver::~nsAbSyncDriver()
{
/* destructor code */
}
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
NS_IMETHODIMP
nsAbSyncDriver::OnStartAuthOperation(void)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
// Tweak the button...
mStatus->StartMeteors();
mStatus->ShowProgress(0);
outValue = GetString(NS_LITERAL_STRING("syncStartingAuth").get());
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
NS_IMETHODIMP
nsAbSyncDriver::OnStopAuthOperation(nsresult aStatus, const PRUnichar *aMsg, const char *aCookie)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
if (NS_SUCCEEDED(aStatus))
outValue = GetString(NS_LITERAL_STRING("syncAuthSuccess").get());
else
outValue = GetString(NS_LITERAL_STRING("syncAuthFailed").get());
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/* void OnStartOperation (in PRInt32 aTransactionID, in PRUint32 aMsgSize); */
NS_IMETHODIMP nsAbSyncDriver::OnStartOperation(PRInt32 aTransactionID, PRUint32 aMsgSize)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
PRUnichar *msgValue = nsnull;
// Tweak the button...
mStatus->StartMeteors();
mStatus->ShowProgress(50);
outValue = GetString(NS_LITERAL_STRING("syncStarting").get());
msgValue = nsTextFormatter::smprintf(outValue, aMsgSize);
mStatus->ShowStatusString(msgValue);
PR_FREEIF(outValue);
PR_FREEIF(msgValue);
}
return NS_OK;
}
/* void OnProgress (in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax); */
NS_IMETHODIMP nsAbSyncDriver::OnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
PRUnichar *msgValue = nsnull;
outValue = GetString(NS_LITERAL_STRING("syncProgress").get());
msgValue = nsTextFormatter::smprintf(outValue, aProgress);
mStatus->ShowStatusString(msgValue);
PR_FREEIF(outValue);
PR_FREEIF(msgValue);
}
return NS_OK;
}
/* void OnStatus (in PRInt32 aTransactionID, in wstring aMsg); */
NS_IMETHODIMP nsAbSyncDriver::OnStatus(PRInt32 aTransactionID, const PRUnichar *aMsg)
{
return mStatus->ShowStatusString(aMsg);
}
/* void OnStopOperation (in PRInt32 aTransactionID, in nsresult aStatus, in wstring aMsg); */
NS_IMETHODIMP nsAbSyncDriver::OnStopOperation(PRInt32 aTransactionID, nsresult aStatus, const PRUnichar *aMsg)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
// Tweak the button...
mStatus->StopMeteors();
mStatus->CloseWindow();
if (NS_SUCCEEDED(aStatus))
outValue = GetString(NS_LITERAL_STRING("syncDoneSuccess").get());
else
{
if (mCancelled)
outValue = GetString(NS_LITERAL_STRING("syncDoneCancelled").get());
else
outValue = GetString(NS_LITERAL_STRING("syncDoneFailed").get());
}
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/* void KickIt (); */
NS_IMETHODIMP nsAbSyncDriver::KickIt(nsIMsgStatusFeedback *aStatus, nsIDOMWindowInternal *aDocShell)
{
nsresult rv = NS_OK;
PRInt32 stateVar;
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_FAILED(rv) || !sync)
return rv;
mCancelled = PR_FALSE;
sync->GetCurrentState(&stateVar);
if (stateVar != nsIAbSyncState::nsIAbSyncIdle)
return NS_ERROR_FAILURE;
mStatus = aStatus;
// Add ourselves to the party!
sync->AddSyncListener((nsIAbSyncListener *)this);
rv = sync->PerformAbSync(aDocShell, &mTransactionID);
if (NS_SUCCEEDED(rv))
{
if (mStatus)
{
PRUnichar *msgValue = nsnull;
msgValue = GetString(NS_LITERAL_STRING("syncStartingAuth").get());
mStatus->ShowStatusString(msgValue);
PR_FREEIF(msgValue);
}
}
else
{
// We failed, turn the button back on...
mStatus->StopMeteors();
mStatus->CloseWindow();
}
return rv;
}
#define AB_STRING_URL "chrome://messenger/locale/addressbook/absync.properties"
PRUnichar *
nsAbSyncDriver::GetString(const PRUnichar *aStringName)
{
nsresult res = NS_OK;
PRUnichar *ptrv = nsnull;
if (!mStringBundle)
{
static const char propertyURL[] = AB_STRING_URL;
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(kStringBundleServiceCID, &res);
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
{
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
}
}
if (mStringBundle)
res = mStringBundle->GetStringFromName(aStringName, &ptrv);
if ( NS_SUCCEEDED(res) && (ptrv) )
return ptrv;
else
return nsCRT::strdup(aStringName);
}
//
// What if we want to stop the operation? Call this!
//
NS_IMETHODIMP nsAbSyncDriver::CancelIt()
{
nsresult rv = NS_OK;
PRInt32 stateVar;
mCancelled = PR_TRUE;
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_FAILED(rv) || !sync)
return rv;
sync->GetCurrentState(&stateVar);
if (stateVar == nsIAbSyncState::nsIAbSyncIdle)
return NS_ERROR_FAILURE;
// Cancel this mess...
return sync->CancelAbSync();
}

View File

@@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsAbSyncDriver_h__
#define __nsAbSyncDriver_h__
#include "nsIAbSyncDriver.h"
#include "nsIMsgStatusFeedback.h"
#include "nsIStringBundle.h"
#include "nsCOMPtr.h"
class nsAbSyncDriver : public nsIAbSyncDriver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNCDRIVER
NS_DECL_NSIABSYNCLISTENER
nsAbSyncDriver();
virtual ~nsAbSyncDriver();
/* additional members */
PRUnichar *GetString(const PRUnichar *aStringName);
private:
nsCOMPtr<nsIStringBundle> mStringBundle;
PRInt32 mTransactionID;
nsCOMPtr<nsIMsgStatusFeedback> mStatus;
PRBool mCancelled;
};
#endif /* __nsAbSyncDriver_h__ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,294 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsIAbSync_h__
#define __nsIAbSync_h__
#include "nsIAbSync.h"
#include "nsIAbSyncPostListener.h"
#include "nsIAbSyncPostEngine.h"
#include "nsCOMPtr.h"
#include "nsIAddrDatabase.h"
#include "nsIAbDirectory.h"
#include "nsIAbMDBCard.h"
#include "nsAbSyncCRCModel.h"
#include "nsVoidArray.h"
#include "nsIStringBundle.h"
#include "nsIDocShell.h"
#include "nsIFileSpec.h"
//
// Basic Sync Logic
// Keep a Sync mapping table like:
//
// ServerRecordID - Unique ID for a record provided by the
// UAB server.
// LocalRecordID - Local Unique ID, for mobile devices this
// is assigned by the mobile device.
// CRC - CRC of the record last time we synced.
// Flags - Operation to apply to this record. ADD
// if it's new, MOD if it's been modified,
// RET if it was already sent to the server
// but an error occured, etc.
//
// Step 1:
// When the user begins a sync, run through the local database and update the
// sync mapping table. If the CRC has changed, mark the entry modified, if
// it's a new record, add an entry and mark it new, if a record was deleted,
// mark the entry deleted, etc.
//
// Sync approach - server handles all conflict resolution:
//
// Step 2:
// Using the sync mapping table and the local records database, generate the change
// list to send to the server. Mark any modified or new record with the RET (retry)
// flag.
//
// Step 3:
// Get the response back from the server. Since the communication was successful,
// clear the RET (retry) flag on all records. Then apply the server changes back
// to the local database (updating the CRC's in the process). Save the changes to
// the local database, clear the sync mapping table flags and save the new sync
// mapping table.
//
typedef struct {
PRInt32 serverID;
PRInt32 localID;
ulong CRC;
PRUint32 flags;
} syncMappingRecord;
#define SYNC_MODIFIED 0x0001 // Must modify record on server
#define SYNC_ADD 0x0002 // Must add record to server
#define SYNC_DELETED 0x0004 // Must delete record from server
#define SYNC_RETRY 0x0008 // Sent to server but failed...must retry!
#define SYNC_RENUMBER 0x0010 // Renumber on the server
#define SYNC_PROCESSED 0x8000 // We processed the entry...nothing to do
#define SYNC_ALLTAGS 1000
#define SYNC_EMAILS 2000
#define ABSYNC_PROTOCOL "2.2.1.1.2.1.2.2.1.1.1.2"
#define ABSYNC_VERSION "Demo"
#define ABSYNC_HOME_PHONE_TYPE "Home"
#define ABSYNC_WORK_PHONE_TYPE "Work"
#define ABSYNC_FAX_PHONE_TYPE "Fax"
#define ABSYNC_PAGER_PHONE_TYPE "Pager"
#define ABSYNC_CELL_PHONE_TYPE "Cellular"
#define ABSYNC_HOME_PHONE_ID 1
#define ABSYNC_WORK_PHONE_ID 2
#define ABSYNC_FAX_PHONE_ID 3
#define ABSYNC_PAGER_PHONE_ID 4
#define ABSYNC_CELL_PHONE_ID 5
#define SYNC_ESCAPE_ADDUSER "op%3Dadd"
#define SYNC_ESCAPE_MOD "op%3Dmod"
#define SYNC_ESCAPE_DEL "op%3Ddel"
//mailing list
#define SYNC_ESCAPE_MAIL_ADD "op%3DmaillistCreate"
#define SYNC_ESCAPE_MAIL_MOD "op%3DmaillistRen"
#define SYNC_ESCAPE_MAIL_DEL "op%3DmaillistDel"
#define SYNC_ESCAPE_MAIL_EMAIL_MOD "op%3DemailstringUpdate"
#define SYNC_ESCAPE_MAIL_CONTACT_ADD "op%3DmaillistAdd"
#define SYNC_ESCAPE_MAIL_CONTACT_DEL "op%3DmaillistMemberDel"
// group
#define SYNC_ESCAPE_GROUP_DEL "op%3DgrpDel"
// Defines for what type of add this may be?
#define SYNC_SINGLE_USER_TYPE 1
#define SYNC_MAILLIST_TYPE 2
#define SYNC_GROUP_TYPE 3
#define SYNC_UNKNOWN_TYPE 0
// Server errors that need to be converted to more user-friendly ones.
#define SYNC_ERROR_EXCEED_MAX_RECORD "exceed max record"
// Generic name tag for AIM screen name
#define SYNC_PREF_PREFIX_CLIENT_MAP "mail.absync.client_map."
#define SYNC_PREF_PREFIX_SERVER_MAP "mail.absync.server_map."
//
// We need this structure for mapping our field names to the server
// field names
//
#define kMaxColumns 38
typedef struct {
const char *abField;
nsString serverField;
} schemaStruct;
class nsAbSync : public nsIAbSync, public nsIAbSyncPostListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNC
NS_DECL_NSIABSYNCPOSTLISTENER
nsAbSync();
virtual ~nsAbSync();
/* additional members */
private:
// Handy methods for listeners...
nsresult DeleteListeners();
nsresult NotifyListenersOnStartSync(PRInt32 aTransactionID, const PRUint32 aMsgSize);
nsresult NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax);
nsresult NotifyListenersOnStatus(PRInt32 aTransactionID, const PRUnichar *aMsg);
nsresult NotifyListenersOnStopSync(PRInt32 aTransactionID, nsresult aStatus, const PRUnichar *aMsg);
nsresult NotifyListenersOnStartAuthOperation(void);
nsresult NotifyListenersOnStopAuthOperation(nsresult aStatus, const PRUnichar *aMsg, const char *aCookie);
nsresult AnalyzeTheLocalAddressBook();
nsresult ProcessServerResponse(const char *aProtocolResponse);
NS_IMETHOD InitSchemaColumns();
NS_IMETHOD OpenAB(char *aAbName, nsIAddrDatabase **aDatabase);
NS_IMETHOD AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *directory);
NS_IMETHOD GenerateProtocolForCard(nsIAbCard *aCard, PRBool aAddId, nsString &protLine);
PRBool ThisCardHasChanged(nsIAbCard *aCard, syncMappingRecord *syncRecord, nsString &protLine);
void InternalInit();
nsresult InternalCleanup(nsresult aResult);
nsresult CleanServerTable(nsVoidArray *aArray);
PRUnichar *GetString(const PRUnichar *aStringName);
nsresult DisplayErrorMessage(const PRUnichar * msg);
nsresult SetDOMWindow(nsIDOMWindowInternal *aWindow);
nsCOMPtr<nsIAbSyncPostEngine> mPostEngine;
nsString mPostString;
nsIAbSyncListener **mListenerArray;
PRInt32 mListenerArrayCount;
PRInt32 mCurrentState;
PRInt32 mLastChangeNum;
char *mUserName;
nsCOMPtr<nsIStringBundle> mStringBundle;
// Setting for ABSync operations...
char *mAbSyncServer;
PRInt32 mAbSyncPort;
char *mAbSyncAddressBook;
char *mAbSyncAddressBookFileName;
PRInt32 mTransactionID;
PRInt32 mCurrentPostRecord;
nsCOMPtr<nsIFileSpec> mHistoryFile;
nsCOMPtr<nsIFileSpec> mLockFile;
PRBool mLastSyncFailed;
PRUint32 mOldTableSize;
syncMappingRecord *mOldSyncMapingTable; // Old history table...
PRUint32 mNewTableSize;
syncMappingRecord *mNewSyncMapingTable; // New table after reading address book
nsVoidArray *mNewServerTable; // New entries from the server
PRUint32 mCrashTableSize;
syncMappingRecord *mCrashTable; // Comparison table for crash recovery...
char *mProtocolResponse; // what the server said...
char *mProtocolOffset; // where in the buffer are we?
schemaStruct mSchemaMappingList[kMaxColumns];
///////////////////////////////////////////////
// The following is for protocol parsing
///////////////////////////////////////////////
PRBool EndOfStream(); // If this returns true, we are done with the data...
PRBool ParseNextSection(); // Deal with next section
nsresult AdvanceToNextLine();
nsresult AdvanceToNextSection();
char *ExtractCurrentLine();
nsresult ExtractInteger(char *aLine, char *aTag, char aDelim, PRInt32 *aRetVal);
char *ExtractCharacterString(char *aLine, char *aTag, char aDelim);
nsresult PatchHistoryTableWithNewID(PRInt32 clientID, PRInt32 serverID, PRInt32 aMultiplier, ulong crc);
nsresult DeleteRecord();
nsresult DeleteList();
nsresult DeleteGroup();
nsresult DeleteCardByServerID(PRInt32 aServerID);
nsresult LocateClientIDFromServerID(PRInt32 aServerID, PRInt32 *aClientID);
PRInt32 DetermineTagType(nsStringArray *aArray);
nsresult AddNewUsers();
nsresult AddValueToNewCard(nsIAbCard *aCard, nsString *aTagName, nsString *aTagValue);
PRBool TagHit(const char *aTag, PRBool advanceToNextLine); // See if we are sitting on a particular tag...and advance if asked
PRBool ErrorFromServer(char **errString); // Return true if the server returned an error...
nsresult ProcessOpReturn();
nsresult ProcessNewRecords();
nsresult ProcessDeletedRecords();
nsresult ProcessLastChange();
nsresult ProcessPhoneNumbersTheyAreSpecial(nsIAbCard *aCard);
PRInt32 GetTypeOfPhoneNumber(const nsAString& tagName);
nsresult AddValueToProtocolLine(const PRUnichar *value, nsString &protocolLine);
// For updating...
PRInt32 HuntForExistingABEntryInServerRecord(PRInt32 aPersonIndex,
nsIAddrDatabase *aDatabase,
nsIAbDirectory *directory,
PRInt32 *aServerID,
nsIAbCard **newCard);
nsresult FindCardByClientID(PRInt32 aClientID,
nsIAddrDatabase *aDatabase,
nsIAbDirectory *directory,
nsIAbCard **aReturnCard);
PRBool CardAlreadyInAddressBook(nsIAbCard *newCard,
PRInt32 *aClientID,
ulong *aRetCRC);
nsString mLocale; // Charset of returned data!
nsStringArray *mDeletedRecordTags; // The deleted record tags from the server...
nsStringArray *mDeletedRecordValues; // The deleted record values from the server...
nsStringArray *mNewRecordTags; // The new record tags from the server...
nsStringArray *mNewRecordValues; // The new record values from the server...
// Only support one column/value pair for now until #128567 is fixed to allow multiple pairs to be set.
nsCString mCurrentGenericColumn; // New generic column from server.
nsString mCurrentGenericValue; // New generic value from server.
nsStringArray *mPhoneTypes; // Phone number types...
nsStringArray *mPhoneValues; // Phone number values...
nsIDocShell *mRootDocShell; // For use in prompts
};
#endif /* __nsIAbSync_h__ */

View File

@@ -1,137 +0,0 @@
/******************************************************************************/
/* Start of crcmodel.c */
/******************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the implementation (.c) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/******************************************************************************/
/* */
/* Implementation Notes */
/* -------------------- */
/* To avoid inconsistencies, the specification of each function is not echoed */
/* here. See the header file for a description of these functions. */
/* This package is light on checking because I want to keep it short and */
/* simple and portable (i.e. it would be too messy to distribute my entire */
/* C culture (e.g. assertions package) with this package. */
/* */
/******************************************************************************/
#include "nsAbSyncCRCModel.h"
/******************************************************************************/
/* The following definitions make the code more readable. */
#define BITMASK(X) (1L << (X))
#define MASK32 0xFFFFFFFFL
#define LOCAL static
/******************************************************************************/
LOCAL ulong reflect P_((ulong v,int b));
LOCAL ulong reflect (ulong v, int b)
/* Returns the value v with the bottom b [0,32] bits reflected. */
/* Example: reflect(0x3e23L,3) == 0x3e26 */
{
int i;
ulong t = v;
for (i=0; i<b; i++)
{
if (t & 1L)
v|= BITMASK((b-1)-i);
else
v&= ~BITMASK((b-1)-i);
t>>=1;
}
return v;
}
/******************************************************************************/
LOCAL ulong widmask P_((p_cm_t));
LOCAL ulong widmask (p_cm_t p_cm)
/* Returns a longword whose value is (2^p_cm->cm_width)-1. */
/* The trick is to do this portably (e.g. without doing <<32). */
{
return (((1L<<(p_cm->cm_width-1))-1L)<<1)|1L;
}
/******************************************************************************/
void cm_ini (p_cm_t p_cm)
{
p_cm->cm_reg = p_cm->cm_init;
}
/******************************************************************************/
void cm_nxt (p_cm_t p_cm, int ch)
{
int i;
ulong uch = (ulong) ch;
ulong topbit = BITMASK(p_cm->cm_width-1);
if (p_cm->cm_refin) uch = reflect(uch,8);
p_cm->cm_reg ^= (uch << (p_cm->cm_width-8));
for (i=0; i<8; i++)
{
if (p_cm->cm_reg & topbit)
p_cm->cm_reg = (p_cm->cm_reg << 1) ^ p_cm->cm_poly;
else
p_cm->cm_reg <<= 1;
p_cm->cm_reg &= widmask(p_cm);
}
}
/******************************************************************************/
void cm_blk (p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len)
{
while (blk_len--) cm_nxt(p_cm,*blk_adr++);
}
/******************************************************************************/
ulong cm_crc (p_cm_t p_cm)
{
if (p_cm->cm_refot)
return p_cm->cm_xorot ^ reflect(p_cm->cm_reg,p_cm->cm_width);
else
return p_cm->cm_xorot ^ p_cm->cm_reg;
}
/******************************************************************************/
ulong cm_tab (p_cm_t p_cm,int index)
{
int i;
ulong r;
ulong topbit = BITMASK(p_cm->cm_width-1);
ulong inbyte = (ulong) index;
if (p_cm->cm_refin) inbyte = reflect(inbyte,8);
r = inbyte << (p_cm->cm_width-8);
for (i=0; i<8; i++)
if (r & topbit)
r = (r << 1) ^ p_cm->cm_poly;
else
r<<=1;
if (p_cm->cm_refin) r = reflect(r,p_cm->cm_width);
return r & widmask(p_cm);
}
/******************************************************************************/
/* End of crcmodel.c */
/******************************************************************************/

View File

@@ -1,149 +0,0 @@
/******************************************************************************/
/* Start of crcmodel.h */
/******************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the header (.h) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/******************************************************************************/
/* */
/* How to Use This Package */
/* ----------------------- */
/* Step 1: Declare a variable of type cm_t. Declare another variable */
/* (p_cm say) of type p_cm_t and initialize it to point to the first */
/* variable (e.g. p_cm_t p_cm = &cm_t). */
/* */
/* Step 2: Assign values to the parameter fields of the structure. */
/* If you don't know what to assign, see the document cited earlier. */
/* For example: */
/* p_cm->cm_width = 16; */
/* p_cm->cm_poly = 0x8005L; */
/* p_cm->cm_init = 0L; */
/* p_cm->cm_refin = TRUE; */
/* p_cm->cm_refot = TRUE; */
/* p_cm->cm_xorot = 0L; */
/* Note: Poly is specified without its top bit (18005 becomes 8005). */
/* Note: Width is one bit less than the raw poly width. */
/* */
/* Step 3: Initialize the instance with a call cm_ini(p_cm); */
/* */
/* Step 4: Process zero or more message bytes by placing zero or more */
/* successive calls to cm_nxt. Example: cm_nxt(p_cm,ch); */
/* */
/* Step 5: Extract the CRC value at any time by calling crc = cm_crc(p_cm); */
/* If the CRC is a 16-bit value, it will be in the bottom 16 bits. */
/* */
/******************************************************************************/
/* */
/* Design Notes */
/* ------------ */
/* PORTABILITY: This package has been coded very conservatively so that */
/* it will run on as many machines as possible. For example, all external */
/* identifiers have been restricted to 6 characters and all internal ones to */
/* 8 characters. The prefix cm (for Crc Model) is used as an attempt to avoid */
/* namespace collisions. This package is endian independent. */
/* */
/* EFFICIENCY: This package (and its interface) is not designed for */
/* speed. The purpose of this package is to act as a well-defined reference */
/* model for the specification of CRC algorithms. If you want speed, cook up */
/* a specific table-driven implementation as described in the document cited */
/* above. This package is designed for validation only; if you have found or */
/* implemented a CRC algorithm and wish to describe it as a set of parameters */
/* to the Rocksoft^tm Model CRC Algorithm, your CRC algorithm implementation */
/* should behave identically to this package under those parameters. */
/* */
/******************************************************************************/
/* The following #ifndef encloses this entire */
/* header file, rendering it indempotent. */
#ifndef CM_DONE
#define CM_DONE
#include "prtypes.h"
/******************************************************************************/
/* The following definitions are extracted from my style header file which */
/* would be cumbersome to distribute with this package. The DONE_STYLE is the */
/* idempotence symbol used in my style header file. */
typedef unsigned long ulong;
typedef unsigned char * p_ubyte_;
/* Change to the second definition if you don't have prototypes. */
#define P_(A) A
/* #define P_(A) () */
/* Uncomment this definition if you don't have void. */
/* typedef int void; */
/******************************************************************************/
/* CRC Model Abstract Type */
/* ----------------------- */
/* The following type stores the context of an executing instance of the */
/* model algorithm. Most of the fields are model parameters which must be */
/* set before the first initializing call to cm_ini. */
typedef struct
{
int cm_width; /* Parameter: Width in bits [8,32]. */
ulong cm_poly; /* Parameter: The algorithm's polynomial. */
ulong cm_init; /* Parameter: Initial register value. */
PRBool cm_refin; /* Parameter: Reflect input bytes? */
PRBool cm_refot; /* Parameter: Reflect output CRC? */
ulong cm_xorot; /* Parameter: XOR this to output CRC. */
ulong cm_reg; /* Context: Context during execution. */
} cm_t;
typedef cm_t *p_cm_t;
/******************************************************************************/
/* Functions That Implement The Model */
/* ---------------------------------- */
/* The following functions animate the cm_t abstraction. */
void cm_ini P_((p_cm_t p_cm));
/* Initializes the argument CRC model instance. */
/* All parameter fields must be set before calling this. */
void cm_nxt P_((p_cm_t p_cm,int ch));
/* Processes a single message byte [0,255]. */
void cm_blk P_((p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len));
/* Processes a block of message bytes. */
ulong cm_crc P_((p_cm_t p_cm));
/* Returns the CRC value for the message bytes processed so far. */
/******************************************************************************/
/* Functions For Table Calculation */
/* ------------------------------- */
/* The following function can be used to calculate a CRC lookup table. */
/* It can also be used at run-time to create or check static tables. */
ulong cm_tab P_((p_cm_t p_cm,int index));
/* Returns the i'th entry for the lookup table for the specified algorithm. */
/* The function examines the fields cm_width, cm_poly, cm_refin, and the */
/* argument table index in the range [0,255] and returns the table entry in */
/* the bottom cm_width bytes of the return value. */
/******************************************************************************/
/* End of the header file idempotence #ifndef */
#endif
/******************************************************************************/
/* End of crcmodel.h */
/******************************************************************************/

View File

@@ -1,864 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "msgCore.h" // for pre-compiled headers
#include "nsCOMPtr.h"
#include <stdio.h>
#include "nscore.h"
#include "prprf.h"
#include "nsEscape.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "comi18n.h"
#include "prmem.h"
#include "plstr.h"
#include "nsIPref.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsAbSyncPostEngine.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsNetUtil.h"
#include "nsMimeTypes.h"
#include "nsIHttpChannel.h"
#include "nsIUploadChannel.h"
#include "nsTextFormatter.h"
#include "nsICookieService.h"
#include "nsIAbSync.h"
#include "nsAbSyncCID.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
static NS_DEFINE_CID(kCAbSyncMojoCID, NS_AB_SYNC_MOJO_CID);
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
/*
* This function will be used by the factory to generate an
* object class object....
*/
NS_METHOD
nsAbSyncPostEngine::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsAbSyncPostEngine *ph = new nsAbSyncPostEngine();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
return ph->QueryInterface(aIID, aResult);
}
NS_IMPL_ADDREF(nsAbSyncPostEngine)
NS_IMPL_RELEASE(nsAbSyncPostEngine)
NS_INTERFACE_MAP_BEGIN(nsAbSyncPostEngine)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsIAbSyncPostEngine)
NS_INTERFACE_MAP_END
/*
* Inherited methods for nsMimeConverter
*/
nsAbSyncPostEngine::nsAbSyncPostEngine()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_ISUPPORTS();
// Init member variables...
mTotalWritten = 0;
mStillRunning = PR_TRUE;
mListenerArray = nsnull;
mListenerArrayCount = 0;
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
mTransactionID = 0;
mMessageSize = 0;
mAuthenticationRunning = PR_TRUE;
mCookie = nsnull;
mUser = nsnull;
mSyncProtocolRequest = nsnull;
mSyncProtocolRequestPrefix = nsnull;
mChannel = nsnull;
mMojoSyncSpec = nsnull;
}
nsAbSyncPostEngine::~nsAbSyncPostEngine()
{
mStillRunning = PR_FALSE;
PR_FREEIF(mSyncProtocolRequest);
PR_FREEIF(mSyncProtocolRequestPrefix);
PR_FREEIF(mCookie);
PR_FREEIF(mUser);
PR_FREEIF(mMojoSyncSpec);
DeleteListeners();
}
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
PRUint32& decoded_len);
/* ==================================================================
* Base64Encode
*
* Returns number of bytes that were encoded.
*
* >0 -> OK
* -1 -> BAD (output buffer not big enough).
*
* ==================================================================
*/
PRInt32 Base64Encode(const unsigned char *in_str, PRInt32 in_len, char *out_str,
PRInt32 out_len)
{
static unsigned char base64[] =
{
/* 0 1 2 3 4 5 6 7 */
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', /* 0 */
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', /* 1 */
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', /* 2 */
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', /* 3 */
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 4 */
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', /* 5 */
'w', 'x', 'y', 'z', '0', '1', '2', '3', /* 6 */
'4', '5', '6', '7', '8', '9', '+', '/' /* 7 */
};
PRInt32 curr_out_len = 0;
PRInt32 i = 0;
unsigned char a, b, c;
out_str[0] = '\0';
if (in_len > 0)
{
while (i < in_len)
{
a = in_str[i];
b = (i + 1 >= in_len) ? 0 : in_str[i + 1];
c = (i + 2 >= in_len) ? 0 : in_str[i + 2];
if (i + 2 < in_len)
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
+ ((c >> 6) & 0x3)]);
out_str[curr_out_len++] = (base64[c & 0x3F]);
}
else if (i + 1 < in_len)
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
+ ((c >> 6) & 0x3)]);
out_str[curr_out_len++] = '=';
}
else
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = '=';
out_str[curr_out_len++] = '=';
}
i += 3;
if((curr_out_len + 4) > out_len)
{
return(-1);
}
}
out_str[curr_out_len] = '\0';
}
return curr_out_len;
}
/*
* This routine decodes base64 string to a buffer.
* Populates 'out_str' with b64 decoded data.
*
* Returns number of bytes that were decoded.
* >0 -> OK
* -1 -> BAD (output buffer not big enough).
*/
PRInt32 Base64Decode(const char *in_str, unsigned char *out_str,
PRUint32* decoded_len)
{
return Base64Decode_int(in_str, out_str, *decoded_len);
}
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
PRUint32& decoded_len)
{
PRInt32 in_len = strlen (/*(char *)*/ in_str);
PRInt32 ii = 0;
PRInt32 a = 0;
char ch;
PRInt32 b1 = 0;
long b4 = 0;
PRInt32 nn = 0;
/* Decode remainder of base 64 string */
while (ii < in_len)
{
ch = in_str[ii++];
if (ch >= 'A' && ch <= 'Z') b1 = (ch - 'A');
else if (ch >= 'a' && ch <= 'z') b1 = 26 + (ch - 'a');
else if (ch >= '0' && ch <= '9') b1 = 52 + (ch - '0');
else if (ch == '+') b1 = 62;
else if (ch == '/') b1 = 63;
else if (ch == '\r' || ch == '\n') continue;
else
{
if (ch == '=')
{
if (nn == 3)
{
if ((a + 2) > (PRInt32) decoded_len)
return (-1); /* Bail. Buffer overflow */
b4 = (b4 << 6);
out_str[a++] = (char) (0xff & (b4 >> 16));
out_str[a++] = (char) (0xff & (b4 >> 8));
}
else if (nn == 2)
{
if ((a + 1) > (PRInt32) decoded_len)
{
return (-1); /* Bail. Buffer overflow */
}
b4 = (b4 << 12);
out_str[a++] = (char) (0xff & (b4 >> 16));
}
}
break;
}
b4 = (b4 << 6) | (long) b1;
nn++;
if (nn == 4)
{
if ((a + 3) > (PRInt32) decoded_len)
{
return (-1); /* Bail. Buffer overflow */
}
out_str[a++] = (char) (0xff & (b4 >> 16));
out_str[a++] = (char) (0xff & (b4 >> 8));
out_str[a++] = (char) (0xff & (b4));
nn = 0;
}
}
out_str[a] = '\0';
decoded_len = a;
return (a);
}
NS_IMETHODIMP nsAbSyncPostEngine::GetInterface(const nsIID & aIID, void * *aInstancePtr)
{
NS_ENSURE_ARG_POINTER(aInstancePtr);
return QueryInterface(aIID, aInstancePtr);
}
// nsIURIContentListener support
NS_IMETHODIMP
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
{
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
*aDesiredContentType = nsCRT::strdup("text/html");
// since we explicilty loaded the url, we always want to handle it!
*aCanHandleContent = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::DoContent(const char * aContentType,
PRBool aIsContentPreferred,
nsIRequest *request,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
nsresult rv = NS_OK;
if (aAbortProcess)
*aAbortProcess = PR_FALSE;
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetParentContentListener(nsIURIContentListener** aParent)
{
*aParent = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::SetParentContentListener(nsIURIContentListener* aParent)
{
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetLoadCookie(nsISupports ** aLoadCookie)
{
*aLoadCookie = mLoadCookie;
NS_IF_ADDREF(*aLoadCookie);
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::SetLoadCookie(nsISupports * aLoadCookie)
{
mLoadCookie = aLoadCookie;
return NS_OK;
}
nsresult
nsAbSyncPostEngine::StillRunning(PRBool *running)
{
*running = mStillRunning;
return NS_OK;
}
// Methods for nsIStreamListener...
nsresult
nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRUint32 readLen = aLength;
char *buf = (char *)PR_Malloc(aLength);
if (!buf)
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
// read the data from the input stram...
nsresult rv = aIStream->Read(buf, aLength, &readLen);
if (NS_FAILED(rv)) return rv;
// write to the protocol response buffer...
mProtocolResponse.Append(NS_ConvertASCIItoUCS2(buf, readLen));
PR_FREEIF(buf);
mTotalWritten += readLen;
if (!mAuthenticationRunning)
NotifyListenersOnProgress(mTransactionID, mTotalWritten, 0);
return NS_OK;
}
// Methods for nsIRequestObserver
nsresult
nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
if (mAuthenticationRunning)
NotifyListenersOnStartAuthOperation();
else
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
{
#ifdef NS_DEBUG_rhp
printf("nsAbSyncPostEngine::OnStopRequest()\n");
#endif
char *tProtResponse = nsnull;
//
// Now complete the stream!
//
mStillRunning = PR_FALSE;
// Check the content type!
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (channel)
{
nsCAutoString contentType;
nsCAutoString charset;
if (NS_SUCCEEDED(channel->GetContentType(contentType)) &&
!contentType.Equals(NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE)))
{
mContentType = contentType;
}
if (NS_SUCCEEDED(channel->GetContentCharset(charset)) && !charset.IsEmpty())
{
mCharset = charset;
}
}
// set the state...
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
if (mAuthenticationRunning)
{
nsresult rv;
if (mSyncMojo)
rv = mSyncMojo->GetAbSyncMojoResults(&mUser, &mCookie, &mMojoSyncSpec, &mMojoSyncPort);
if (NS_SUCCEEDED(rv))
{
// Before we really get started...lets let sync know who is doing this...
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_SUCCEEDED(rv) || sync)
sync->SetAbSyncUser(mUser);
// Base64 encode then url encode it...
//
char tUser[256] = "";
if (Base64Encode((unsigned char *)mUser, strlen(mUser), tUser, sizeof(tUser)) < 0)
{
rv = NS_ERROR_FAILURE;
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
else
{
char *tUser2 = nsEscape(tUser, url_Path);
if (!tUser2)
{
rv = NS_ERROR_FAILURE;
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
else
{
mSyncProtocolRequestPrefix = PR_smprintf("cn=%s&cc=%s&", tUser2, mCookie);
PR_FREEIF(tUser2);
NotifyListenersOnStopAuthOperation(aStatus, tProtResponse);
KickTheSyncOperation();
}
}
// RICHIE - Special here to show the server we are hitting!
// RICHIE - REMOVE THIS BEFORE SHIPPING!!!!
#ifdef DEBUG
PRUnichar *msgValue = nsnull;
msgValue = nsTextFormatter::smprintf(nsString(NS_LITERAL_STRING("Server: %s - port %d")).get(),
mMojoSyncSpec, mMojoSyncPort);
NotifyListenersOnStatus(mTransactionID, msgValue);
PR_FREEIF(msgValue);
// RICHIE
#endif
}
else
{
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
mSyncMojo = nsnull;
}
else
{
tProtResponse = ToNewCString(mProtocolResponse);
NotifyListenersOnStopSending(mTransactionID, aStatus, tProtResponse);
}
PR_FREEIF(tProtResponse);
// Time to return...
return NS_OK;
}
/* void AddSyncListener (in nsIAbSyncPostListener aListener); */
NS_IMETHODIMP nsAbSyncPostEngine::AddPostListener(nsIAbSyncPostListener *aListener)
{
if ( (mListenerArrayCount > 0) || mListenerArray )
{
++mListenerArrayCount;
mListenerArray = (nsIAbSyncPostListener **)
PR_Realloc(*mListenerArray, sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
if (!mListenerArray)
return NS_ERROR_OUT_OF_MEMORY;
else
{
mListenerArray[mListenerArrayCount - 1] = aListener;
return NS_OK;
}
}
else
{
mListenerArrayCount = 1;
mListenerArray = (nsIAbSyncPostListener **) PR_Malloc(sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
if (!mListenerArray)
return NS_ERROR_OUT_OF_MEMORY;
memset(mListenerArray, 0, (sizeof(nsIAbSyncPostListener *) * mListenerArrayCount));
mListenerArray[0] = aListener;
NS_ADDREF(mListenerArray[0]);
return NS_OK;
}
}
/* void RemoveSyncListener (in nsIAbSyncPostListener aListener); */
NS_IMETHODIMP nsAbSyncPostEngine::RemovePostListener(nsIAbSyncPostListener *aListener)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] == aListener)
{
NS_RELEASE(mListenerArray[i]);
mListenerArray[i] = nsnull;
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
nsresult
nsAbSyncPostEngine::DeleteListeners()
{
if ( (mListenerArray) && (*mListenerArray) )
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
{
NS_RELEASE(mListenerArray[i]);
}
PR_FREEIF(mListenerArray);
}
mListenerArrayCount = 0;
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStartAuthOperation(void)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStartAuthOperation();
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStopAuthOperation(aStatus, nsnull, aCookie);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStartOperation(aTransactionID, aMsgSize);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnProgress(aTransactionID, aProgress, aProgressMax);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStatus(aTransactionID, aMsg);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
char *aProtocolResponse)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStopOperation(aTransactionID, aStatus, nsnull, aProtocolResponse);
return NS_OK;
}
// Utility to create a nsIURI object...
extern "C" nsresult
nsEngineNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
{
nsresult res;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIIOService> pService(do_GetService(kIOServiceCID, &res));
if (NS_FAILED(res))
return NS_ERROR_FACTORY_NOT_REGISTERED;
return pService->NewURI(nsDependentCString(aSpec), nsnull, aBase, aInstancePtrResult);
}
nsresult
nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
{
nsresult rv;
nsCOMPtr<nsIInputStream> postStream;
if (!postData)
return NS_ERROR_INVALID_ARG;
NS_ENSURE_SUCCESS(NS_NewChannel(getter_AddRefs(mChannel), aURL, nsnull), NS_ERROR_FAILURE);
// Tag the post stream onto the channel...but never seemed to work...so putting it
// directly on the URL spec
//
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (!httpChannel)
return NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, nsDependentCString(postData), 0))){
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
uploadChannel->SetUploadStream(postStream, nsnull, -1);
}
httpChannel->AsyncOpen(this, nsnull);
return NS_OK;
}
/* PRInt32 GetCurrentState (); */
NS_IMETHODIMP nsAbSyncPostEngine::GetCurrentState(PRInt32 *_retval)
{
*_retval = mPostEngineState;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////////////
//
// This is the implementation of the actual post driver.
//
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsAbSyncPostEngine::BuildMojoString(nsIDocShell *aRootDocShell, char **aID)
{
nsresult rv;
if (!aID)
return NS_ERROR_FAILURE;
// Now, get the COMPtr to the Mojo!
if (!mSyncMojo)
{
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
if ( NS_FAILED(rv) || (!mSyncMojo) )
return NS_ERROR_FAILURE;
}
rv = mSyncMojo->BuildMojoString(aRootDocShell, aID);
return rv;
}
NS_IMETHODIMP nsAbSyncPostEngine::SendAbRequest(const char *aSpec, PRInt32 aPort, const char *aProtocolRequest, PRInt32 aTransactionID,
nsIDocShell *aDocShell, const char *aUser)
{
nsresult rv;
char *mojoUser = nsnull;
char *mojoSnack = nsnull;
// Only try if we are not currently busy!
if (mPostEngineState != nsIAbSyncPostEngineState::nsIAbSyncPostIdle)
return NS_ERROR_FAILURE;
// Now, get the COMPtr to the Mojo!
if (!mSyncMojo)
{
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
if ( NS_FAILED(rv) || (!mSyncMojo) )
return NS_ERROR_FAILURE;
}
if (aUser)
mUser = nsCRT::strdup(aUser);
if (NS_FAILED(mSyncMojo->StartAbSyncMojo(this, aDocShell, mUser)))
return NS_ERROR_FAILURE;
// Set transaction ID and save/init Sync info...
mTransactionID = aTransactionID;
// Init stuff we need....
mSyncProtocolRequest = nsCRT::strdup(aProtocolRequest);
mProtocolResponse.Truncate();
mTotalWritten = 0;
// The first thing we need to do is authentication so do it!
mAuthenticationRunning = PR_TRUE;
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncAuthenticationRunning;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::KickTheSyncOperation(void)
{
nsresult rv;
nsIURI *workURI = nsnull;
char *protString = nsnull;
// The first thing we need to do is authentication so do it!
mAuthenticationRunning = PR_FALSE;
mProtocolResponse.Truncate();
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
const char postHeader[] = "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\nCookie: %s\r\n\r\n%s";
protString = PR_smprintf("%s%s", mSyncProtocolRequestPrefix, mSyncProtocolRequest);
if (protString)
mMessageSize = strlen(protString);
else
mMessageSize = 0;
char *tCommand = PR_smprintf(postHeader, mMessageSize, mCookie, protString);
PR_FREEIF(protString);
#ifdef DEBUG_rhp
printf("COMMAND = %s\n", tCommand);
#endif
if (!tCommand)
{
rv = NS_ERROR_OUT_OF_MEMORY; // we couldn't allocate the string
goto GetOuttaHere;
}
rv = nsEngineNewURI(&workURI, mMojoSyncSpec, nsnull);
if (NS_FAILED(rv) || (!workURI))
{
rv = NS_ERROR_FAILURE; // we couldn't allocate the string
goto GetOuttaHere;
}
if (mMojoSyncPort > 0)
workURI->SetPort(mMojoSyncPort);
rv = FireURLRequest(workURI, tCommand);
if (NS_SUCCEEDED(rv))
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
GetOuttaHere:
NS_IF_RELEASE(workURI);
PR_FREEIF(tCommand);
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::CancelAbSync()
{
nsresult rv = NS_ERROR_FAILURE;
if (mSyncMojo)
{
rv = mSyncMojo->CancelTheMojo();
}
else if (mChannel)
{
rv = mChannel->Cancel(NS_BINDING_ABORTED);
}
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetMojoUserAndSnack(char **aMojoUser, char **aMojoSnack)
{
if ( (!mUser) || (!mCookie) )
return NS_ERROR_FAILURE;
*aMojoUser = nsCRT::strdup(mUser);
*aMojoSnack = nsCRT::strdup(mCookie);
if ( (!*aMojoUser) || (!*aMojoSnack) )
return NS_ERROR_FAILURE;
else
return NS_OK;
}

View File

@@ -1,135 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAbSyncPostEngine_h_
#define nsAbSyncPostEngine_h_
#include "nsCOMPtr.h"
#include "nsIInputStream.h"
#include "nsIStreamListener.h"
#include "nsFileStream.h"
#include "nsIAbSyncPostEngine.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCURILoader.h"
#include "nsIURIContentListener.h"
#include "nsIURI.h"
#include "nsIAbSyncMojo.h"
#include "nsIChannel.h"
//
// Callback declarations for URL completion
//
// For completion of send/message creation operations...
//
typedef nsresult (*nsPostCompletionCallback ) (nsresult aStatus,
const char *aContentType,
const char *aCharset,
PRInt32 totalSize, const PRUnichar* aMsg,
void *tagData);
class nsAbSyncPostEngine : public nsIAbSyncPostEngine, public nsIStreamListener, public nsIURIContentListener, public nsIInterfaceRequestor {
public:
nsAbSyncPostEngine();
virtual ~nsAbSyncPostEngine();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNCPOSTENGINE
//
// This is the output stream where the stream converter will write processed data after
// conversion.
//
NS_IMETHOD StillRunning(PRBool *running);
NS_IMETHOD FireURLRequest(nsIURI *aURL, const char *postData);
NS_IMETHOD KickTheSyncOperation();
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// Methods for nsIStreamListener
NS_DECL_NSISTREAMLISTENER
// Methods for nsIStreamObserver
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
PRInt32 mPostEngineState;
PRInt32 mTransactionID;
private:
// Handy methods for listeners...
nsresult DeleteListeners();
nsresult NotifyListenersOnStartAuthOperation(void);
nsresult NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie);
nsresult NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize);
nsresult NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax);
nsresult NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg);
nsresult NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
char *aProtocolResponse);
PRBool mStillRunning; // Are we still running?
PRInt32 mTotalWritten; // Size counter variable
nsString mProtocolResponse; // Protocol response
nsCString mContentType; // The content type retrieved from the server
nsCString mCharset; // The charset retrieved from the server
nsCOMPtr<nsISupports> mLoadCookie; // load cookie used by the uri loader when we post the url
char *mCookie;
char *mUser;
char *mAuthSpec;
PRInt32 mMessageSize; // Size of POST request...
nsIAbSyncPostListener **mListenerArray;
PRInt32 mListenerArrayCount;
// Since we need to do authentication a bit differently, do it here!
PRBool mAuthenticationRunning;
nsCOMPtr<nsIAbSyncMojo> mSyncMojo;
nsCOMPtr<nsIChannel> mChannel;
char *mSyncProtocolRequest;
char *mSyncProtocolRequestPrefix;
char *mMojoSyncSpec;
PRInt32 mMojoSyncPort;
};
#endif /* nsAbSyncPostEngine_h_ */

View File

@@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAbSync.h"
#include "prmem.h"
#include "nsAbSyncCID.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsEscape.h"
#include "nsSyncDecoderRing.h"
nsSyncDecoderRing::nsSyncDecoderRing()
{
}
nsSyncDecoderRing::~nsSyncDecoderRing()
{
}

View File

@@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsSyncDecoderRing_h__
#define __nsSyncDecoderRing_h__
#include "nsIAbSync.h"
#include "nsIAbSyncPostListener.h"
#include "nsIAbSyncPostEngine.h"
#include "nsCOMPtr.h"
#include "nsIAddrDatabase.h"
#include "nsIAbDirectory.h"
#include "nsAbSyncCRCModel.h"
// Server record fields!
#define kServerFirstNameColumn NS_LITERAL_STRING("fname")
#define kServerLastNameColumn NS_LITERAL_STRING("lname")
#define kServerDisplayNameColumn NS_LITERAL_STRING("Display_name")
#define kServerNicknameColumn NS_LITERAL_STRING("nick_name")
#define kServerPriEmailColumn NS_LITERAL_STRING("email1")
#define kServer2ndEmailColumn NS_LITERAL_STRING("email2")
#define kServerPlainTextColumn NS_LITERAL_STRING("Pref_rich_email")
#define kServerWorkPhoneColumn NS_LITERAL_STRING("work_phone")
#define kServerHomePhoneColumn NS_LITERAL_STRING("home_phone")
#define kServerFaxColumn NS_LITERAL_STRING("fax")
#define kServerPagerColumn NS_LITERAL_STRING("pager")
#define kServerCellularColumn NS_LITERAL_STRING("cell_phone")
#define kServerHomeAddressColumn NS_LITERAL_STRING("home_add1")
#define kServerHomeAddress2Column NS_LITERAL_STRING("home_add2")
#define kServerHomeCityColumn NS_LITERAL_STRING("home_city")
#define kServerHomeStateColumn NS_LITERAL_STRING("home_state")
#define kServerHomeZipCodeColumn NS_LITERAL_STRING("home_zip")
#define kServerHomeCountryColumn NS_LITERAL_STRING("home_country")
#define kServerWorkAddressColumn NS_LITERAL_STRING("work_add1")
#define kServerWorkAddress2Column NS_LITERAL_STRING("work_add2")
#define kServerWorkCityColumn NS_LITERAL_STRING("work_city")
#define kServerWorkStateColumn NS_LITERAL_STRING("work_state")
#define kServerWorkZipCodeColumn NS_LITERAL_STRING("work_zip")
#define kServerWorkCountryColumn NS_LITERAL_STRING("work_country")
#define kServerJobTitleColumn NS_LITERAL_STRING("job_title")
#define kServerDepartmentColumn NS_LITERAL_STRING("department")
#define kServerCompanyColumn NS_LITERAL_STRING("company")
#define kServerWebPage1Column NS_LITERAL_STRING("Work_web_page")
#define kServerWebPage2Column NS_LITERAL_STRING("web_page")
#define kServerBirthYearColumn NS_LITERAL_STRING("OMIT:BirthYear")
#define kServerBirthMonthColumn NS_LITERAL_STRING("OMIT:BirthMonth")
#define kServerBirthDayColumn NS_LITERAL_STRING("OMIT:BirthDay")
#define kServerCustom1Column NS_LITERAL_STRING("Custom_1")
#define kServerCustom2Column NS_LITERAL_STRING("Custom_2")
#define kServerCustom3Column NS_LITERAL_STRING("Custom_3")
#define kServerCustom4Column NS_LITERAL_STRING("Custom_4")
#define kServerNotesColumn NS_LITERAL_STRING("addl_info")
#define kServerLastModifiedDateColumn NS_LITERAL_STRING("OMIT:LastModifiedDate")
class nsSyncDecoderRing
{
public:
nsSyncDecoderRing();
virtual ~nsSyncDecoderRing();
};
#endif /* __nsSyncDecoderRing_h__ */

View File

@@ -1,37 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifdef MOZ_LDAP_XPCOM
REQUIRES += mozldap necko
EXTRA_COMPONENTS += src/nsLDAPPrefsService.js
endif
DIRS = public src build
include $(topsrcdir)/config/rules.mk

View File

@@ -1,21 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
nsAbBaseCID.h

View File

@@ -1,84 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = addrbook
LIBRARY_NAME = addrbook
META_COMPONENT = mail
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsAbModule
REQUIRES = xpcom \
string \
necko \
mime \
rdf \
msgbase \
msgbaseutil \
rdfutil \
docshell \
appshell \
dom \
widget \
locale \
mork \
appcomps \
layout \
intl \
$(NULL)
CPPSRCS = nsAbFactory.cpp
EXPORTS = nsAbBaseCID.h
ifdef MOZ_LDAP_XPCOM
REQUIRES += mozldap \
uriloader \
$(NULL)
DEFINES += -DMOZ_LDAP_XPCOM
endif
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)addrbook_s.$(LIB_SUFFIX) \
$(NULL)
EXTRA_DSO_LIBS = rdfutil_s
ifeq ($(USE_SHORT_LIBNAME),1)
EXTRA_DSO_LIBS += msgbsutl
else
EXTRA_DSO_LIBS += msgbaseutil
endif
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,447 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAbBaseCID_h__
#define nsAbBaseCID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
#include "nsAbDirFactoryService.h"
//
// nsAddressBook
//
#define NS_ADDRESSBOOK_CONTRACTID \
"@mozilla.org/addressbook;1"
#define NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID \
"@mozilla.org/commandlinehandler/general-startup;1?type=addressbook"
#define NS_ADDRESSBOOK_CID \
{ /* {D60B84F2-2A8C-11d3-9E07-00A0C92B5F0D} */ \
0xd60b84f2, 0x2a8c, 0x11d3, \
{ 0x9e, 0x7, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd } \
}
//
// nsAbDirectoryDataSource
//
#define NS_ABDIRECTORYDATASOURCE_CONTRACTID \
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "addressdirectory"
#define NS_ABDIRECTORYDATASOURCE_CID \
{ /* 0A79186D-F754-11d2-A2DA-001083003D0C */ \
0xa79186d, 0xf754, 0x11d2, \
{0xa2, 0xda, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
}
//
// nsAbBSDirectory
//
#define NS_ABDIRECTORY_CONTRACTID \
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-abdirectory"
#define NS_ABDIRECTORY_CID \
{ /* {012D3C24-1DD2-11B2-BA79-B4AD359FC461}*/ \
0x012D3C24, 0x1DD2, 0x11B2, \
{0xBA, 0x79, 0xB4, 0xAD, 0x35, 0x9F, 0xC4, 0x61} \
}
//
// nsAbMDBDirectory
//
#define NS_ABMDBDIRECTORY_CONTRACTID \
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-abmdbdirectory"
#define NS_ABMDBDIRECTORY_CID \
{ /* {e618f894-1dd1-11b2-889c-9aaefaa90dde}*/ \
0xe618f894, 0x1dd1, 0x11b2, \
{0x88, 0x9c, 0x9a, 0xae, 0xfa, 0xa9, 0x0d, 0xde} \
}
//
// nsAbMDBCard
//
#define NS_ABMDBCARD_CONTRACTID \
"@mozilla.org/addressbook/moz-abmdbcard;1"
#define NS_ABMDBCARD_CID \
{ /* {f578a5d2-1dd1-11b2-8841-f45cc5e765f8} */ \
0xf578a5d2, 0x1dd1, 0x11b2, \
{0x88, 0x41, 0xf4, 0x5c, 0xc5, 0xe7, 0x65, 0xf8} \
}
//
// nsAddressBookDB
//
#define NS_ADDRDATABASE_CONTRACTID \
"@mozilla.org/addressbook/carddatabase;1"
#define NS_ADDRDATABASE_CID \
{ /* 63187917-1D19-11d3-A302-001083003D0C */ \
0x63187917, 0x1d19, 0x11d3, \
{0xa3, 0x2, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
}
//
// nsAbCardProperty
//
#define NS_ABCARDPROPERTY_CONTRACTID \
"@mozilla.org/addressbook/cardproperty;1"
#define NS_ABCARDPROPERTY_CID \
{ /* 2B722171-2CEA-11d3-9E0B-00A0C92B5F0D */ \
0x2b722171, 0x2cea, 0x11d3, \
{0x9e, 0xb, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd} \
}
//
// nsAddrBookSession
//
#define NS_ADDRBOOKSESSION_CONTRACTID \
"@mozilla.org/addressbook/services/session;1"
#define NS_ADDRBOOKSESSION_CID \
{ /* C5339442-303F-11d3-9E13-00A0C92B5F0D */ \
0xc5339442, 0x303f, 0x11d3, \
{0x9e, 0x13, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd} \
}
//
// nsAbDirProperty
//
#define NS_ABDIRPROPERTY_CONTRACTID \
"@mozilla.org/addressbook/directoryproperty;1"
#define NS_ABDIRPROPERTY_CID \
{ /* 6FD8EC67-3965-11d3-A316-001083003D0C */ \
0x6fd8ec67, 0x3965, 0x11d3, \
{0xa3, 0x16, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
}
//
// nsAbDirectoryProperties
//
#define NS_ABDIRECTORYPROPERTIES_CONTRACTID \
"@mozilla.org/addressbook/properties;1"
#define NS_ABDIRECTORYPROPERTIES_CID \
{ /* 8b00a972-1dd2-11b2-9d9c-9c377a9c3dba */ \
0x8b00a972, 0x1dd2, 0x11b2, \
{0x9d, 0x9c, 0x9c, 0x37, 0x7a, 0x9c, 0x3d, 0xba} \
}
//
// nsAbAutoCompleteSession
//
#define NS_ABAUTOCOMPLETESESSION_CONTRACTID \
"@mozilla.org/autocompleteSession;1?type=addrbook"
#define NS_ABAUTOCOMPLETESESSION_CID \
{ /* 138DE9BD-362B-11d3-988E-001083010E9B */ \
0x138de9bd, 0x362b, 0x11d3, \
{0x98, 0x8e, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b} \
}
//
// nsAbAddressCollecter
//
#define NS_ABADDRESSCOLLECTER_CONTRACTID \
"@mozilla.org/addressbook/services/addressCollecter;1"
#define NS_ABADDRESSCOLLECTER_CID \
{ /* fe04c8e6-501e-11d3-a527-0060b0fc04b7 */ \
0xfe04c8e6, 0x501e, 0x11d3, \
{0xa5, 0x27, 0x0, 0x60, 0xb0, 0xfc, 0x4, 0xb7} \
}
#define NS_AB4xUPGRADER_CONTRACTID \
"@mozilla.org/addressbook/services/4xUpgrader;1"
#define NS_AB4xUPGRADER_CID \
{ /* 0a6ae8e6-f550-11d3-a563-0060b0fc04b7 */ \
0x0a6ae8e6, 0xf550, 0x11d3, \
{0xa5, 0x63, 0x00, 0x60, 0xb0, 0xfc, 0x4, 0xb7} \
}
//
// addbook URL
//
#define NS_ADDBOOKURL_CONTRACTID \
"@mozilla.org/addressbook/services/url;1?type=addbook"
#define NS_ADDBOOKURL_CID \
{ /* ff04c8e6-501e-11d3-a527-0060b0fc0444 */ \
0xff04c8e6, 0x501e, 0x11d3, \
{0xa5, 0x27, 0x0, 0x60, 0xb0, 0xfc, 0x4, 0x44} \
}
//
// addbook Protocol Handler
//
#define NS_ADDBOOK_HANDLER_CONTRACTID \
"@mozilla.org/addressbook/services/addbook;1"
#define NS_ADDBOOK_HANDLER_CID \
{ /* ff04c8e6-501e-11d3-ffcc-0060b0fc0444 */ \
0xff04c8e6, 0x501e, 0x11d3, \
{0xff, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x4, 0x44} \
}
//
// directory factory service
//
#define NS_ABDIRFACTORYSERVICE_CONTRACTID \
"@mozilla.org/addressbook/directory-factory-service;1"
#define NS_ABDIRFACTORYSERVICE_CID \
{ /* {F8B212F2-742B-4A48-B7A0-4C44D4DDB121}*/ \
0xF8B212F2, 0x742B, 0x4A48, \
{0xB7, 0xA0, 0x4C, 0x44, 0xD4, 0xDD, 0xB1, 0x21} \
}
//
// mdb directory factory
//
#define NS_ABMDBDIRFACTORY_CONTRACTID \
NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "moz-abmdbdirectory"
#define NS_ABMDBDIRFACTORY_CID \
{ /* {E1CB9C8A-722D-43E4-9D7B-7CCAE4B0338A}*/ \
0xE1CB9C8A, 0x722D, 0x43E4, \
{0x9D, 0x7B, 0x7C, 0xCA, 0xE4, 0xB0, 0x33, 0x8A} \
}
#ifdef XP_WIN
//
// nsAbOutlookDirectory
//
#define NS_ABOUTLOOKDIRECTORY_CONTRACTID \
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-aboutlookdirectory"
#define NS_ABOUTLOOKDIRECTORY_CID \
{ /* {9cc57822-0599-4c47-a399-1c6fa185a05c}*/ \
0x9cc57822, 0x0599, 0x4c47, \
{0xa3, 0x99, 0x1c, 0x6f, 0xa1, 0x85, 0xa0, 0x5c} \
}
//
// nsAbOutlookCard
//
#define NS_ABOUTLOOKCARD_CONTRACTID \
"@mozilla.org/addressbook/moz-aboutlookcard"
#define NS_ABOUTLOOKCARD_CID \
{ /* {32cf9734-4ee8-4f5d-acfc-71b75eee1819}*/ \
0x32cf9734, 0x4ee8, 0x4f5d, \
{0xac, 0xfc, 0x71, 0xb7, 0x5e, 0xee, 0x18, 0x19} \
}
//
// Outlook directory factory
//
#define NS_ABOUTLOOKDIRFACTORY_CONTRACTID \
NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "moz-aboutlookdirectory"
#define NS_ABOUTLOOKDIRFACTORY_CID \
{ /* {558ccc0f-2681-4dac-a066-debd8d26faf6}*/ \
0x558ccc0f, 0x2681, 0x4dac, \
{0xa0, 0x66, 0xde, 0xbd, 0x8d, 0x26, 0xfa, 0xf6} \
}
#endif
//
// Addressbook Query support
//
#define NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID \
"@mozilla.org/addressbook/directory/query-arguments;1"
#define NS_ABDIRECTORYQUERYARGUMENTS_CID \
{ /* {f7dc2aeb-8e62-4750-965c-24b9e09ed8d2} */ \
0xf7dc2aeb, 0x8e62, 0x4750, \
{ 0x96, 0x5c, 0x24, 0xb9, 0xe0, 0x9e, 0xd8, 0xd2 } \
}
#define NS_BOOLEANCONDITIONSTRING_CONTRACTID \
"@mozilla.org/boolean-expression/condition-string;1"
#define NS_BOOLEANCONDITIONSTRING_CID \
{ /* {ca1944a9-527e-4c77-895d-d0466dd41cf5} */ \
0xca1944a9, 0x527e, 0x4c77, \
{ 0x89, 0x5d, 0xd0, 0x46, 0x6d, 0xd4, 0x1c, 0xf5 } \
}
#define NS_BOOLEANEXPRESSION_CONTRACTID \
"@mozilla.org/boolean-expression/n-peer;1"
#define NS_BOOLEANEXPRESSION_CID \
{ /* {2c2e75c8-6f56-4a50-af1c-72af5d0e8d41} */ \
0x2c2e75c8, 0x6f56, 0x4a50, \
{ 0xaf, 0x1c, 0x72, 0xaf, 0x5d, 0x0e, 0x8d, 0x41 } \
}
#define NS_ABDIRECTORYQUERYPROXY_CONTRACTID \
"@mozilla.org/addressbook/directory-query/proxy;1"
#define NS_ABDIRECTORYQUERYPROXY_CID \
{ /* {E162E335-541B-43B4-AAEA-FE591E240CAF}*/ \
0xE162E335, 0x541B, 0x43B4, \
{0xAA, 0xEA, 0xFE, 0x59, 0x1E, 0x24, 0x0C, 0xAF} \
}
// nsAbLDAPDirectory
//
#define NS_ABLDAPDIRECTORY_CONTRACTID \
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-abldapdirectory"
#define NS_ABLDAPDIRECTORY_CID \
{ /* {783E2777-66D7-4826-9E4B-8AB58C228A52}*/ \
0x783E2777, 0x66D7, 0x4826, \
{0x9E, 0x4B, 0x8A, 0xB5, 0x8C, 0x22, 0x8A, 0x52} \
}
//
// nsAbLDAPCard
//
#define NS_ABLDAPCARD_CONTRACTID \
"@mozilla.org/addressbook/moz-abldapcard"
#define NS_ABLDAPCARD_CID \
{ /* {10307B01-EBD6-465F-B972-1630410F70E6}*/ \
0x10307B01, 0xEBD6, 0x465F, \
{0xB9, 0x72, 0x16, 0x30, 0x41, 0x0F, 0x70, 0xE6} \
}
//
// LDAP directory factory
//
#define NS_ABLDAPDIRFACTORY_CONTRACTID \
NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "moz-abldapdirectory"
#define NS_ABLDAPDIRFACTORY_CID \
{ /* {8e3701af-8828-426c-84ac-124825c778f8} */ \
0x8e3701af, 0x8828, 0x426c, \
{0x84, 0xac, 0x12, 0x48, 0x25, 0xc7, 0x78, 0xf8} \
}
//
// LDAP autcomplete directory factory
//
#define NS_ABLDAPACDIRFACTORY_CONTRACTID \
NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "ldap"
#define NS_ABLDAPSACDIRFACTORY_CONTRACTID \
NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "ldaps"
// nsAbLDAPAutoCompFormatter
// 4e276d6d-9981-46b4-9070-92f344ac5f5a
//
#define NS_ABLDAPAUTOCOMPFORMATTER_CID \
{ 0x4e276d6d, 0x9981, 0x46b4, \
{ 0x90, 0x70, 0x92, 0xf3, 0x44, 0xac, 0x5f, 0x5a }}
#define NS_ABLDAPAUTOCOMPFORMATTER_CONTRACTID \
"@mozilla.org/ldap-autocomplete-formatter;1?type=addrbook"
// nsAbLDAPReplicationService
//
// {ece81280-2639-11d6-b791-00b0d06e5f27}
//
#define NS_ABLDAP_REPLICATIONSERVICE_CID \
{0xece81280, 0x2639, 0x11d6, \
{ 0xb7, 0x91, 0x00, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 }}
#define NS_ABLDAP_REPLICATIONSERVICE_CONTRACTID \
"@mozilla.org/addressbook/ldap-replication-service;1"
// nsAbLDAPReplicationQuery
//
// {5414fff0-263b-11d6-b791-00b0d06e5f27}
//
#define NS_ABLDAP_REPLICATIONQUERY_CID \
{0x5414fff0, 0x263b, 0x11d6, \
{ 0xb7, 0x91, 0x00, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 }}
#define NS_ABLDAP_REPLICATIONQUERY_CONTRACTID \
"@mozilla.org/addressbook/ldap-replication-query;1"
// nsAbLDAPChangeLogQuery
//
// {63E11D51-3C9B-11d6-B7B9-00B0D06E5F27}
#define NS_ABLDAP_CHANGELOGQUERY_CID \
{0x63e11d51, 0x3c9b, 0x11d6, \
{ 0xb7, 0xb9, 0x0, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 }}
#define NS_ABLDAP_CHANGELOGQUERY_CONTRACTID \
"@mozilla.org/addressbook/ldap-changelog-query;1"
// nsAbLDAPProcessReplicationData
//
// {5414fff1-263b-11d6-b791-00b0d06e5f27}
//
#define NS_ABLDAP_PROCESSREPLICATIONDATA_CID \
{0x5414fff1, 0x263b, 0x11d6, \
{ 0xb7, 0x91, 0x00, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 }}
#define NS_ABLDAP_PROCESSREPLICATIONDATA_CONTRACTID \
"@mozilla.org/addressbook/ldap-process-replication-data;1"
// nsAbLDAPProcessChangeLogData
//
// {63E11D52-3C9B-11d6-B7B9-00B0D06E5F27}
#define NS_ABLDAP_PROCESSCHANGELOGDATA_CID \
{0x63e11d52, 0x3c9b, 0x11d6, \
{0xb7, 0xb9, 0x0, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 }}
#define NS_ABLDAP_PROCESSCHANGELOGDATA_CONTRACTID \
"@mozilla.org/addressbook/ldap-process-changelog-data;1"
// nsABView
#define NS_ABVIEW_CID \
{ 0xc5eb5d6a, 0x1dd1, 0x11b2, \
{ 0xa0, 0x25, 0x94, 0xd1, 0x18, 0x1f, 0xc5, 0x9c }}
#define NS_ABVIEW_CONTRACTID \
"@mozilla.org/addressbook/abview;1"
#endif // nsAbBaseCID_h__

View File

@@ -1,325 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998,1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsAbBaseCID.h"
#include "pratom.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "rdf.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsDirectoryDataSource.h"
#include "nsAbBSDirectory.h"
#include "nsAbMDBDirectory.h"
#include "nsAbMDBCard.h"
#include "nsAbDirFactoryService.h"
#include "nsAbMDBDirFactory.h"
#include "nsAddrDatabase.h"
#include "nsAddressBook.h"
#include "nsAddrBookSession.h"
#include "nsAbDirProperty.h"
#include "nsAbAutoCompleteSession.h"
#include "nsAbAddressCollecter.h"
#include "nsAddbookProtocolHandler.h"
#include "nsAddbookUrl.h"
#ifdef XP_WIN
#include "nsAbOutlookDirectory.h"
#include "nsAbOutlookCard.h"
#include "nsAbOutlookDirFactory.h"
#endif
#include "nsAbDirectoryQuery.h"
#include "nsAbBooleanExpression.h"
#include "nsAbDirectoryQueryProxy.h"
#include "nsAbView.h"
#if defined(MOZ_LDAP_XPCOM)
#include "nsAbLDAPDirectory.h"
#include "nsAbLDAPCard.h"
#include "nsAbLDAPDirFactory.h"
#include "nsAbLDAPAutoCompFormatter.h"
#include "nsAbLDAPReplicationService.h"
#include "nsAbLDAPReplicationQuery.h"
#include "nsAbLDAPReplicationData.h"
#include "nsAbLDAPChangeLogQuery.h"
#include "nsAbLDAPChangeLogData.h"
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddressBook)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbDirectoryDataSource,Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirProperty)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryProperties)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbCardProperty)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBSDirectory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirectory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBCard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrDatabase)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrBookSession)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbAutoCompleteSession)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbAddressCollecter,Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookUrl)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirFactoryService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirFactory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookProtocolHandler)
#ifdef XP_WIN
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookDirectory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookCard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookDirFactory)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryArguments)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanConditionString)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanExpression)
#if defined(MOZ_LDAP_XPCOM)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirectory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPCard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirFactory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPAutoCompFormatter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationQuery)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessReplicationData)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPChangeLogQuery)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessChangeLogData)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView);
static const nsModuleComponentInfo components[] =
{
{ "Address Book",
NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOK_CONTRACTID,
nsAddressBookConstructor },
{ "Address Book Startup Handler",
NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID,
nsAddressBookConstructor,
nsAddressBook::RegisterProc,
nsAddressBook::UnregisterProc },
{ "Address Book Directory Datasource",
NS_ABDIRECTORYDATASOURCE_CID,
NS_ABDIRECTORYDATASOURCE_CONTRACTID,
nsAbDirectoryDataSourceConstructor },
{ "Address Boot Strap Directory",
NS_ABDIRECTORY_CID,
NS_ABDIRECTORY_CONTRACTID,
nsAbBSDirectoryConstructor },
{ "Address MDB Book Directory",
NS_ABMDBDIRECTORY_CID,
NS_ABMDBDIRECTORY_CONTRACTID,
nsAbMDBDirectoryConstructor },
{ "Address MDB Book Card",
NS_ABMDBCARD_CID,
NS_ABMDBCARD_CONTRACTID,
nsAbMDBCardConstructor },
{ "Address Database",
NS_ADDRDATABASE_CID,
NS_ADDRDATABASE_CONTRACTID,
nsAddrDatabaseConstructor },
{ "Address Book Card Property",
NS_ABCARDPROPERTY_CID,
NS_ABCARDPROPERTY_CONTRACTID,
nsAbCardPropertyConstructor },
{ "Address Book Directory Property",
NS_ABDIRPROPERTY_CID,
NS_ABDIRPROPERTY_CONTRACTID,
nsAbDirPropertyConstructor },
{ "AB Directory Properties",
NS_ABDIRECTORYPROPERTIES_CID,
NS_ABDIRECTORYPROPERTIES_CONTRACTID,
nsAbDirectoryPropertiesConstructor },
{ "Address Book Session",
NS_ADDRBOOKSESSION_CID,
NS_ADDRBOOKSESSION_CONTRACTID,
nsAddrBookSessionConstructor },
{ "Address Book Auto Complete Session",
NS_ABAUTOCOMPLETESESSION_CID,
NS_ABAUTOCOMPLETESESSION_CONTRACTID,
nsAbAutoCompleteSessionConstructor },
{ "Address Book Address Collector",
NS_ABADDRESSCOLLECTER_CID,
NS_ABADDRESSCOLLECTER_CONTRACTID,
nsAbAddressCollecterConstructor },
{ "The addbook URL Interface",
NS_ADDBOOKURL_CID,
NS_ADDBOOKURL_CONTRACTID,
nsAddbookUrlConstructor },
{ "The addbook Protocol Handler",
NS_ADDBOOK_HANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "addbook",
nsAddbookProtocolHandlerConstructor },
{ "The directory factory service interface",
NS_ABDIRFACTORYSERVICE_CID,
NS_ABDIRFACTORYSERVICE_CONTRACTID,
nsAbDirFactoryServiceConstructor },
{ "The MDB directory factory interface",
NS_ABMDBDIRFACTORY_CID,
NS_ABMDBDIRFACTORY_CONTRACTID,
nsAbMDBDirFactoryConstructor },
#ifdef XP_WIN
{ "Address OUTLOOK Book Directory",
NS_ABOUTLOOKDIRECTORY_CID,
NS_ABOUTLOOKDIRECTORY_CONTRACTID,
nsAbOutlookDirectoryConstructor },
{ "Address OUTLOOK Book Card",
NS_ABOUTLOOKCARD_CID,
NS_ABOUTLOOKCARD_CONTRACTID,
nsAbOutlookCardConstructor },
{ "The outlook factory Interface",
NS_ABOUTLOOKDIRFACTORY_CID,
NS_ABOUTLOOKDIRFACTORY_CONTRACTID,
nsAbOutlookDirFactoryConstructor },
#endif
{ "The addbook query arguments",
NS_ABDIRECTORYQUERYARGUMENTS_CID,
NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,
nsAbDirectoryQueryArgumentsConstructor },
{ "The query boolean condition string",
NS_BOOLEANCONDITIONSTRING_CID,
NS_BOOLEANCONDITIONSTRING_CONTRACTID,
nsAbBooleanConditionStringConstructor },
{ "The query n-peer expression",
NS_BOOLEANEXPRESSION_CID,
NS_BOOLEANEXPRESSION_CONTRACTID,
nsAbBooleanExpressionConstructor },
#if defined(MOZ_LDAP_XPCOM)
{ "Address LDAP Book Directory",
NS_ABLDAPDIRECTORY_CID,
NS_ABLDAPDIRECTORY_CONTRACTID,
nsAbLDAPDirectoryConstructor },
{ "Address LDAP Book Card",
NS_ABLDAPCARD_CID,
NS_ABLDAPCARD_CONTRACTID,
nsAbLDAPCardConstructor },
{ "Address LDAP factory Interface",
NS_ABLDAPDIRFACTORY_CID,
NS_ABLDAPDIRFACTORY_CONTRACTID,
nsAbLDAPDirFactoryConstructor },
{"Address LDAP Replication Service Interface",
NS_ABLDAP_REPLICATIONSERVICE_CID,
NS_ABLDAP_REPLICATIONSERVICE_CONTRACTID,
nsAbLDAPReplicationServiceConstructor },
{"Address LDAP Replication Query Interface",
NS_ABLDAP_REPLICATIONQUERY_CID,
NS_ABLDAP_REPLICATIONQUERY_CONTRACTID,
nsAbLDAPReplicationQueryConstructor },
{"Address LDAP Replication Processor Interface",
NS_ABLDAP_PROCESSREPLICATIONDATA_CID,
NS_ABLDAP_PROCESSREPLICATIONDATA_CONTRACTID,
nsAbLDAPProcessReplicationDataConstructor },
{"Address LDAP ChangeLog Query Interface",
NS_ABLDAP_CHANGELOGQUERY_CID,
NS_ABLDAP_CHANGELOGQUERY_CONTRACTID,
nsAbLDAPChangeLogQueryConstructor },
{"Address LDAP ChangeLog Processor Interface",
NS_ABLDAP_PROCESSCHANGELOGDATA_CID,
NS_ABLDAP_PROCESSCHANGELOGDATA_CONTRACTID,
nsAbLDAPProcessChangeLogDataConstructor },
{ "Address LDAP autocomplete factory Interface",
NS_ABLDAPDIRFACTORY_CID,
NS_ABLDAPACDIRFACTORY_CONTRACTID,
nsAbLDAPDirFactoryConstructor },
{ "Address LDAP over SSL autocomplete factory Interface",
NS_ABLDAPDIRFACTORY_CID,
NS_ABLDAPSACDIRFACTORY_CONTRACTID,
nsAbLDAPDirFactoryConstructor },
{ "Address book LDAP autocomplete formatter",
NS_ABLDAPAUTOCOMPFORMATTER_CID,
NS_ABLDAPAUTOCOMPFORMATTER_CONTRACTID,
nsAbLDAPAutoCompFormatterConstructor },
#endif
{ "The directory query proxy interface",
NS_ABDIRECTORYQUERYPROXY_CID,
NS_ABDIRECTORYQUERYPROXY_CONTRACTID,
nsAbDirectoryQueryProxyConstructor },
{ "addressbook view",
NS_ABVIEW_CID,
NS_ABVIEW_CONTRACTID,
nsAbViewConstructor }
};
PR_STATIC_CALLBACK(void)
msgAbModuleDtor(nsIModule* self)
{
nsAddrDatabase::CleanupCache();
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsAbModule, components, msgAbModuleDtor)

View File

@@ -1,249 +0,0 @@
?GetStringColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IAAVnsString@@@Z ; 75645
?AddRef@nsAddrDatabase@@UAGKXZ ; 19143
?Release@nsRDFResource@@UAGKXZ ; 16961
?Release@nsAbDirectory@@UAGKXZ ; 16929
?AddRef@nsAbRDFResource@@UAGKXZ ; 16929
?AddRef@nsAbDirectory@@UAGKXZ ; 16929
?Release@nsAbRDFResource@@UAGKXZ ; 16929
?GetAttributeName@nsAbCardProperty@@IAEIPAPAGAAVnsString@@@Z ; 10557
?QueryInterface@nsAbCard@@UAGIABUnsID@@PAPAX@Z ; 8402
?SetAttributeName@nsAbCardProperty@@IAEIPBGAAVnsString@@@Z ; 6694
?assign_assuming_AddRef@nsCOMPtr_base@@IAEXPAVnsISupports@@@Z ; 4248
?GetValueConst@nsRDFResource@@UAGIPAPBD@Z ; 4232
?GetIntColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IPAII@Z ; 4223
?QueryInterface@nsAbRDFResource@@UAGIABUnsID@@PAPAX@Z ; 4219
?Release@nsAddrDatabase@@UAGKXZ ; 2182
?YarnToUInt32@nsAddrDatabase@@IAEXPAUmdbYarn@@PAI@Z ; 2139
?RemoveListener@nsAddrDatabase@@UAGIPAVnsIAddrDBListener@@@Z ; 2118
?Init@nsRDFResource@@UAGIPBD@Z ; 2116
??1nsRDFResource@@UAE@XZ ; 2116
?QueryInterface@nsRDFResource@@UAGIABUnsID@@PAPAX@Z ; 2116
??0nsRDFResource@@QAE@XZ ; 2116
??0nsAbRDFResource@@QAE@XZ ; 2116
??1nsAbRDFResource@@UAE@XZ ; 2116
?Next@nsAddrDBEnumerator@@UAGIXZ ; 2109
?AddListener@nsAddrDatabase@@UAGIPAVnsIAddrDBListener@@@Z ; 2107
?SetDbRowID@nsAbCardProperty@@UAGII@Z ; 2103
?SetDbTableID@nsAbCardProperty@@UAGII@Z ; 2103
?SetAbDatabase@nsAbCardProperty@@UAGIPAVnsIAddrDatabase@@@Z ; 2101
?AddChildCards@nsAbDirectory@@UAGIPBDPAPAVnsIAbCard@@@Z ; 2101
??0nsAbCardProperty@@QAE@XZ ; 2101
??1nsAbCard@@UAE@XZ ; 2101
?SetPrimaryEmail@nsAbCardProperty@@UAGIPBG@Z ; 2101
?GetCardFromDB@nsAddrDatabase@@IAEIPAVnsIAbCard@@PAVnsIMdbRow@@@Z ; 2101
?SetRecordKey@nsAbCardProperty@@UAGII@Z ; 2101
??1nsAbCardProperty@@UAE@XZ ; 2101
??0nsAbCard@@QAE@XZ ; 2101
??_EnsAbCard@@UAEPAXI@Z ; 2101
?CreateABCard@nsAddrDatabase@@QAEIPAVnsIMdbRow@@PAPAVnsIAbCard@@@Z ; 2101
?CreateCard@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IPAPAVnsIAbCard@@@Z ; 2101
?GetFirstName@nsAbCardProperty@@UAGIPAPAG@Z ; 2099
?GetDisplayName@nsAbCardProperty@@UAGIPAPAG@Z ; 2099
?GetNickName@nsAbCardProperty@@UAGIPAPAG@Z ; 2099
?GetLastName@nsAbCardProperty@@UAGIPAPAG@Z ; 2099
?GetIsMailList@nsAbCardProperty@@UAGIPAH@Z ; 2099
?GetPrimaryEmail@nsAbCardProperty@@UAGIPAPAG@Z ; 2099
?CurrentItem@nsAddrDBEnumerator@@UAGIPAPAVnsISupports@@@Z ; 2097
?CheckEntry@nsAbAutoCompleteSession@@IAEHPAVnsAbAutoCompleteSearchString@@PBG1111PAW4MatchType@1@@Z ; 2097
?SetDisplayName@nsAbCardProperty@@UAGIPBG@Z ; 1891
?SetFirstName@nsAbCardProperty@@UAGIPBG@Z ; 1456
?SetLastName@nsAbCardProperty@@UAGIPBG@Z ; 1246
?do_GetService@@YA?BVnsGetServiceByCID@@ABUnsID@@PAI@Z ; 371
?GetDBCache@nsAddrDatabase@@KAPAVnsVoidArray@@XZ ; 198
?GetCharStringYarn@nsAddrDatabase@@IAEXPADPAUmdbYarn@@@Z ; 74
?AddCharStringColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IPBD@Z ; 74
?INTL_ConvertFromUnicode@@YAHPBGHPAPAD@Z ; 72
?QueryInterface@nsAbDirectory@@UAGIABUnsID@@PAPAX@Z ; 59
?DIR_ForceFlag@@YAXPAUDIR_Server@@IH@Z ; 54
?FindInCache@nsAddrDatabase@@KAHPAV1@@Z ; 44
?RemoveFromCache@nsAddrDatabase@@KAXPAV1@@Z ; 44
?AddRef@nsAddbookProtocolHandler@@UAGKXZ ; 42
?DIR_GetDirectories@@YAPAVnsVoidArray@@XZ ; 35
?CloseMDB@nsAddrDatabase@@UAGIH@Z ; 33
?Close@nsAddrDatabase@@UAGIH@Z ; 33
?DIR_TestFlag@@YAHPAUDIR_Server@@I@Z ; 32
?NS_GetSpecialDirectory@@YAIPBDPAPAVnsIFile@@@Z ; 30
?QueryInterface@nsAddrBookSession@@UAGIABUnsID@@PAPAX@Z ; 30
?Open@nsAddrDatabase@@UAGIPAVnsFileSpec@@HPAPAVnsIAddrDatabase@@H@Z ; 30
?QueryInterface@nsAddrDatabase@@UAGIABUnsID@@PAPAX@Z ; 30
?GetUserProfileDirectory@nsAddrBookSession@@UAGIPAPAVnsFileSpec@@@Z ; 30
?FindInCache@nsAddrDatabase@@SAPAV1@PAVnsFileSpec@@@Z ; 30
?RemoveElementsFromAddressList@nsAbDirProperty@@UAGIXZ ; 29
?INTL_ConvertToUnicode@@YAHPBDHPAPAX@Z ; 27
?GetDataRow@nsAddrDatabase@@IAEIPAPAVnsIMdbRow@@@Z ; 23
??0nsAddrDatabase@@QAE@XZ ; 22
??_EnsAddrDatabase@@UAEPAXI@Z ; 22
??1nsAddrDatabase@@UAE@XZ ; 22
?SetDbPath@nsAddrDatabase@@UAGIPAVnsFileSpec@@@Z ; 21
?GetMDBFactory@nsAddrDatabase@@QAEPAVnsIMdbFactory@@XZ ; 21
?OpenMDB@nsAddrDatabase@@UAGIPAVnsFileSpec@@H@Z ; 21
?UpdateLowercaseEmailListName@nsAddrDatabase@@IAEIXZ ; 21
?GetLastRecorKey@nsAddrDatabase@@IAEIXZ ; 21
?UnixToNative@nsAddrDatabase@@KAXAAPAD@Z ; 21
?InitMDBInfo@nsAddrDatabase@@IAEIXZ ; 21
?Commit@nsAddrDatabase@@UAGII@Z ; 21
?InitExistingDB@nsAddrDatabase@@IAEIXZ ; 21
?GetChildNodes@nsAbDirectory@@UAGIPAPAVnsIEnumerator@@@Z ; 19
?MatchDbName@nsAddrDatabase@@IAEHPAVnsFileSpec@@@Z ; 19
?SetPreferMailFormat@nsAbCardProperty@@UAGII@Z ; 17
?Release@nsAbAutoCompleteParam@@UAGKXZ ; 16
??0nsAbDirectory@@QAE@XZ ; 15
??_GnsAbDirectory@@UAEPAXI@Z ; 15
??0nsAbDirProperty@@QAE@XZ ; 15
??1nsAbDirProperty@@UAE@XZ ; 15
?AddRef@nsAddressBook@@UAGKXZ ; 15
??1nsAbDirectory@@UAE@XZ ; 15
?Release@nsAddressBook@@UAGKXZ ; 15
?GetAbDatabaseFromURI@nsAddressBook@@UAGIPBDPAPAVnsIAddrDatabase@@@Z ; 13
?QueryInterface@nsAddressBook@@UAGIABUnsID@@PAPAX@Z ; 13
?Release@nsAbAutoCompleteSession@@UAGKXZ ; 12
?QueryInterface@nsAbAutoCompleteSession@@UAGIABUnsID@@PAPAX@Z ; 12
?GetMailingListsFromDB@nsAddrDatabase@@UAGIPAVnsIAbDirectory@@@Z ; 10
?SetDirName@nsAbDirProperty@@UAGIPBG@Z ; 10
?AddDirectory@nsAbDirectory@@UAGIPBDPAPAVnsIAbDirectory@@@Z ; 10
?SetServer@nsAbDirProperty@@UAGIPAUDIR_Server@@@Z ; 10
?DIR_InitServer@@YAIPAUDIR_Server@@@Z ; 9
?DIR_GetPrefsForOneServer@@YAXPAUDIR_Server@@HH@Z ; 9
?SearchDirectory@nsAbAutoCompleteSession@@IAEIAAVnsString@@PAVnsAbAutoCompleteSearchString@@PAVnsIAutoCompleteResults@@H@Z ; 9
??_GnsVoidArray@@UAEPAXI@Z ; 9
?Release@nsAbAddressCollecter@@UAGKXZ ; 8
?AddToResult@nsAbAutoCompleteSession@@IAEXPBG00000HW4MatchType@1@PAVnsIAutoCompleteResults@@@Z ; 8
?GetDirUri@nsAbDirectory@@UAGIPAPAD@Z ; 8
??1nsAbAutoCompleteParam@@UAE@XZ ; 8
?ItsADuplicate@nsAbAutoCompleteSession@@IAEHPAGPAVnsIAutoCompleteResults@@@Z ; 8
??0nsAbAutoCompleteParam@@QAE@PBG00000HW4MatchType@nsAbAutoCompleteSession@@@Z ; 8
??_GnsAbAutoCompleteParam@@UAEPAXI@Z ; 8
?QueryInterface@nsAbAddressCollecter@@UAGIABUnsID@@PAPAX@Z ; 7
?OnStartLookup@nsAbAutoCompleteSession@@UAGIPBGPAVnsIAutoCompleteResults@@PAVnsIAutoCompleteListener@@@Z ; 7
?GetServer@nsAbDirProperty@@UAGIPAPAUDIR_Server@@@Z ; 6
?GetIntYarn@nsAddrDatabase@@IAEXIPAUmdbYarn@@@Z ; 6
??_EnsAddrDBEnumerator@@UAEPAXI@Z ; 6
??0nsAddrDBEnumerator@@QAE@PAVnsAddrDatabase@@@Z ; 6
?SearchCards@nsAbAutoCompleteSession@@IAEIPAVnsIAbDirectory@@PAVnsAbAutoCompleteSearchString@@PAVnsIAutoCompleteResults@@@Z ; 6
?GetCardForEmailAddress@nsAddrDatabase@@UAGIPAVnsIAbDirectory@@PBDPAPAVnsIAbCard@@@Z ; 6
?Release@nsListAddressEnumerator@@UAGKXZ ; 6
?First@nsAddrDBEnumerator@@UAGIXZ ; 6
?AddIntColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@II@Z ; 6
?GetChildCards@nsAbDirectory@@UAGIPAPAVnsIEnumerator@@@Z ; 6
??1nsAddrDBEnumerator@@UAE@XZ ; 6
?GetAbDatabase@nsAbRDFResource@@IAEIXZ ; 6
?GetRowForEmailAddress@nsAddrDatabase@@IAEIPBDPAPAVnsIMdbRow@@@Z ; 6
?EnumerateCards@nsAddrDatabase@@UAGIPAVnsIAbDirectory@@PAPAVnsIEnumerator@@@Z ; 6
?GetRowForCharColumn@nsAddrDatabase@@IAEIPBDIHPAPAVnsIMdbRow@@@Z ; 6
?DIR_SetFlag@@YAXPAUDIR_Server@@I@Z ; 5
?DIR_SavePrefsForOneServer@@YAXPAUDIR_Server@@@Z ; 5
?DIR_ClearFlag@@YAXPAUDIR_Server@@I@Z ; 5
?DIR_ClearPrefBranch@@YAXPBD@Z ; 5
?NotifyCardEntryChange@nsAddrDatabase@@UAGIIPAVnsIAbCard@@PAVnsIAddrDBListener@@@Z ; 4
?GetIsMailList@nsAbDirProperty@@UAGIPAH@Z ; 4
?GetPreferMailFormat@nsAbCardProperty@@UAGIPAI@Z ; 4
?DIR_SetServerFileName@@YAXPAUDIR_Server@@PBD@Z ; 4
??0nsAbAutoCompleteSearchString@@QAE@PBG@Z ; 3
??1nsAbAutoCompleteSearchString@@UAE@XZ ; 3
?ResetMatchTypeConters@nsAbAutoCompleteSession@@IAEXXZ ; 3
?SearchPreviousResults@nsAbAutoCompleteSession@@IAEIPAVnsAbAutoCompleteSearchString@@PAVnsIAutoCompleteResults@@1@Z ; 3
?AddUnicodeToColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IPAG@Z ; 2
?IsDomainExcluded@nsAbAddressCollecter@@QAEIPBDPAVnsIPref@@PAH@Z ; 2
?AddDepartment@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddCustom2@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddHomeCountry@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddWebPage2@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetWorkCountry@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddCompany@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetCellularNumber@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddWorkPhone@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetWebPage2@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetCustom3@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddAttributeColumnsToRow@nsAddrDatabase@@IAEIPAVnsIAbCard@@PAVnsIMdbRow@@@Z ; 2
?GetCardCount@nsAddrDatabase@@UAGIPAI@Z ; 2
?GetCustom2@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddCustom1@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?DeleteCardFromAllMailLists@nsAddrDatabase@@IAEXI@Z ; 2
?GetHomeCity@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetDepartment@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetBirthDay@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetWorkState@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddWebPage1@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddCardToDatabase@nsAbCardProperty@@UAGIPBD@Z ; 2
?UpdateLastRecordKey@nsAddrDatabase@@IAEIXZ ; 2
?GetWorkPhone@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomeAddress@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetBirthMonth@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetHomeState@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetFaxNumber@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddDisplayName@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetCustom4@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddNotes@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetNewRow@nsAddrDatabase@@UAGIPAPAVnsIMdbRow@@@Z ; 2
?AddFirstName@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddRecordKeyColumnToRow@nsAddrDatabase@@IAEIPAVnsIMdbRow@@@Z ; 2
?CreateNewCardAndAddToDB@nsAddrDatabase@@UAGIPAVnsIAbCard@@H@Z ; 2
?GetHomePhone@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetWebPage1@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomeState@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?DeleteCard@nsAddrDatabase@@UAGIPAVnsIAbCard@@H@Z ; 2
?GetHomeZipCode@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomeAddress2@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddWorkCity@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetPagerNumber@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetDbRowID@nsAbCardProperty@@UAGIPAI@Z ; 2
?AddLastName@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetWorkZipCode@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddBirthDay@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddCustom3@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetSecondEmail@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddCellularNumber@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddPreferMailFormat@nsAddrDatabase@@UAGIPAVnsIMdbRow@@I@Z ; 2
?DeleteRow@nsAddrDatabase@@IAEIPAVnsIMdbTable@@PAVnsIMdbRow@@@Z ; 2
?GetJobTitle@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomeCity@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetNotes@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomePhone@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?SplitFullName@nsAbAddressCollecter@@QAEIPBDPAPAD1@Z ; 2
?SetNamesForCard@nsAbAddressCollecter@@QAEIPAVnsIAbCard@@PBD@Z ; 2
?AddWorkAddress2@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddWorkState@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetBirthYear@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetCompany@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddCustom4@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?CollectAddress@nsAbAddressCollecter@@UAGIPBD@Z ; 2
?AddWorkZipCode@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetWorkCity@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddBirthMonth@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetHomeAddress2@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddBirthYear@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetWorkAddress2@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddLowercaseColumn@nsAddrDatabase@@IAEIPAVnsIMdbRow@@IPBD@Z ; 2
?GetCustom1@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?GetWorkAddress@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddWorkCountry@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddJobTitle@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetHomeCountry@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddHomeZipCode@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddPagerNumber@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddWorkAddress@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?AddFaxNumber@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?Add2ndEmail@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?GetHomeAddress@nsAbCardProperty@@UAGIPAPAG@Z ; 2
?AddNickName@nsAddrDatabase@@UAGIPAVnsIMdbRow@@PBD@Z ; 2
?SetDefaultDomain@nsAbAutoCompleteSession@@UAGIPBG@Z ; 1
??1nsAddrBookSession@@UAE@XZ ; 1
_NSGetModule ; 1
?DIR_GetDirServers@@YAIXZ ; 1
??_EnsAddressBook@@UAEPAXI@Z ; 1
??1nsAddressBook@@UAE@XZ ; 1
??0nsAddressBook@@QAE@XZ ; 1
??0nsAbAutoCompleteSession@@QAE@XZ ; 1
?DIR_GetServerPreferences@@YAIPAPAVnsVoidArray@@@Z ; 1
??0nsAddrBookSession@@QAE@XZ ; 1
??_EnsAddrBookSession@@UAEPAXI@Z ; 1
?OpenHistoryAB@nsAbAddressCollecter@@QAEIPAPAVnsIAddrDatabase@@@Z ; 1
?setupPrefs@nsAbAddressCollecter@@AAEXXZ ; 1
??0nsAbAddressCollecter@@QAE@XZ ; 1
??1nsAbAddressCollecter@@UAE@XZ ; 1
??_GnsFileSpec@@UAEPAXI@Z ; 1
?DIR_SendNotification@@YAHPAUDIR_Server@@IW4DIR_PrefId@@@Z ; 1
?DIR_SortServersByPosition@@YAHPAVnsVoidArray@@@Z ; 1
??_EnsAbAddressCollecter@@UAEPAXI@Z ; 1
??_GnsAbAutoCompleteSession@@UAEPAXI@Z ; 1
??1nsAbAutoCompleteSession@@UAE@XZ ; 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacPrefix.h"

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacPrefix_debug.h"

View File

@@ -1,24 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# This is a list of local files which get copied to the res\mailnews\messenger directory
#
pref-addressing.xul
pref-addressbookOverlay.xul

View File

@@ -1,14 +0,0 @@
<?xml version="1.0"?>
<overlay id="addressbookPrefOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<treechildren id="messengerChildren">
<treeitem open="true" position="3">
<treerow>
<treecell indent="true" url="chrome://messenger/content/addressbook/pref-addressing.xul" label="&address.label;"/>
</treerow>
</treeitem>
</treechildren>
</overlay>

View File

@@ -1,90 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/pref-addressing.dtd">
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();"
headertitle="&pane.title;">
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory.js"/>
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["emailCollectionIncoming", "emailCollectionOutgoing",
"emailCollectionNewsgroup", "addressingAutocomplete",
"enableCABsizeLimit", "CABsizeLimit", "autocompleteLDAP",
"directoriesList"];
function onLoad(){
createDirectoriesList(true);
parent.initPanel('chrome://messenger/content/addressbook/pref-addressing.xul');
}
function Startup(){
enableAutocomplete();
}
]]>
</script>
<groupbox>
<caption label="&emailCollectiontitle.label;"/>
<description>&emailCollectiontext.label;</description>
<vbox align="start" class="indent">
<checkbox id="emailCollectionIncoming" label="&emailCollectionIncomingEnable.label;"
prefstring="mail.collect_email_address_incoming"
accesskey="&emailCollectionIncomingEnable.accesskey;"/>
<checkbox id="emailCollectionOutgoing" label="&emailCollectionOutgoingEnable.label;"
prefstring="mail.collect_email_address_outgoing"
accesskey="&emailCollectionOutgoingEnable.accesskey;"/>
<checkbox id="emailCollectionNewsgroup" label="&emailCollectionNewsgroupEnable.label;"
prefstring="mail.collect_email_address_newsgroup"
accesskey="&emailCollectionNewsgroupEnable.accesskey;"/>
</vbox>
<hbox align="center">
<checkbox id="enableCABsizeLimit" label="&useCABSizelimitPart1.label;"
prefstring="mail.collect_email_address_enable_size_limit"
accesskey="&useCABSizelimitPart1.accesskey;"/>
<textbox id="CABsizeLimit" size="6" preftype="int"
prefstring="mail.collect_email_address_size_limit"/>
<label id="useCABSizelimitPart2" class="small-margin" value="&useCABSizelimitPart2.label;"
accesskey="&useCABSizelimitPart2.accesskey;"
control="CABsizeLimit"/>
</hbox>
</groupbox>
<groupbox id="addressAutocompletion">
<caption label="&addressingTitle.label;"/>
<description>&autocompleteText.label;</description>
<hbox align="center">
<checkbox id="addressingAutocomplete" label="&addressingEnable.label;"
prefstring="mail.enable_autocomplete"
accesskey="&addressingEnable.accesskey;"/>
</hbox>
<hbox align="center">
<checkbox id="autocompleteLDAP" label="&directories.label;"
prefstring="ldap_2.autoComplete.useDirectory"
oncommand="enableAutocomplete();"
accesskey="&directories.accesskey;"/>
<menulist id="directoriesList" flex="1"
preftype="string"
prefstring="ldap_2.autoComplete.directoryServer">
<menupopup id="directoriesListPopup"
onpopupshowing="createDirectoriesList(true);">
</menupopup>
</menulist>
<button id="editButton" label="&editDirectories.label;"
prefstring="pref.ldap.disable_button.edit_directories"
oncommand="onEditDirectories();"
accesskey="&editDirectories.accesskey;"/>
</hbox>
<!--
<description>&matchText.label;</description>
<hbox align="center">
<checkbox id="autocompleteSkipDirectory"
label="&skipDirectory.label;"
prefstring="ldap_2.autoComplete.skipDirectoryIfLocalMatchFound"/>
</hbox>
-->
</groupbox>
</page>

View File

@@ -1,349 +0,0 @@
/* -*- Mode: Java; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
var gPrefstring = "ldap_2.servers.";
var gPref_string_desc = "";
var gPrefInt = null;
var gCurrentDirectory = null;
var gCurrentDirectoryString = null;
var gLdapService = Components.classes["@mozilla.org/network/ldap-service;1"].
getService(Components.interfaces.nsILDAPService);
const kDefaultMaxHits = 100;
const kDefaultLDAPPort = 389;
const kDefaultSecureLDAPPort = 636;
function Startup()
{
if ( "arguments" in window && window.arguments[0] ) {
gCurrentDirectory = window.arguments[0].selectedDirectory;
gCurrentDirectoryString = window.arguments[0].selectedDirectoryString;
try {
fillSettings();
} catch (ex) {
dump("pref-directory-add.js:Startup(): fillSettings() exception: "
+ ex + "\n");
}
} else {
fillDefaultSettings();
}
}
function DownloadNow()
{
var args = {dirName: gCurrentDirectory, prefName: gCurrentDirectoryString};
window.opener.openDialog("chrome://messenger/content/addressbook/replicationProgress.xul", "", "chrome,resizable,status,centerscreen,dialog=no", args);
}
// fill the settings panel with the data from the preferences.
//
function fillSettings()
{
gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var ldapUrl = Components.classes["@mozilla.org/network/ldap-url;1"];
ldapUrl = ldapUrl.createInstance().
QueryInterface(Components.interfaces.nsILDAPURL);
try {
var prefValue =
gPrefInt.getComplexValue(gCurrentDirectoryString + ".description",
Components.interfaces.nsISupportsString).data;
} catch(ex) {
prefValue="";
}
document.getElementById("description").value = prefValue;
ldapUrl.spec = gPrefInt.getComplexValue(gCurrentDirectoryString +".uri",
Components.interfaces.
nsISupportsString).data;
document.getElementById("hostname").value = ldapUrl.host;
document.getElementById("port").value = ldapUrl.port;
document.getElementById("basedn").value =
gLdapService.UTF8toUCS2(ldapUrl.dn);
document.getElementById("search").value =
gLdapService.UTF8toUCS2(ldapUrl.filter);
var sub = document.getElementById("sub");
switch(ldapUrl.scope) {
case Components.interfaces.nsILDAPURL.SCOPE_ONELEVEL:
sub.radioGroup.selectedItem = document.getElementById("one");
break;
default:
sub.radioGroup.selectedItem = sub;
break;
}
if (ldapUrl.options & ldapUrl.OPT_SECURE) {
document.getElementById("secure").setAttribute("checked", "true");
}
try {
prefValue = gPrefInt.getIntPref(gCurrentDirectoryString + ".maxHits");
} catch(ex) {
prefValue = kDefaultMaxHits;
}
document.getElementById("results").value = prefValue;
try {
prefValue =
gPrefInt.getComplexValue(gCurrentDirectoryString + ".auth.dn",
Components.interfaces.nsISupportsString).data;
} catch(ex) {
prefValue="";
}
document.getElementById("login").value = prefValue;
// check if any of the preferences for this server are locked.
//If they are locked disable them
DisableUriFields(gCurrentDirectoryString + ".uri");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".description", "description");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".disable_button_download", "download");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".maxHits", "results");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".auth.dn", "login");
}
function DisableElementIfPrefIsLocked(aPrefName, aElementId)
{
if (gPrefInt.prefIsLocked(aPrefName))
document.getElementById(aElementId).setAttribute('disabled', true);
}
// disables all the text fields corresponding to the .uri pref.
function DisableUriFields(aPrefName)
{
if (gPrefInt.prefIsLocked(aPrefName)) {
var lockedElements = document.getElementsByAttribute("disableiflocked", "true");
for (var i=0; i<lockedElements.length; i++)
lockedElements[i].setAttribute('disabled', 'true');
}
}
function onSecure()
{
var port = document.getElementById("port");
if (document.getElementById("secure").checked)
port.value = kDefaultSecureLDAPPort;
else
port.value = kDefaultLDAPPort;
}
function fillDefaultSettings()
{
document.getElementById("port").value = kDefaultLDAPPort;
document.getElementById("results").value = kDefaultMaxHits;
var sub = document.getElementById("sub");
sub.radioGroup.selectedItem = sub;
}
// find a unique server-name for the new directory server
// from the description entered by the user.
function createUniqueServername()
{
// gPref_string_desc is the description entered by the user.
// Just get the alphabets and digits from the description.
// remove spaces and special characters from description.
var user_Id = 0;
var re = /[A-Za-z0-9]/g;
var str = gPref_string_desc.match(re);
var temp = "";
if (!str) {
try {
user_Id = gPrefInt.getIntPref("ldap_2.user_id");
}
catch(ex){
user_Id = 0;
}
++user_Id;
temp = "user_directory_" + user_Id;
str = temp;
try {
gPrefInt.setIntPref("ldap_2.user_id", user_Id);
}
catch(ex) {}
}
else {
var len = str.length;
if (len > 20) len = 20;
for (var count = 0; count < len; count++)
{
temp += str[count];
}
}
gPref_string_desc = temp;
while (temp) {
temp = "";
try{
temp = gPrefInt.getComplexValue(gPrefstring+gPref_string_desc+".description",
Components.interfaces.nsISupportsString).data;
} catch(e){}
if (temp)
gPref_string_desc += str[0];
}
}
function hasOnlyWhitespaces(string)
{
// get all the whitespace characters of string and assign them to str.
// string is not modified in this function
// returns true if string contains only whitespaces and/or tabs
var re = /[ \s]/g;
var str = string.match(re);
if (str && (str.length == string.length))
return true;
else
return false;
}
function hasCharacters(number)
{
var re = /[0-9]/g;
var num = number.match(re);
if(num && (num.length == number.length))
return false;
else
return true;
}
function onAccept()
{
try {
var pref_string_content = "";
var pref_string_title = "";
if (!gPrefInt) {
gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
}
var ldapUrl = Components.classes["@mozilla.org/network/ldap-url;1"];
ldapUrl = ldapUrl.createInstance().
QueryInterface(Components.interfaces.nsILDAPURL);
var description = document.getElementById("description").value;
var hostname = document.getElementById("hostname").value;
var port = document.getElementById("port").value;
var secure = document.getElementById("secure");
var dn = document.getElementById("login").value;
var results = document.getElementById("results").value;
var errorValue = null;
gPref_string_desc = description;
if ((!gPref_string_desc) || hasOnlyWhitespaces(gPref_string_desc))
errorValue = "invalidName";
else if ((!hostname) || hasOnlyWhitespaces(hostname))
errorValue = "invalidHostname";
// XXX write isValidDn and call it on the dn string here?
else if (port && hasCharacters(port))
errorValue = "invalidPortNumber";
else if (results && hasCharacters(results))
errorValue = "invalidResults";
if (!errorValue) {
pref_string_content = gPref_string_desc;
if (gCurrentDirectory && gCurrentDirectoryString) {
gPref_string_desc = gCurrentDirectoryString;
} else {
createUniqueServername();
gPref_string_desc = gPrefstring + gPref_string_desc;
}
pref_string_title = gPref_string_desc + "." + "description";
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = pref_string_content;
gPrefInt.setComplexValue(pref_string_title,
Components.interfaces.nsISupportsString, str);
ldapUrl.host = hostname;
pref_string_content = gLdapService.
UCS2toUTF8(document.getElementById("basedn").value);
ldapUrl.dn = pref_string_content;
pref_string_content = gLdapService.
UCS2toUTF8(document.getElementById("search").value);
ldapUrl.filter = pref_string_content;
if (!port) {
if (secure.checked)
ldapUrl.port = kDefaultSecureLDAPPort;
else
ldapUrl.port = kDefaultLDAPPort;
} else {
ldapUrl.port = port;
}
if (document.getElementById("one").selected) {
ldapUrl.scope = Components.interfaces.nsILDAPURL.SCOPE_ONELEVEL;
} else {
ldapUrl.scope = Components.interfaces.nsILDAPURL.SCOPE_SUBTREE;
}
if (secure.checked)
ldapUrl.options |= ldapUrl.OPT_SECURE;
pref_string_title = gPref_string_desc + ".uri";
var uri = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
uri.data = ldapUrl.spec;
gPrefInt.setComplexValue(pref_string_title,
Components.interfaces.nsISupportsString, uri);
pref_string_content = results;
pref_string_title = gPref_string_desc + ".maxHits";
if (pref_string_content != kDefaultMaxHits) {
gPrefInt.setIntPref(pref_string_title, pref_string_content);
} else {
try {
gPrefInt.clearUserPref(pref_string_title);
} catch (ex) {
}
}
pref_string_title = gPref_string_desc + ".auth.dn";
var dnWString = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
dnWString.data = dn;
gPrefInt.setComplexValue(pref_string_title,
Components.interfaces.nsISupportsString,
dnWString);
// We don't actually allow the password to be saved in the preferences;
// this preference is (effectively) ignored by the current code base.
// It's here because versions of Mozilla 1.0 and earlier (maybe 1.1alpha
// too?) would blow away the .auth.dn preference if .auth.savePassword
// is not set. To avoid trashing things for users who switch between
// versions, we'll set it. Once the versions in question become
// obsolete enough, this workaround can be gotten rid of.
//
try {
gPrefInt.setBoolPref(gPref_string_desc + ".auth.savePassword", true);
} catch (ex) {
// if this fails, we can live with that; keep going
}
window.opener.gNewServer = description;
window.opener.gNewServerString = gPref_string_desc;
// set window.opener.gUpdate to true so that LDAP Directory Servers
// dialog gets updated
window.opener.gUpdate = true;
} else {
var addressBookBundle = document.getElementById("bundle_addressBook");
var errorMsg = addressBookBundle.getString(errorValue);
alert(errorMsg);
}
} catch (outer) {
dump("Internal error in pref-directory-add.js:onAccept() " + outer + "\n");
}
}
function onCancel()
{
window.opener.gUpdate = false;
}
// called by Help button in platform overlay
function doHelpButton()
{
openHelp("mail-ldap-properties");
}

View File

@@ -1,156 +0,0 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
Srilatha Moturi <srilatha@netscape.com>, original implementor
Hkan Waara <hwaara@chello.se>
Dan Mosedale <dmose@netscape.com>
-->
<?xml-stylesheet href="chrome://messenger/skin/prefPanels.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/pref-directory-add.dtd">
<dialog id="addDirectory"
style="width: &newDirectoryWidth;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&newDirectoryTitle.label;"
onload="Startup();"
buttons="accept,cancel,help"
ondialogaccept="return onAccept();"
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory-add.js"/>
<script type="application/x-javascript" src="chrome://help/content/contextHelp.js"/>
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
<keyset id="keyset"/>
<vbox id="editDirectory">
<tabbox style="margin:5px">
<tabs id="directoryTabBox">
<tab label="&General.tab;"/>
<tab label="&Offline.tab;"/>
<tab label="&Advanced.tab;"/>
</tabs>
<tabpanels id="directoryTabPanels" flex="1">
<vbox>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
<column/>
</columns>
<rows>
<row align="center">
<label value="&directoryName.label;" accesskey="&directoryName.accesskey;"
control="description"/>
<textbox id="description" flex="1"/>
<spacer flex="1"/>
</row>
<row align="center">
<label value="&directoryHostname.label;" accesskey="&directoryHostname.accesskey;"
control="hostname"/>
<textbox id="hostname" flex="1" disableiflocked="true"/>
<spacer flex="1"/>
</row>
<row align="center">
<label value="&directoryBaseDN.label;"
accesskey="&directoryBaseDN.accesskey;"
control="basedn"/>
<vbox>
<textbox id="basedn" disableiflocked="true"/>
</vbox>
<button label="&findButton.label;"
accesskey="&findButton.accesskey;" disabled="true"/>
</row>
<row align="center">
<label value="&portNumber.label;"
accesskey="&portNumber.accesskey;"
control="port"/>
<hbox>
<textbox id="port" size="6" disableiflocked="true"/>
</hbox>
</row>
<row align="center">
<label value="&directoryLogin.label;"
accesskey="&directoryLogin.accesskey;"
control="login"/>
<textbox id="login" flex="1"/>
</row>
</rows>
</grid>
<separator/>
<checkbox id="secure" label="&directorySecure.label;"
accesskey="&directorySecure.accesskey;"
oncommand="onSecure();" disableiflocked="true"/>
</vbox>
<vbox>
<description>&offlineText.label;</description>
<separator/>
<hbox>
<button id="download" label="&downloadNowButton.label;"
accesskey="&downloadNowButton.accesskey;"
oncommand="DownloadNow();"/>
<spacer flex="1"/>
</hbox>
</vbox>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&return.label;"
accesskey="&return.accesskey;"
control="results"/>
<hbox align="center">
<textbox id="results" size="6"/>
<label value="&results.label;"/>
</hbox>
</row>
<row align="center">
<label value="&scope.label;" control="scope" accesskey="&scope.accesskey;"/>
<radiogroup id="scope" orient="horizontal">
<radio id="one" value="1" label="&scopeOneLevel.label;"
disableiflocked="true" accesskey="&scopeOneLevel.accesskey;"/>
<radio id="sub" value="2" label="&scopeSubtree.label;"
disableiflocked="true" accesskey="&scopeSubtree.accesskey;"/>
</radiogroup>
</row>
<row>
<label value="&searchFilter.label;"
accesskey="&searchFilter.accesskey;"
control="search"/>
<textbox id="search" multiline="true" flex="1" disableiflocked="true"/>
</row>
</rows>
</grid>
</tabpanels>
</tabbox>
</vbox>
</dialog>

View File

@@ -1,512 +0,0 @@
var gPrefInt = null;
var gAvailDirectories = null;
var gCurrentDirectoryServer = null;
var gCurrentDirectoryServerId = null;
var gRefresh = false;
var gNewServer = null;
var gNewServerString = null;
var gFromGlobalPref = false;
var gUpdate = false;
var gDeletedDirectories = new Array();
var gLDAPPrefsService = Components.classes[
"@mozilla.org/ldapprefs-service;1"].getService();
gLDAPPrefsService = gLDAPPrefsService.QueryInterface(
Components.interfaces.nsILDAPPrefsService);
function onEditDirectories()
{
var args = {fromGlobalPref: gFromGlobalPref};
window.openDialog("chrome://messenger/content/addressbook/pref-editdirectories.xul",
"editDirectories", "chrome,modal=yes,resizable=no", args);
if (gRefresh)
{
var popup = document.getElementById("directoriesListPopup");
if (popup)
{
while (popup.childNodes.length)
popup.removeChild(popup.childNodes[0]);
}
gAvailDirectories = null;
LoadDirectories(popup);
gRefresh = false;
}
}
function enableAutocomplete()
{
var autocompleteLDAP = document.getElementById("autocompleteLDAP");
var directoriesList = document.getElementById("directoriesList");
var directoriesListPopup = document.getElementById("directoriesListPopup");
var editButton = document.getElementById("editButton");
// var autocompleteSkipDirectory = document.getElementById("autocompleteSkipDirectory");
if (autocompleteLDAP.checked) {
// If the default directory preference is locked
// disable the list popup
if (gPrefInt.prefIsLocked("ldap_2.autoComplete.directoryServer")) {
directoriesList.setAttribute("disabled", true);
directoriesListPopup.setAttribute("disabled", true);
}
else {
directoriesList.removeAttribute("disabled");
directoriesListPopup.removeAttribute("disabled");
}
editButton.removeAttribute("disabled");
// autocompleteSkipDirectory.removeAttribute("disabled");
}
else {
directoriesList.setAttribute("disabled", true);
directoriesListPopup.setAttribute("disabled", true);
editButton.setAttribute("disabled", true);
// autocompleteSkipDirectory.setAttribute("disabled", true);
}
// if we do not have any directories disable the dropdown list box
if (gAvailDirectories.length < 1)
directoriesList.setAttribute("disabled", true);
gFromGlobalPref = true;
LoadDirectories(directoriesListPopup);
}
function setupDirectoriesList()
{
var override = document.getElementById("identity.overrideGlobalPref").getAttribute("value");
var autocomplete = document.getElementById("ldapAutocomplete");
// useGlobalFlag is set when user changes the selectedItem on the radio button and switches
// to a different pane and switches back in Mail/news AccountSettings
var useGlobalFlag = document.getElementById("overrideGlobalPref").getAttribute("value");
// directoryServerFlag is set when user changes the server to None and switches
// to a different pane and switches back in Mail/news AccountSettings
var directoryServerFlag = document.getElementById("directoryServer").getAttribute("value");
if(override == "true" && !useGlobalFlag)
autocomplete.selectedItem = document.getElementById("directories");
else
autocomplete.selectedItem = document.getElementById("useGlobalPref");
var directoriesList = document.getElementById("directoriesList");
var directoryServer =
document.getElementById("identity.directoryServer").getAttribute('value');
try {
var directoryServerString = gPrefInt.getComplexValue(directoryServer + ".description",
Components.interfaces.nsISupportsString).data;
}
catch(ex) {}
if (directoryServerFlag || !directoryServerString) {
document.getElementById("identity.directoryServer").setAttribute("value", "");
directoryServer = "";
var addressBookBundle = document.getElementById("bundle_addressBook");
directoryServerString = addressBookBundle.getString("directoriesListItemNone");
}
directoriesList.value = directoryServer;
directoriesList.label = directoryServerString;
gFromGlobalPref = false;
}
function createDirectoriesList(flag)
{
gFromGlobalPref = flag;
var directoriesListPopup = document.getElementById("directoriesListPopup");
if (directoriesListPopup) {
LoadDirectories(directoriesListPopup);
}
}
function LoadDirectories(popup)
{
var prefCount = {value:0};
var enabled = false;
var description = "";
var item;
var formElement;
var j=0;
var arrayOfDirectories;
var position = 0;
var dirType = 1;
var directoriesList;
var directoryDescription;
if (!gPrefInt) {
try {
gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
}
catch (ex) {
gPrefInt = null;
}
}
if (!gAvailDirectories) {
try {
arrayOfDirectories = gLDAPPrefsService.getServerList(gPrefInt, prefCount);
}
catch (ex) {
arrayOfDirectories = null;
}
if (arrayOfDirectories) {
gAvailDirectories = new Array();
for (var i = 0; i < prefCount.value; i++)
{
if ((arrayOfDirectories[i] != "ldap_2.servers.pab") &&
(arrayOfDirectories[i] != "ldap_2.servers.history")) {
try{
position = gPrefInt.getIntPref(arrayOfDirectories[i]+".position");
}
catch(ex){
position = 1;
}
try{
dirType = gPrefInt.getIntPref(arrayOfDirectories[i]+".dirType");
}
catch(ex){
dirType = 1;
}
if ((position != 0) && (dirType == 1)) {
try{
description = gPrefInt.getComplexValue(arrayOfDirectories[i]+".description",
Components.interfaces.nsISupportsString).data;
}
catch(ex){
description="";
}
if (description != "") {
if (popup) {
item=document.createElement("menuitem");
item.setAttribute("label", description);
item.setAttribute("value", arrayOfDirectories[i]);
popup.appendChild(item);
}
gAvailDirectories[j] = {value:arrayOfDirectories[i], label:description};
j++;
}
}
}
}
if (popup && !gFromGlobalPref)
{
// we are in mail/news Account settings
item=document.createElement("menuitem");
var addressBookBundle = document.getElementById("bundle_addressBook");
var directoryName = addressBookBundle.getString("directoriesListItemNone");
item.setAttribute("label", directoryName);
item.setAttribute("value", "");
popup.appendChild(item);
if (gRefresh) {
// gRefresh is true if user edits, removes or adds a directory.
directoriesList = document.getElementById("directoriesList");
directoryDescription = null;
if(directoriesList.value != "") {
// make sure the selected directory still exists
try {
directoryDescription = gPrefInt.
getComplexValue(directoriesList.value + ".description",
Components.interfaces.nsISupportsString).data;
}
catch (ex) {}
}
if(!directoryDescription) {
// if selected directory doesn't exist, set it to none
directoriesList.value = "";
addressBookBundle = document.getElementById("bundle_addressBook");
directoriesList.label = addressBookBundle.
getString("directoriesListItemNone");
}
else {
directoriesList.label = directoryDescription;
directoriesList.value = directoriesList.value;
}
}
}
if (popup && gFromGlobalPref) {
// we are in global preferences-> Addressing pane.
directoriesList = document.getElementById("directoriesList");
if (gRefresh) {
// gRefresh is true if user edits, removes or adds a directory.
directoryDescription = null;
if(directoriesList.label != "") {
// make sure the selected directory still exists
try {
directoryDescription = gPrefInt.
getComplexValue(directoriesList.value + ".description",
Components.interfaces.nsISupportsString).data;
}
catch (ex) {}
}
if(!directoryDescription) {
// if selected directory doesn't exist,
// set it the first one in the list of directories
// if we have atleast one directory.
// or else set it to ""
if (gAvailDirectories.length) {
directoriesList.label = gAvailDirectories[0].label;
directoriesList.value = gAvailDirectories[0].value;
directoriesList.removeAttribute("disabled");
}
else {
directoriesList.label = "";
directoriesList.value = null;
directoriesList.setAttribute("disabled", true);
}
}
else {
directoriesList.label = directoryDescription;
directoriesList.value = directoriesList.value;
}
return;
}
var pref_string_title = "ldap_2.autoComplete.directoryServer";
try {
var directoryServer = gPrefInt.getCharPref(pref_string_title);
}
catch (ex)
{
directoryServer = "";
}
if (directoryServer != "")
{
pref_string_title = directoryServer + ".description";
try {
description = gPrefInt.getComplexValue(pref_string_title,
Components.interfaces.nsISupportsString).data;
}
catch (ex) {
description = "";
}
}
if ((directoryServer != "") && (description != ""))
{
directoriesList.label = description;
directoriesList.value = directoryServer;
}
else if(gAvailDirectories.length) {
directoriesList.label = gAvailDirectories[0].label;
directoriesList.value = gAvailDirectories[0].value;
gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer",
gAvailDirectories[0].value);
}
else {
directoriesList.label = "";
directoriesList.value = null;
gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer", "");
}
}
}
}
}
function onInitEditDirectories()
{
var listbox = document.getElementById("directoriesList");
gFromGlobalPref = window.arguments[0].fromGlobalPref;
LoadDirectoriesList(listbox);
// If the pref is locked disable the "Add" button
if (gPrefInt.prefIsLocked("ldap_2.disable_button_add"))
document.getElementById("addButton").setAttribute('disabled', true);
}
function LoadDirectoriesList(listbox)
{
LoadDirectories();
if (listbox && gAvailDirectories)
{
for (var i=0; i<gAvailDirectories.length; i++)
{
var item = document.createElement('listitem');
item.setAttribute('label', gAvailDirectories[i].label);
item.setAttribute('string', gAvailDirectories[i].value);
listbox.appendChild(item);
}
}
}
function selectDirectory()
{
var directoriesList = document.getElementById("directoriesList");
if(directoriesList && directoriesList.selectedItems
&& directoriesList.selectedItems.length)
{
gCurrentDirectoryServer =
directoriesList.selectedItems[0].getAttribute('label');
gCurrentDirectoryServerId =
directoriesList.selectedItems[0].getAttribute('string');
}
else
{
gCurrentDirectoryServer = null;
gCurrentDirectoryServerId = null;
}
var editButton = document.getElementById("editButton");
var removeButton = document.getElementById("removeButton");
if(gCurrentDirectoryServer && gCurrentDirectoryServerId) {
editButton.removeAttribute("disabled");
// If the disable delete button pref for the selected directory is set
// disable the delete button for that directory.
var disable = false;
try {
disable = gPrefInt.getBoolPref(gCurrentDirectoryServerId + ".disable_delete");
}
catch(ex){
// if this preference is not set its ok.
}
if (disable)
removeButton.setAttribute("disabled", true);
else
removeButton.removeAttribute("disabled");
}
else {
editButton.setAttribute("disabled", true);
removeButton.setAttribute("disabled", true);
}
}
function newDirectory()
{
window.openDialog("chrome://messenger/content/addressbook/pref-directory-add.xul",
"addDirectory", "chrome,modal=yes,resizable=no,centerscreen");
if(gUpdate && gNewServer && gNewServerString) {
var listbox = document.getElementById("directoriesList");
var item = document.createElement('listitem');
item.setAttribute('label', gNewServer);
item.setAttribute('string', gNewServerString);
listbox.appendChild(item);
gNewServer = null;
gNewServerString = null;
window.opener.gRefresh = true;
}
}
function editDirectory()
{
var args = { selectedDirectory: null,
selectedDirectoryString: null,
result: false};
if(gCurrentDirectoryServer && gCurrentDirectoryServerId) {
args.selectedDirectory = gCurrentDirectoryServer;
args.selectedDirectoryString = gCurrentDirectoryServerId;
window.openDialog("chrome://messenger/content/addressbook/pref-directory-add.xul",
"editDirectory", "chrome,modal=yes,resizable=no,centerscreen", args);
}
if(gUpdate)
{
// directory server properties have changed. So, update the
// LDAP Directory Servers dialog.
var directoriesList = document.getElementById("directoriesList");
var selectedNode = directoriesList.selectedItems[0];
selectedNode.setAttribute('label', gNewServer);
selectedNode.setAttribute('string', gNewServerString);
// window.opener is either global pref window or
// mail/news account settings window.
// set window.opener.gRefresh to true such that the
// dropdown list box gets updated
window.opener.gRefresh = true;
}
}
function removeDirectory()
{
var directoriesList = document.getElementById("directoriesList");
var selectedNode = directoriesList.selectedItems[0];
var nextNode = selectedNode.nextSibling;
if (!nextNode)
if (selectedNode.previousSibling)
nextNode = selectedNode.previousSibling;
if(gCurrentDirectoryServer && gCurrentDirectoryServerId) {
var len= gDeletedDirectories.length;
gDeletedDirectories[len] = gCurrentDirectoryServerId;
}
directoriesList.removeChild(selectedNode);
if (nextNode)
directoriesList.selectItem(nextNode)
}
// remove all the directories that are selected for deletion from preferences
// check if the deleted directory is selected for autocompletion in global
// or identity prefs. If so change the pref to ""
function onAccept()
{
var len = gDeletedDirectories.length;
if (len) {
try {
var directoryServer = gPrefInt.getCharPref("ldap_2.autoComplete.directoryServer");
}
catch(ex) {
directoryServer = null;
}
var am = Components.classes["@mozilla.org/messenger/account-manager;1"]
.getService(Components.interfaces.nsIMsgAccountManager);
if (am) {
var RDF, addressbook, addressbookDS;
try {
// the rdf service
RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].
getService(Components.interfaces.nsIRDFService);
// get the datasource for the addressdirectory
addressbookDS = RDF.GetDataSource("rdf:addressdirectory");
addressbook = Components.classes["@mozilla.org/addressbook;1"].
createInstance(Components.interfaces.nsIAddressBook);
}
catch(ex){
dump("Failed to get RDF Service or addressbook " + ex + "\n");
}
var allIdentities = am.allIdentities;
var identitiesCount = allIdentities.Count();
var identityServer = new Array();
var currentIdentity = null;
var j=0;
for (j=0; j< identitiesCount; j++) {
currentIdentity = allIdentities.QueryElementAt(j, Components.interfaces.nsIMsgIdentity);
identityServer[j] = {server:currentIdentity.directoryServer, deleted:false};
}
var deletedGlobal = false;
for (var i=0; i< len; i++){
if (!deletedGlobal && directoryServer && (gDeletedDirectories[i] == directoryServer)) {
gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer", "");
deletedGlobal = true;
}
for (j=0; j<identitiesCount; j++){
if (identityServer[j].server && !identityServer[j].deleted && (gDeletedDirectories[i] == identityServer[j].server)) {
identityServer[j].server = "";
identityServer[j].deleted = true;
}
}
try {
// delete the directory
var parentArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
// moz-abdirectory:// is the RDF root to get all types of addressbooks.
var parentDir = RDF.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
parentArray.AppendElement(parentDir);
var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
// the RDF resource URI for LDAPDirectory will be moz-abldapdirectory://<prefName>
var selectedABURI = "moz-abldapdirectory://" + gDeletedDirectories[i];
var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);
var selectedABResource = selectedABDirectory.QueryInterface(Components.interfaces.nsIRDFResource);
resourceArray.AppendElement(selectedABResource);
addressbook.deleteAddressBooks(addressbookDS, parentArray, resourceArray);
}
catch(ex){
dump("Failed to delete the addressbook " + ex + "\n");
}
}
var svc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
svc.savePrefFile(null);
}
}
window.opener.gRefresh = true;
return true;
}
function doHelpButton()
{
openHelp("mail-ldap-properties");
}

View File

@@ -1,47 +0,0 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
-->
<?xml-stylesheet href="chrome://messenger/skin/prefPanels.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/pref-directory.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
title="&window.title;"
buttons="accept,cancel,help"
onload="onInitEditDirectories();"
ondialogaccept="return onAccept();"
ondialoghelp="return doHelpButton();">
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory.js"/>
<script type="application/x-javascript" src="chrome://help/content/contextHelp.js"/>
<label value="&directoriesText.label;" accesskey="&directoriesText.accesskey;" control="directoriesList"/>
<hbox flex="1">
<listbox id="directoriesList" flex="1" onselect="selectDirectory();"/>
<vbox>
<button id="addButton" label="&addDirectory.label;" oncommand="newDirectory();" accesskey="&addDirectory.accesskey;"/>
<button id="editButton" label="&editDirectory.label;" oncommand="editDirectory();" disabled="true" accesskey="&editDirectory.accesskey;"/>
<button id="removeButton" label="&deleteDirectory.label;" oncommand="removeDirectory();" disabled="true" accesskey="&deleteDirectory.accesskey;"/>
</vbox>
</hbox>
</dialog>

View File

@@ -1,147 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.
*
* The Initial Developer of the Original Code is
* Srilatha Moturi <srilatha@netscape.com>.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Rajiv Dayal <rdayal@netscape.com>
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gCurrentDirectoryPrefName;
var gReplicationService = Components.classes["@mozilla.org/addressbook/ldap-replication-service;1"].getService(Components.interfaces.nsIAbLDAPReplicationService);
var gProgressText;
var gProgressMeter;
var gReplicationBundle;
function onLoad()
{
var dirName;
if (window.arguments[0]) {
dirName = window.arguments[0].dirName;
gCurrentDirectoryPrefName = window.arguments[0].prefName;
}
gProgressText = document.getElementById("replication.status");
gProgressMeter = document.getElementById("replication.progress");
gReplicationBundle = document.getElementById("bundle_replication");
window.title = gReplicationBundle.getFormattedString("replicatingTitle", [dirName])
Replicate();
}
function DoReplicationClose()
{
// XXX todo, confirm the cancel
onCancelReplication(false);
return true;
}
var progressListener = {
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START) {
// start the spinning
gProgressMeter.setAttribute("mode","undetermined");
if (aStatus)
SetProgressText(gReplicationBundle.getString("replicationStarted"));
else
SetProgressText(gReplicationBundle.getString("changesStarted"));
}
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
// stop the spinning
gProgressMeter.setAttribute("mode","normal");
gProgressMeter.setAttribute("value", "100");
if (aStatus) {
SetProgressText(gReplicationBundle.getString("replicationSucceeded"));
}
else {
SetProgressText(gReplicationBundle.getString("replicationFailed"));
}
window.close();
}
},
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
{
SetProgressText(gReplicationBundle.getFormattedString("currentCount", [aCurSelfProgress]));
},
onLocationChange: function(aWebProgress, aRequest, aLocation)
{
},
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
{
},
onSecurityChange: function(aWebProgress, aRequest, state)
{
},
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
iid.equals(Components.interfaces.nsISupportsWeakReference))
return this;
throw Components.results.NS_NOINTERFACE;
}
};
function Replicate()
{
try {
gReplicationService.startReplication(gCurrentDirectoryPrefName, progressListener);
}
catch (ex) {
// XXX todo
// are you offline? If so, you need to go offline to use this
dump("replication failed. ex=" + ex + "\n");
}
}
function onCancelReplication(closeWindow)
{
try {
gReplicationService.cancelReplication(gCurrentDirectoryPrefName);
}
catch (ex) {
// XXX todo
// perhaps replication hasn't started yet? This can happen if you hit cancel after attempting to replication when offline
dump("unexpected failure while cancelling. ex=" + ex + "\n");
if (closeWindow)
window.close();
}
}
function SetProgressText(textStr)
{
gProgressText.value = textStr;
}

View File

@@ -1,82 +0,0 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.
-
- The Initial Developer of the Original Code is
- Srilatha Moturi <srilatha@netscape.com>
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Rajiv Dayal <rdayal@netscape.com>
- Seth Spitzer <sspitzer@netscape.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/replicationProgress.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="replicationProgress"
style="width: 36em;"
class="dialog"
onload="onLoad()"
onclose="return DoReplicationClose()">
<stringbundle id="bundle_replication" src="chrome://messenger/locale/addressbook/replicationProgress.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/replicationProgress.js"/>
<separator/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox pack="end">
<label value="&status.label;"/>
</hbox>
<label id="replication.status"/>
</row>
<row class="thin-separator">
<hbox pack="end">
<label value="&progress.label;"/>
</hbox>
<progressmeter id="replication.progress" mode="normal" value="0"/>
</row>
</rows>
</grid>
<separator/>
<hbox id="CancelButton" pack="end">
<button id="cancel" label="&replicationCancel.label;" accesskey="&replicationCancel.accesskey;" oncommand="onCancelReplication(true);"/>
</hbox>
</window>

View File

@@ -1 +0,0 @@
pref-addressing.dtd

View File

@@ -1,64 +0,0 @@
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
-->
<!ENTITY window.title "Addressing">
<!ENTITY pane.title "Addressing">
<!ENTITY pane.description "Settings for addressing messages">
<!ENTITY pinpoint.label "Pinpoint Addressing">
<!ENTITY lookFor.label "Look for addresses in the following:">
<!ENTITY padCheck.label "Address Books">
<!ENTITY padCheck.accesskey "a">
<!ENTITY dirCheck.label "Directory Server">
<!ENTITY dirCheck.accesskey "d">
<!ENTITY mulFound.label "When there are multiple addresses found:">
<!ENTITY showList.label "Show me a list of choices">
<!ENTITY showList.accesskey "s">
<!ENTITY acceptList.label "Accept what I have typed">
<!ENTITY acceptList.accesskey "c">
<!ENTITY oneMatch.label "If there is one match in your personal address books:">
<!ENTITY useAddress.label "Use the address and do not search in the directory">
<!ENTITY useAddress.accesskey "u">
<!ENTITY emailCollectionEnable.label "Enable Email Address Collection">
<!ENTITY emailCollectionIncomingEnable.label "Incoming Mail Messages">
<!ENTITY emailCollectionIncomingEnable.accesskey "I">
<!ENTITY emailCollectionOutgoingEnable.label "Outgoing Mail Messages">
<!ENTITY emailCollectionOutgoingEnable.accesskey "O">
<!ENTITY emailCollectionNewsgroupEnable.label "Outgoing Newsgroup Messages">
<!ENTITY emailCollectionNewsgroupEnable.accesskey "u">
<!ENTITY emailCollectionTypeText.label "Save email addresses from:">
<!ENTITY emailCollectiontitle.label "Email Address Collection">
<!ENTITY emailCollectiontext.label "Email addresses from messages can be added to a local address book, 'Collected Addresses'. Add email addresses from:">
<!ENTITY useCABSizelimitPart1.label "Limit the Collected Address book to">
<!ENTITY useCABSizelimitPart1.accesskey "L">
<!ENTITY useCABSizelimitPart2.label "cards">
<!ENTITY useCABSizelimitPart2.accesskey "c">
<!-- Autocompletion -->
<!ENTITY addressingTitle.label "Address Autocompletion">
<!-- LOCALIZATION NOTE (addressingText.label) : do not translate "LDAP" in below line -->
<!ENTITY addressingEnable.label "Local Address Books">
<!ENTITY addressingEnable.accesskey "A">
<!ENTITY autocompleteText.label "When addressing messages, look for matching entries in:">
<!ENTITY directories.label "Directory Server:">
<!ENTITY directories.accesskey "D">
<!ENTITY editDirectories.label "Edit Directories...">
<!ENTITY editDirectories.accesskey "E">
<!ENTITY matchText.label "If there is a match in your local address books:">
<!ENTITY skipDirectory.label "Do not search in the directory">

View File

@@ -1,60 +0,0 @@
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2002 Netscape Communications Corporation. All
Rights Reserved.
-->
<!ENTITY newDirectoryTitle.label "Directory Server Properties">
<!ENTITY directoryName.label "Name: ">
<!ENTITY directoryName.accesskey "n">
<!ENTITY directoryHostname.label "Hostname: ">
<!ENTITY directoryHostname.accesskey "o">
<!ENTITY directoryBaseDN.label "Base DN: ">
<!ENTITY directoryBaseDN.accesskey "b">
<!ENTITY findButton.label "Find">
<!ENTITY findButton.accesskey "f">
<!ENTITY directorySecure.label "Use secure connection (SSL)">
<!ENTITY directorySecure.accesskey "U">
<!ENTITY directoryLogin.label "Bind DN: ">
<!ENTITY directoryLogin.accesskey "i">
<!ENTITY advancedOptionsButton.label "Advanced Options">
<!ENTITY advancedOptionsButton.accesskey "a">
<!ENTITY General.tab "General">
<!ENTITY Offline.tab "Offline">
<!ENTITY Advanced.tab "Advanced">
<!ENTITY advancedOptionsTitle.label "Advanced Options">
<!ENTITY portNumber.label "Port number: ">
<!ENTITY portNumber.accesskey "p">
<!ENTITY searchFilter.label "Search filter: ">
<!ENTITY searchFilter.accesskey "f">
<!ENTITY scope.label "Scope: ">
<!ENTITY scope.accesskey "c">
<!ENTITY scopeOneLevel.label "One Level">
<!ENTITY scopeOneLevel.accesskey "L">
<!ENTITY scopeSubtree.label "Subtree">
<!ENTITY scopeSubtree.accesskey "S">
<!ENTITY return.label "Don't return more than">
<!ENTITY return.accesskey "r">
<!ENTITY results.label "results">
<!ENTITY offlineText.label "You can download a local copy of this directory so that it is available for use when you are working offline.">
<!ENTITY downloadNowButton.label "Download Now">
<!ENTITY downloadNowButton.accesskey "D">
<!-- Localization note: this is here because the width of the dialog
is determined by the width of the base DN box; and that is likely
to vary somewhat with the language.
-->
<!ENTITY newDirectoryWidth "36em">

View File

@@ -1,37 +0,0 @@
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
-->
<!-- LOCALIZATION NOTE (window.title) : do not translate "LDAP" in below line -->
<!ENTITY window.title "LDAP Directory Servers">
<!ENTITY pane.title "Directory">
<!ENTITY directory.label "Add a directory">
<!-- LOCALIZATION NOTE (directories.label) : do not translate "LDAP" in below line -->
<!ENTITY directories.label "LDAP Directory Server:">
<!-- LOCALIZATION NOTE (directoriesText.label) : do not translate "LDAP" in below line -->
<!ENTITY directoriesText.label "Select an LDAP Directory Server:">
<!ENTITY directoriesText.accesskey "S">
<!-- LOCALIZATION NOTE (autocomplete.title) : do not translate "LDAP" in below line -->
<!ENTITY autocomplete.title "LDAP Directory Server">
<!ENTITY addDirectory.label "Add">
<!ENTITY addDirectory.accesskey "a">
<!ENTITY editDirectory.label "Edit">
<!ENTITY editDirectory.accesskey "e">
<!ENTITY deleteDirectory.label "Delete">
<!ENTITY deleteDirectory.accesskey "d">

View File

@@ -1,41 +0,0 @@
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.
-
- The Initial Developer of the Original Code is
- Srilatha Moturi <srilatha@netscape.com>
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Rajiv Dayal <rdayal@netscape.com>
- Seth Spitzer <sspitzer@netscape.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY status.label "Status:">
<!ENTITY progress.label "Progress:">
<!ENTITY replicationCancel.label "Cancel">
<!ENTITY replicationCancel.accesskey "C">

View File

@@ -1,55 +0,0 @@
#***** BEGIN LICENSE BLOCK *****
#Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
#The contents of this file are subject to the Mozilla Public License Version
#1.1 (the "License"); you may not use this file except in compliance with
#the License. You may obtain a copy of the License at
#http://www.mozilla.org/MPL/
#
#Software distributed under the License is distributed on an "AS IS" basis,
#WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
#for the specific language governing rights and limitations under the
#License.
#
#The Original Code is mozilla.
#
#The Initial Developer of the Original Code is
# Srilatha Moturi <srilatha@netscape.com>.
#Portions created by the Initial Developer are Copyright (C) 2002
#the Initial Developer. All Rights Reserved.
#
#Contributor(s):
# Rajiv Dayal <rdayal@netscape.com>
# Seth Spitzer <sspitzer@netscape.com>
#
#Alternatively, the contents of this file may be used under the terms of
#either the GNU General Public License Version 2 or later (the "GPL"), or
#the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
#in which case the provisions of the GPL or the LGPL are applicable instead
#of those above. If you wish to allow use of your version of this file only
#under the terms of either the GPL or the LGPL, and not to allow others to
#use your version of this file under the terms of the MPL, indicate your
#decision by deleting the provisions above and replace them with the notice
#and other provisions required by the GPL or the LGPL. If you do not delete
#the provisions above, a recipient may use your version of this file under
#the terms of any one of the MPL, the GPL or the LGPL.
#
#***** END LICENSE BLOCK *****
replicationStarted=Replication started...
changesStarted=Started finding changes to replicate...
replicationSucceeded=Replication succeeded
replicationFailed=Replication failed
# LOCALIZATION NOTE
# do not localize %S. %S is the current entry number (an integer)
currentCount=Replicating directory entry: %S
# LOCALIZATION NOTE
# do not localize %S. %S is the current address book name
replicatingTitle=Replicating %S
replicationOfSameInProgress=A replication of this directory is already in progress.
replicationOfOtherInProgress=A replication of another directory is already in progress. You can only replicate one directory at a time.
mustBeOnlineToReplicate=You must be online to replicate a directory.
# LOCALIZATION NOTE
# do not localize %S. %S is the product name.
replicationInProgress=%S is currently in the process of replicating an address book. Would you like to wait until the process has completed before quitting or quit now?
waitButton=Wait
quitButton=Quit

View File

@@ -1,22 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# This is a list of local files which get copied to the mozilla:dist:mailnews directory
#

View File

@@ -1,7 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist:idl directory
#
nsIAbAddressCollecter.idl
nsIAbUpgrader.idl

View File

@@ -1,66 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = addrbook
XPIDLSRCS = \
nsIAbListener.idl \
nsIAbDirectory.idl \
nsIAbCard.idl \
nsIAbMDBDirectory.idl \
nsIAbMDBCard.idl \
nsIAddrDBAnnouncer.idl \
nsIAddrDBListener.idl \
nsIAddrDatabase.idl \
nsIAddressBook.idl \
nsIAbBase.idl \
nsIAddrBookSession.idl \
nsIAbAutoCompleteSession.idl \
nsIAbAddressCollecter.idl \
nsIAbUpgrader.idl \
nsIAddbookUrl.idl \
nsIAbDirFactory.idl \
nsIAbDirFactoryService.idl \
nsIAbDirectoryQueryProxy.idl \
nsIAbDirectoryQuery.idl \
nsIAbBooleanExpression.idl \
nsIAbDirectorySearch.idl \
nsIAbView.idl \
$(NULL)
ifdef MOZ_LDAP_XPCOM
XPIDLSRCS += \
nsILDAPPrefsService.idl \
nsIAbLDAPAutoCompFormatter.idl \
nsIAbLDAPReplicationService.idl \
nsIAbLDAPReplicationQuery.idl \
nsIAbLDAPReplicationData.idl \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,53 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
[scriptable, uuid(fe04c8e6-501e-11d3-a527-0060b0fc04b7)]
interface nsIAbAddressCollecter : nsISupports {
void collectAddress(in string address);
/* CollectUnicodeAddress is the most I18N friendly
of the two methods to call. If you just take a char * address
as used by CollectAddress then you don't know what char set
the address is in (UTF-8??).
*/
void collectUnicodeAddress(in wstring address);
};

View File

@@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
[scriptable, uuid(CA2A6B08-3625-11d3-988E-001083010E9B)]
interface nsIAbAutoCompleteListener : nsISupports {
void onAutoCompleteResult(in nsISupports aParam, in wstring aOriginalString, in wstring aMatch);
};

View File

@@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIAutoCompleteSession.idl"
#include "nsIMsgIdentity.idl"
[scriptable, uuid(CA2A6B07-3625-11d3-988E-001083010E9B)]
interface nsIAbAutoCompleteSession : nsIAutoCompleteSession {
attribute wstring defaultDomain;
};

View File

@@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsICollection.idl"
[scriptable, uuid(013DD009-F73B-11d2-A2DA-001083003D0C)]
interface nsIAbBase : nsICollection {
readonly attribute string URI;
attribute string name;
nsISupports GetChildNamed(in string name);
attribute nsIAbBase parent;
nsIEnumerator GetChildNodes();
void AddUnique(in nsISupports element);
void ReplaceElement(in nsISupports element, in nsISupports newElement);
};

View File

@@ -1,168 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Created by: Paul Sandoz <paul.sandoz@sun.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
typedef long nsAbBooleanConditionType;
/**
* Condition types
*
* Constants defining the types of condition
* to obtain a boolean result of TRUE or FALSE
*
*/
[scriptable, uuid(F51387B1-5AEF-4A1C-830E-7CD3B02366CE)]
interface nsIAbBooleanConditionTypes
{
const long Exists = 0;
const long DoesNotExist = 1;
const long Contains = 2;
const long DoesNotContain = 3;
const long Is = 4;
const long IsNot = 5;
const long BeginsWith = 6;
const long EndsWith = 7;
const long LessThan = 8;
const long GreaterThan = 9;
const long SoundsLike = 10;
const long RegExp = 11;
};
typedef long nsAbBooleanOperationType;
/*
* Operation types
*
* Constants defining the boolean operation that
* should be performed between two boolean expressions
*
*/
[uuid(9bdd2e51-2be4-49a4-a558-36d1a812231a)]
interface nsIAbBooleanOperationTypes
{
const long AND = 0;
const long OR = 1;
const long NOT = 2;
};
/**
* String condition
*
* A string condition represents a leaf node in a
* boolean expression tree and represents
* test which will return TRUE or FALSE
*
* Condition is an expression which is a
* leaf node in a boolean expression tree
*
*/
[scriptable, uuid(C3869D72-CFD0-45F0-A0EC-3F67D83C7110)]
interface nsIAbBooleanConditionString : nsISupports
{
/**
* The condition for how the a value
* should be compared
*
*/
attribute nsAbBooleanConditionType condition;
/**
* The lhs of the condition
*
* Represents a property name which
* should be evaluated to obtain the
* lhs.
*
*/
attribute string name;
/**
* The rhs of the condition
*
* <name> [condition] value
*
*/
attribute wstring value;
};
/**
* N Boolean expression type
*
* Supports Unary Binary and N boolean expressions
*
* An operation represents a node in a boolean
* expression tree which may contain one or more
* child conditions or expressions
*
*/
[scriptable, uuid(67F87C44-2C63-41A2-9545-AFF1D9F09623)]
interface nsIAbBooleanExpression: nsISupports
{
/**
* The boolean operation to be applied to
* results of all evaluated expressions
*
*/
attribute nsAbBooleanOperationType operation;
/**
* List of peer expressions
*
* e1 [op] e2 [op] .... en
*
*/
attribute nsISupportsArray expressions;
/**
* expressions attribute defined explicitly as an
* array of nsISupports
*
*/
void asetExpressions (in unsigned long aExpressionsSize,
[array, size_is(aExpressionsSize)]
in nsISupports aExpressionsArray);
void agetExpressions (out unsigned long aExpressionsSize,
[retval, array, size_is(aExpressionsSize)]
out nsISupports aExpressionsArray);
};

Some files were not shown because too many files have changed in this diff Show More