Changes for OS/2. Patch provided by Eric Olson (eric.olson@sympatico.ca)

This commit is contained in:
mcafee%netscape.com 1999-06-28 23:11:18 +00:00
Родитель ef4a318bdb
Коммит f81dc61901
19 изменённых файлов: 2353 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,49 @@
# 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 the Mozilla OS/2 libraries.
#
# The Initial Developer of the Original Code is John Fairhurst,
# <john_fairhurst@iname.com>. Portions created by John Fairhurst are
# Copyright (C) 1999 John Fairhurst. All Rights Reserved.
DEPTH = ../../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = nglocale
MODULE = locale
REQUIRES = xpcom unicharutil
EXPORTS = nsILocaleOS2.h
CPPSRCS = \
nsLocaleOS2.cpp \
nsLocaleFactoryOS2.cpp \
nsCollationOS2.cpp \
nsDateTimeFormatOS2.cpp \
nsLocaleDllOS2.cpp \
$(NULL)
IS_COMPONENT=1
OS2_IMPLIB = 1
OS2_LIBRARYNAME = nglocale
OS2_LIBS = libuni xpcom ngbase libnslocale_s
OS_LIBS += $(NSPR_LIBS)
INCLUDES += $(srcdir) $(srcdir)/..
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,228 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#define INCL_DOS
#include <os2.h>
#include "unidef.h"
#include "nscore.h"
#include "nsCollationOS2.h"
#include "nsILocaleOS2.h"
static NS_DEFINE_IID(kILocaleOS2IID, NS_ILOCALEOS2_IID);
static NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
static NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsCollationOS2, kICollationIID)
// init/term
nsCollationOS2::nsCollationOS2() : mLocaleObject(0), mLocale(nsnull)
{
NS_INIT_REFCNT();
}
nsCollationOS2::~nsCollationOS2()
{
NS_IF_RELEASE(mLocale);
}
nsresult nsCollationOS2::Initialize( nsILocale *aLocale)
{
nsILocaleOS2 *mOS2Locale = nsnull;
nsresult rc = aLocale->QueryInterface( kILocaleOS2IID,
(void**) &mOS2Locale);
if( NS_SUCCEEDED(rc))
{
mLocale = aLocale;
NS_ADDREF(mLocale);
mOS2Locale->GetLocaleObject( &mLocaleObject);
NS_RELEASE(mOS2Locale);
}
return rc;
}
// sort-key creation
// get a length (of character) of a sort key to be generated by an
// input string length is a byte length
nsresult nsCollationOS2::GetSortKeyLen( const nsCollationStrength aStrength,
const nsString &aStringIn,
PRUint32 *aOutLen)
{
if( !aOutLen)
return NS_ERROR_NULL_POINTER;
size_t num_elems = UniStrxfrm( mLocaleObject, nsnull,
aStringIn.GetUnicode(), 0);
*aOutLen = 2 * num_elems; // out is in bytes
return NS_OK;
}
// create sort key from input string
// length is a byte length, caller should allocate a memory for a key
nsresult nsCollationOS2::CreateRawSortKey( const nsCollationStrength aStrength,
const nsString &aStringIn,
PRUint8 *aKey,
PRUint32 *aOutLen)
{
if( !aKey || !aOutLen)
return NS_ERROR_NULL_POINTER;
UniStrxfrm( mLocaleObject, (UniChar*) aKey,
aStringIn.GetUnicode(), *aOutLen / 2);
// XXX hmm
if( aStrength & kCollationCaseInsensitiveAscii)
{
#if 0
// XXX this is correct, but is it guaranteed not to alter the
// length of key needed? Ought we to do this in the 'getkeylen'
// function above as well?
//
// XXX Don't currently support the 'no accent' comparison; may have
// to bite the bullet & use the mozilla function, if it ever
// arrives.
//
XformObject xform_object = 0;
int iSize = -1, oSize = aStringIn.Length() + 1;
UniChar *xformed = new UniChar [ oSize];
UniCreateTransformObject( mLocaleObject, L"lower", &xform_object);
UniTransformStr( xform_object,
(const UniChar *) aStringIn.GetUnicode(),
&iSize, xformed, &oSize);
UniFreeTransformObject( xform_object);
UniStrxfrm( mLocaleObject, (UniChar*) aKey, xformed, *aOutLen / 2);
delete [] xformed;
#else
UniStrlwr( (UniChar*) aKey);
#endif
}
return NS_OK;
}
// compare two sort keys
// length is a byte length, result is same as strcmp
nsresult nsCollationOS2::CompareRawSortKey( const PRUint8 *aKey1,
const PRUint32 aLen1,
const PRUint8 *aKey2,
const PRUint32 aLen2,
PRInt32 *aResult)
{
if( !aKey1 || !aKey2 || !aResult)
return NS_ERROR_NULL_POINTER;
*aResult = UniStrcmp( (UniChar*) aKey1, (UniChar*) aKey2);
return NS_OK;
}
// create a sort key (nsString)
nsresult nsCollationOS2::CreateSortKey( const nsCollationStrength aStrength,
const nsString &aStringIn,
nsString &aKey)
{
PRUint32 length = 0;
PRUint8 *key = nsnull;
nsresult rc = GetSortKeyLen( aStrength, aStringIn, &length);
if( NS_SUCCEEDED(rc))
{
key = new PRUint8[ length];
CreateRawSortKey( aStrength, aStringIn, key, &length);
aKey.SetString( (PRUnichar*) key);
delete [] key;
}
return rc;
}
// compare two sort keys (nsString)
nsresult nsCollationOS2::CompareSortKey( const nsString &aKey1,
const nsString &aKey2,
PRInt32 *aResult)
{
return CompareRawSortKey( (const PRUint8 *) aKey1.GetUnicode(),
(aKey1.Length() + 1) * 2,
(const PRUint8 *) aKey2.GetUnicode(),
(aKey2.Length() + 1) * 2,
aResult);
}
// compare two strings; result is same as strcmp
nsresult nsCollationOS2::CompareString( const nsCollationStrength aStrength,
const nsString &aString1,
const nsString &aString2,
PRInt32 *aResult)
{
if( !aResult)
return NS_ERROR_NULL_POINTER;
nsString key1, key2;
CreateSortKey( aStrength, aString1, key1);
CreateSortKey( aStrength, aString2, key2);
return CompareSortKey( key1, key2, aResult);
}
// nsCollationFactoryOS2 implementation
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsCollationFactoryOS2,kICollationFactoryIID)
// init/term
nsCollationFactoryOS2::nsCollationFactoryOS2()
{
NS_INIT_REFCNT();
}
nsCollationFactoryOS2::~nsCollationFactoryOS2()
{
}
// strange factory method
nsresult nsCollationFactoryOS2::CreateCollation( nsILocale *aLocale,
nsICollation **aInstance)
{
if( !aLocale || !aInstance)
return NS_ERROR_NULL_POINTER;
nsCollationOS2 *coll = new nsCollationOS2;
nsresult rc = coll->Initialize( aLocale);
if( NS_SUCCEEDED(rc))
{
NS_ADDREF(coll);
*aInstance = coll;
}
else
delete coll;
return rc;
}

Просмотреть файл

@ -0,0 +1,96 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _nscollationos2_h_
#define _nscollationos2_h_
#include "nsICollation.h"
class nsILocaleOS2;
class nsCollationOS2 : public nsICollation
{
public:
nsCollationOS2();
virtual ~nsCollationOS2();
// nsISupports
NS_DECL_ISUPPORTS
// nsICollation
// compare two strings; result is same as strcmp
NS_IMETHOD CompareString( const nsCollationStrength aStrength,
const nsString &aString1,
const nsString &aString2,
PRInt32 *aResult);
// get a length (of character) of a sort key to be generated by an
// input string length is a byte length
NS_IMETHOD GetSortKeyLen( const nsCollationStrength aStrength,
const nsString &aStringIn,
PRUint32 *aOutLen);
// create sort key from input string
// length is a byte length, caller should allocate a memory for a key
NS_IMETHOD CreateRawSortKey( const nsCollationStrength aStrength,
const nsString &aStringIn,
PRUint8 *aKey,
PRUint32 *aOutLen);
// create a sort key (nsString)
NS_IMETHOD CreateSortKey( const nsCollationStrength aStrength,
const nsString &aStringIn,
nsString &aKey);
// compare two sort keys
// length is a byte length, result is same as strcmp
NS_IMETHOD CompareRawSortKey( const PRUint8 *aKey1, const PRUint32 aLen1,
const PRUint8 *aKey2, const PRUint32 aLen2,
PRInt32 *aResult);
// compare two sort keys (nsString)
NS_IMETHOD CompareSortKey( const nsString &aKey1,
const nsString &aKey2,
PRInt32 *aResult);
// init to a specified locale
NS_IMETHOD Initialize( nsILocale *aLocale);
protected:
LocaleObject mLocaleObject;
nsILocale *mLocale;
};
// Strange collationfactory class
class nsCollationFactoryOS2 : public nsICollationFactory
{
public:
nsCollationFactoryOS2();
virtual ~nsCollationFactoryOS2();
// nsISupports
NS_DECL_ISUPPORTS
// nsICollationFactory
NS_IMETHOD CreateCollation( nsILocale *aLocale, nsICollation **aInstance);
};
#endif

Просмотреть файл

@ -0,0 +1,175 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#define INCL_DOS
#include <os2.h>
#include "unidef.h"
#include "ulsitem.h"
#include "nsDateTimeFormatOS2.h"
#include "nsILocaleOS2.h"
static NS_DEFINE_IID(kILocaleOS2IID, NS_ILOCALEOS2_IID);
static NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsDateTimeFormatOS2,kIDateTimeFormatIID)
// ctor/dtor
nsDateTimeFormatOS2::nsDateTimeFormatOS2()
{
NS_INIT_REFCNT();
}
nsDateTimeFormatOS2::~nsDateTimeFormatOS2()
{
}
// nsIDateTimeFormat
nsresult nsDateTimeFormatOS2::FormatTime( nsILocale *aLocale,
const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const time_t aTime,
nsString &aStringOut)
{
struct tm *now = 0;
now = localtime( &aTime); // XXX dodgy (this whole thing ought to be using
// PRTimes etc., anyway)
return FormatTMTime( aLocale, aDateFormatSelector, aTimeFormatSelector,
now, aStringOut);
}
// performs a locale sensitive date formatting operation on the struct tm parameter
nsresult nsDateTimeFormatOS2::FormatTMTime( nsILocale *aLocale,
const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const struct tm *aTime,
nsString &aStringOut)
{
if( !aLocale || !aTime)
return NS_ERROR_NULL_POINTER;
nsILocaleOS2 *os2locale = 0;
nsresult rc = NS_ERROR_FAILURE;
// find a sane locale object
if( NS_SUCCEEDED(aLocale->QueryInterface( kILocaleOS2IID,
(void**) &os2locale)))
{
LocaleObject locale_object = 0;
os2locale->GetLocaleObject( &locale_object);
NS_RELEASE(os2locale);
// Build up a strftime-style format string - date first and then
// time.
//
// XXX Usage of %c for "long date" copied from unix, even though
// it's documented as producing time as well. Change it if
// weird things happen.
//
// XXX Not sure when if ever we should look at PM_National in the
// ini and override locale-defaults. Maybe only if this locale
// is the same as the system's LC_TIME locale?
//
#define FORMAT_BUFF_LEN 20 // update this if things get complex below
UniChar format[ FORMAT_BUFF_LEN] = { 0 };
UniChar *pString = nsnull;
// date
switch( aDateFormatSelector)
{
case kDateFormatNone:
break;
case kDateFormatLong:
UniStrcat( format, (UniChar*)L"%c");
break;
case kDateFormatShort:
UniStrcat( format, (UniChar*)L"%x");
break;
case kDateFormatYearMonth:
UniQueryLocaleItem( locale_object, DATESEP, &pString);
UniStrcat( format, (UniChar*)L"%y");
UniStrcat( format, pString);
UniStrcat( format, (UniChar*)L"%m");
UniFreeMem( pString);
break;
case kDateFormatWeekday:
UniStrcat( format, (UniChar*)L"%a");
break;
default:
printf( "Unknown date format (%d)\n", aDateFormatSelector);
break;
}
// space between date & time
if( aDateFormatSelector != kDateFormatNone &&
aTimeFormatSelector != kTimeFormatNone)
UniStrcat( format, (UniChar*)L" ");
// time
switch( aTimeFormatSelector)
{
case kTimeFormatNone:
break;
case kTimeFormatSeconds:
UniStrcat( format, (UniChar*)L"%r");
break;
case kTimeFormatNoSeconds:
UniQueryLocaleItem( locale_object, TIMESEP, &pString);
UniStrcat( format, (UniChar*)L"%I");
UniStrcat( format, pString);
UniStrcat( format, (UniChar*)L"%M %p");
UniFreeMem( pString);
break;
case kTimeFormatSecondsForce24Hour:
UniStrcat( format, (UniChar*)L"%T");
break;
case kTimeFormatNoSecondsForce24Hour:
UniStrcat( format, (UniChar*)L"%R");
break;
default:
printf( "Unknown time format (%d)\n", aTimeFormatSelector);
break;
}
// now produce the string (dodgy buffer - iwbn if the function
// had a handy `pass-me-null-to-find-the-length' mode).
UniChar buffer[ 100]; // surely ample?
size_t ret = UniStrftime( locale_object, buffer, 100, format, aTime);
if( ret == 0)
{
printf( "UniStrftime needs a bigger buffer, rethink\n");
}
else
{
aStringOut.SetString( (const PRUnichar*) buffer);
rc = NS_OK;
}
}
return rc;
}

Просмотреть файл

@ -0,0 +1,55 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _nsdatetimeformatos2_h_
#define _nsdatetimeformatos2_h_
#include "nsIDateTimeFormat.h"
class nsILocaleOS2;
class nsDateTimeFormatOS2 : public nsIDateTimeFormat
{
public:
nsDateTimeFormatOS2();
virtual ~nsDateTimeFormatOS2();
// nsISupports
NS_DECL_ISUPPORTS
// nsIDateTimeFormat
// performs a locale sensitive date formatting operation on a time_t
NS_IMETHOD FormatTime( nsILocale *aLocale,
const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const time_t aTime,
nsString &aStringOut);
// performs a locale sensitive date formatting operation on the struct tm parameter
NS_IMETHOD FormatTMTime( nsILocale *aLocale,
const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const struct tm *aTime,
nsString &aStringOut);
};
#endif

Просмотреть файл

@ -0,0 +1,52 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _nsilocaleos2_h_
#define _nsilocaleos2_h_
#include "nsISupports.h"
#include "unidef.h" // for LocaleObject
class nsString;
// XXX I made this IID up. Get a legit one when we land the branch.
// {00932BE1-B65A-11d2-AF0B-aa60089FE59B}
#define NS_ILOCALEOS2_IID \
{ 0x932be1, 0xb65a, 0x11d2, \
{ 0xaf, 0xb, 0xaa, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
class nsILocaleOS2 : public nsISupports
{
public:
// Init a complex locale - categories should be magic nsLocale words
NS_IMETHOD Init( nsString **aCatList,
nsString **aValList,
PRUint8 aLength) = 0;
// Init a locale object from a xx-XX style name
NS_IMETHOD Init( const nsString &aLocaleName) = 0;
// Get the OS/2 locale object
NS_IMETHOD GetLocaleObject( LocaleObject *aLocaleObject) = 0;
};
#endif

Просмотреть файл

@ -0,0 +1,188 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#include "nscore.h"
#include "nsLocaleOS2.h"
#include "nsLocaleFactoryOS2.h"
#include "nsCollationOS2.h"
#include "nsDateTimeFormatOS2.h"
#include "nsLocaleCID.h"
#include "nsCollationCID.h"
#include "nsDateTimeFormatCID.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
static NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
static NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
static NS_DEFINE_IID(kILocaleFactoryIID,NS_ILOCALEFACTORY_IID);
static NS_DEFINE_CID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
static NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID);
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
// Okay, this is very weird: for some crazy reason known only to the
// intl@netscape folks, nsILocaleFactory exists. This makes things
// more complicated here than in other DLLs.
//
// Note that nsICollationFactory is *not* an nsIFactory.
//
// How on earth are people supposed to create nsILocale objects?
// Or call methods from nsILocaleFactory ?
// In fact this must be wrong: say I want to create an nsILocaleFactory.
// NSGetFactory() here gives the CM not a factory to create these but
// an actual nsILocaleFactory. CreateInstance() on that then gives me
// the system locale. What on earth is going on!
class nsLocaleDllFactory : public nsIFactory
{
public:
nsLocaleDllFactory( const nsCID &aClass);
virtual ~nsLocaleDllFactory() {}
// nsISupports
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance( nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory( PRBool aLock) { return NS_OK; }
protected:
nsCID mClassID;
};
nsLocaleDllFactory::nsLocaleDllFactory( const nsCID &aClass)
{
NS_INIT_REFCNT();
mClassID = aClass;
}
NS_IMPL_ISUPPORTS(nsLocaleDllFactory,nsIFactory::GetIID())
nsresult nsLocaleDllFactory::CreateInstance( nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if( !aResult)
return NS_ERROR_NULL_POINTER;
*aResult = nsnull;
nsISupports *inst = nsnull;
if( aIID.Equals( kICollationFactoryIID))
inst = new nsCollationFactoryOS2;
else if( aIID.Equals( kICollationIID))
inst = new nsCollationOS2;
else if( aIID.Equals( kIDateTimeFormatIID))
inst = new nsDateTimeFormatOS2;
else
return NS_NOINTERFACE;
if( inst == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rc = inst->QueryInterface( aIID, aResult);
if( NS_FAILED(rc))
delete inst;
return rc;
}
// Find a factory
extern "C" NS_EXPORT nsresult NSGetFactory( nsISupports *aServiceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if( !aFactory || !aServiceMgr)
return NS_ERROR_NULL_POINTER;
nsIFactory *fact = nsnull;
nsresult rc = NS_ERROR_FAILURE;
// first check for strange localefactory class
if( aClass.Equals( kLocaleFactoryCID))
{
fact = new nsLocaleFactoryOS2;
// XXX this next line looks a bit wrong, but hey...
rc = fact->QueryInterface( kILocaleFactoryIID, (void **) aFactory);
}
else // something sensible
{
fact = new nsLocaleDllFactory( aClass);
rc = fact->QueryInterface( nsIFactory::GetIID(), (void**)aFactory);
}
if( NS_FAILED(rc))
delete fact;
return rc;
}
// Register classes
extern "C" NS_EXPORT nsresult NSRegisterSelf( nsISupports *aServMgr,
const char *aPath)
{
nsresult rc;
NS_WITH_SERVICE1( nsIComponentManager, pCompMgr, aServMgr,
kComponentManagerCID, &rc);
if( NS_FAILED(rc)) return rc;
pCompMgr->RegisterComponent( kLocaleFactoryCID, NULL, NULL,
aPath, PR_TRUE, PR_TRUE);
pCompMgr->RegisterComponent( kCollationFactoryCID, NULL, NULL,
aPath, PR_TRUE, PR_TRUE);
pCompMgr->RegisterComponent( kCollationCID, NULL, NULL,
aPath, PR_TRUE, PR_TRUE);
pCompMgr->RegisterComponent( kDateTimeFormatCID, NULL, NULL,
aPath, PR_TRUE, PR_TRUE);
return rc;
}
// Deregister classes
extern "C" NS_EXPORT nsresult NSUnregisterSelf( nsISupports *aServMgr,
const char *aPath)
{
nsresult rc;
NS_WITH_SERVICE1( nsIComponentManager, pCompMgr, aServMgr,
kComponentManagerCID, &rc);
if( NS_FAILED(rc)) return rc;
pCompMgr->UnregisterComponent( kLocaleFactoryCID, aPath);
pCompMgr->UnregisterComponent( kCollationFactoryCID, aPath);
pCompMgr->UnregisterComponent( kCollationCID, aPath);
pCompMgr->UnregisterComponent( kDateTimeFormatCID, aPath);
return NS_OK;
}
// XXX NSCanUnload not implemented

Просмотреть файл

@ -0,0 +1,107 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#include "nscore.h"
#include "nsLocaleFactoryOS2.h"
// ctor/dtor
nsLocaleFactoryOS2::nsLocaleFactoryOS2() : mSysLocale(nsnull),
mAppLocale(nsnull)
{
// don't need to init the ref-count because XP nsLocaleFactory does that.
}
nsLocaleFactoryOS2::~nsLocaleFactoryOS2()
{
NS_IF_RELEASE(mSysLocale);
NS_IF_RELEASE(mAppLocale);
}
// nsILocaleFactory
nsresult nsLocaleFactoryOS2::NewLocale( nsString **aCatList,
nsString **aValList,
PRUint8 aCount,
nsILocale **aLocale)
{
if( !aCatList || !aValList || !aLocale)
return NS_ERROR_NULL_POINTER;
nsLocaleOS2 *aLoc = new nsLocaleOS2;
nsresult rc = aLoc->Init( aCatList, aValList, aCount);
if( NS_FAILED(rc))
delete aLoc;
else
{
NS_ADDREF(aLoc);
*aLocale = aLoc;
}
return rc;
}
nsresult nsLocaleFactoryOS2::NewLocale( const nsString *aName,
nsILocale **aLocale)
{
if( !aName || !aLocale)
return NS_ERROR_NULL_POINTER;
nsLocaleOS2 *aLoc = new nsLocaleOS2;
nsresult rc = aLoc->Init( *aName);
if( NS_FAILED(rc))
delete aLoc;
else
{
NS_ADDREF(aLoc);
*aLocale = aLoc;
}
return rc;
}
nsresult nsLocaleFactoryOS2::GetSystemLocale( nsILocale **aSysLocale)
{
if( !aSysLocale)
return NS_ERROR_NULL_POINTER;
if( !mSysLocale)
mSysLocale = new nsSystemLocale;
NS_ADDREF(mSysLocale);
return NS_OK;
}
nsresult nsLocaleFactoryOS2::GetApplicationLocale( nsILocale **aAppLocale)
{
if( !aAppLocale)
return NS_ERROR_NULL_POINTER;
if( !mAppLocale)
mAppLocale = new nsApplicationLocale;
NS_ADDREF(mAppLocale);
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,51 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _nslocalefactoryos2_h_
#define _nslocalefactoryos2_h_
#include "nsLocaleFactory.h"
#include "nsLocaleOS2.h" // for sys/app typedef (sorry!)
// Although we pretty-much do our own thing for locale on OS/2 due to the
// rich set of native functions, it is necessary to derive this class from
// the XP nsLocaleFactory to take advantage of the GetLocaleFromAcceptLanguage()
// method. Doing this probably drags in a load of unused XP locale code :-(
//
class nsLocaleFactoryOS2 : public nsLocaleFactory
{
public:
nsLocaleFactoryOS2();
virtual ~nsLocaleFactoryOS2();
// nsILocaleFactory
NS_IMETHOD NewLocale( nsString **aCatList, nsString **aValList,
PRUint8 aCount, nsILocale **aLocale);
NS_IMETHOD NewLocale( const nsString *aLocaleName, nsILocale **aLocale);
NS_IMETHOD GetSystemLocale( nsILocale **aSystemLocale);
NS_IMETHOD GetApplicationLocale( nsILocale **aApplicationLocale);
protected:
nsSystemLocale *mSysLocale;
nsApplicationLocale *mAppLocale;
};
#endif

Просмотреть файл

@ -0,0 +1,251 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#define INCL_DOS
#include <os2.h>
#include "unidef.h"
#include "nscore.h"
#include "nsLocaleOS2.h"
static NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
static NS_DEFINE_IID(kILocaleOS2IID, NS_ILOCALEOS2_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// for now
#ifndef DEBUG
#define DEBUG
#endif
// nsISupports implementation
NS_IMPL_ADDREF(nsLocaleOS2)
NS_IMPL_RELEASE(nsLocaleOS2)
nsresult nsLocaleOS2::QueryInterface( const nsIID &aIID, void **aInstancePtr)
{
if( !aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
if( aIID.Equals( kILocaleOS2IID))
*aInstancePtr = (void*) ((nsILocaleOS2*)this);
else if( aIID.Equals( kILocaleIID))
*aInstancePtr = (void*) ((nsILocale*)this);
else if( aIID.Equals( kISupportsIID))
*aInstancePtr = (void*) ((nsISupports*)(nsILocale*)(this));
if( !*aInstancePtr)
return NS_NOINTERFACE;
NS_ADDREF_THIS();
return NS_OK;
}
// ctor-dtor
nsLocaleOS2::nsLocaleOS2() : mLocaleObject(nsnull)
{
NS_INIT_REFCNT();
}
nsLocaleOS2::~nsLocaleOS2()
{
if( mLocaleObject)
UniFreeLocaleObject( mLocaleObject);
}
// convert from a 'cool' netscape-style locale category to a sensible index
#define NUM_LOCALE_CATEGORIES 6
static int GetLocaleCategory( const nsString *aCat)
{
int category = -1;
if( aCat->Equals( "NSILOCALE_TIME")) category = LC_TIME;
else if( aCat->Equals( "NSILOCALE_COLLATE")) category = LC_COLLATE;
else if( aCat->Equals( "NSILOCALE_CTYPE")) category = LC_CTYPE;
else if( aCat->Equals( "NSILOCALE_MONETARY")) category = LC_MONETARY;
else if( aCat->Equals( "NSILOCALE_MESSAGES")) category = LC_MESSAGES;
else if( aCat->Equals( "NSILOCALE_NUMERIC")) category = LC_NUMERIC;
return category;
}
// nsILocaleOS2
// Init a complex locale - categories should be magic nsLocale words
nsresult nsLocaleOS2::Init( nsString **aCatList,
nsString **aValList,
PRUint8 aLength)
{
char categories[NUM_LOCALE_CATEGORIES][12];
PRUint8 i = 0;
if( aLength < NUM_LOCALE_CATEGORIES)
{
// query default locale to fill in unspecified gaps in supplied info
LocaleObject def_locale;
UniCreateLocaleObject( UNI_MBS_STRING_POINTER,
(const void*) "", &def_locale);
char *pszLCALL, *pszCategory;
UniQueryLocaleObject( def_locale, LC_ALL, UNI_MBS_STRING_POINTER,
(void **)&pszLCALL);
// init categories array from it
pszCategory = strtok( pszLCALL, " ");
while( pszCategory)
{
strcpy( categories[i], pszCategory);
i++;
pszCategory = strtok( 0, " ");
}
// fill in anything that didn't work (hmm)
for( ; i < NUM_LOCALE_CATEGORIES; i++)
strcpy( categories[i], "en_US");
// free up locale stuff
UniFreeMem( pszLCALL);
UniFreeLocaleObject( def_locale);
}
// now fill in categories passed in
for( i = 0; i < aLength; i++)
{
int category = GetLocaleCategory( aCatList[i]);
if( category != -1)
aValList[i]->ToCString( categories[i], 12);
#ifdef DEBUG
else
{
char buff[12];
aValList[i]->ToCString( buff, 12);
printf( "Bad locale magic %s\n", buff);
}
#endif
}
// build string of the various locales & create an object.
nsresult rc = NS_OK;
char localebuff[80];
sprintf( localebuff, "%s %s %s %s %s %s",
categories[0], categories[1], categories[2],
categories[3], categories[4], categories[5]);
int ret = UniCreateLocaleObject( UNI_MBS_STRING_POINTER,
(const void*) localebuff,
&mLocaleObject);
if( ret)
{
#ifdef DEBUG
printf( "Locale init string `%s' gave rc %d\n", localebuff, ret);
#endif
// didn't work. Try something else...
rc = Init( "");
}
return rc;
}
// Init a locale object from a xx-XX style name
nsresult nsLocaleOS2::Init( const nsString &aLocaleName)
{
char szLocale[7] = { 0 };
aLocaleName.ToCString( szLocale, 6);
nsresult rc = NS_ERROR_FAILURE;
if( strlen( szLocale) == 5)
{
// implementations are not consistent: some use _ & some - as separator.
szLocale[2] = '_';
rc = Init( szLocale);
if( NS_FAILED(rc))
{
#ifdef DEBUG
printf( "Can't find locale %s, using fallback\n", szLocale);
#endif
rc = Init( ""); // XXX maybe this should be 0 -> UNIV ?
}
}
#ifdef DEBUG
else printf( "Malformed locale string %s\n", szLocale);
#endif
return rc;
}
nsresult nsLocaleOS2::Init( char *pszLocale)
{
nsresult nr = NS_ERROR_FAILURE;
int ret = UniCreateLocaleObject( UNI_MBS_STRING_POINTER,
(const void *) pszLocale,
&mLocaleObject);
if( !ret)
nr = NS_OK;
return nr;
}
// Get the OS/2 locale object
nsresult nsLocaleOS2::GetLocaleObject( LocaleObject *aLocaleObject)
{
if( !aLocaleObject)
return NS_ERROR_NULL_POINTER;
*aLocaleObject = mLocaleObject;
return NS_OK;
}
// nsILocale
nsresult nsLocaleOS2::GetCategory( const nsString *aCat, nsString *aLocale)
{
if( !aCat || !aLocale)
return NS_ERROR_NULL_POINTER;
nsresult rc = NS_OK;
int category = 0;
category = GetLocaleCategory( aCat);
if( -1 == category)
rc = NS_ERROR_FAILURE;
if( NS_SUCCEEDED(rc))
{
char *pszLocale = 0;
UniQueryLocaleObject( mLocaleObject, category,
UNI_MBS_STRING_POINTER,
(void**) &pszLocale);
aLocale->SetString( pszLocale);
UniFreeMem( pszLocale);
}
return rc;
}
// System locale
nsSystemLocale::nsSystemLocale()
{
Init( ""); // create locale based on value of LANG and friends
}

Просмотреть файл

@ -0,0 +1,67 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _nslocaleos2_h_
#define _nslocaleos2_h_
#include "nsILocale.h"
#include "nsILocaleOS2.h"
class nsLocaleOS2 : public nsILocale, public nsILocaleOS2
{
public:
nsLocaleOS2();
virtual ~nsLocaleOS2();
// nsISupports
NS_DECL_ISUPPORTS
// nsILocale
NS_IMETHOD GetCategory( const nsString *aCat, nsString *aLocale);
// nsILocaleOS2
// Init a complex locale - categories should be magic nsLocale words
NS_IMETHOD Init( nsString **aCatList,
nsString **aValList,
PRUint8 aLength);
// Init a locale object from a xx-XX style name
NS_IMETHOD Init( const nsString &aLocaleName);
// Get the OS/2 locale object
NS_IMETHOD GetLocaleObject( LocaleObject *aLocaleObject);
protected:
LocaleObject mLocaleObject;
NS_IMETHOD Init( char *pszLocale);
};
class nsSystemLocale : public nsLocaleOS2
{
public:
nsSystemLocale();
};
// XXX for now, I guess
typedef nsSystemLocale nsApplicationLocale;
#endif

Просмотреть файл

Просмотреть файл

@ -0,0 +1,223 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1998 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
// OS/2 plugin-loading code.
#define INCL_DOS
#define INCL_DOSERRORS
#include <os2.h>
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
#include "nsPluginDefs.h"
/* Load a string stored as RCDATA in a resource segment */
/* Returned string needs to be PR_Free'd by caller */
static char *LoadRCDATAString( HMODULE hMod, ULONG resid)
{
APIRET rc;
ULONG ulSize = 0;
char *string = 0;
rc = DosQueryResourceSize( hMod, RT_RCDATA, resid, &ulSize);
if( rc == NO_ERROR)
{
char *readOnlyString = 0;
rc = DosGetResource( hMod, RT_RCDATA, resid, (void**) &readOnlyString);
/* allow for 0-termination if user hasn't got it right */
if( readOnlyString[ ulSize - 1] != '\0')
ulSize++;
if( rc == NO_ERROR)
{
/* copy string & zero-terminate */
string = (char*) PR_Malloc( ulSize);
memcpy( string, readOnlyString, ulSize - 1);
string[ ulSize - 1] = '\0';
DosFreeResource( readOnlyString);
}
}
return string;
}
/* Take a string of the form "foo|bar|baz" and return an */
/* array of pointers *into that string* to foo, bar, baz. */
/* There may be embedded nulls after | characters, thanks */
/* to the way the resource compiler works. Technically */
/* the flat string ought to end with a double null, but */
/* I'm not checking here. */
/* The 'flat' string is altered, ['\0'/'|'] */
/* The array returned needs to be PR_Free'd. */
/* Also return the size of the array! */
static char **BuildStringArray( char *aFlat, PRUint32 &aSize)
{
char **array = 0;
aSize = 1;
/* make two passes through the string 'cos I'm lazy */
char *c = aFlat;
while( 0 != (c = PL_strchr( c, '|')))
{
/* skip past <= 1 null char */
c++; if( !*c) c++;
aSize++;
}
PRInt32 index = 0;
array = (char**) PR_Malloc( aSize * sizeof( char *));
c = aFlat;
for(;;) // do-while-do
{
array[ index++] = c;
c = PL_strchr( c, '|');
if( !c) break;
*c++ = '\0';
}
return array;
}
// nsPluginsDir class
nsPluginsDir::nsPluginsDir()
{
// XXX This isn't right for the embedded case, but it's as close
// as we can do right now.
nsSpecialSystemDirectory appdir( nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
appdir += "plugins";
if( !appdir.Exists())
appdir.CreateDirectory();
*(nsFileSpec*)this = appdir;
}
nsPluginsDir::~nsPluginsDir()
{
}
PRBool nsPluginsDir::IsPluginFile( const nsFileSpec &fileSpec)
{
PRBool rc = PR_FALSE;
const char *leafname = fileSpec.GetLeafName();
if( nsnull != leafname)
{
int len = strlen( leafname);
if( len > 6 && // np*.dll
(0 == strnicmp( &(leafname[len - 4]), ".dll", 4)) &&
(0 == strnicmp( leafname, "np", 2)))
{
rc = PR_TRUE;
}
delete [] leafname;
}
return rc;
}
// nsPluginFile implementation
nsPluginFile::nsPluginFile( const nsFileSpec &spec)
: nsFileSpec(spec)
{}
nsPluginFile::~nsPluginFile()
{}
// Loads the plugin into memory using NSPR's shared-library loading
nsresult nsPluginFile::LoadPlugin( PRLibrary *&outLibrary)
{
nsNSPRPath nsprpath( *this);
outLibrary = PR_LoadLibrary( nsprpath);
return outLibrary == nsnull ? NS_ERROR_FAILURE : NS_OK;
}
// Obtains all of the information currently available for this plugin.
nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
{
nsresult rc = NS_ERROR_FAILURE;
nsNSPRPath nsprpath( *this);
HMODULE hPlug = 0; // Need a HMODULE to query resource statements
char failure[ CCHMAXPATH] = "";
APIRET ret;
const char *pszNative = nsprpath;
ret = DosLoadModule( failure, CCHMAXPATH, pszNative, &hPlug);
while( ret == NO_ERROR)
{
info.fPluginInfoSize = sizeof( nsPluginInfo);
char *leaf = GetLeafName();
info.fName = PL_strdup( leaf);
delete [] leaf;
// get description (doesn't matter if it's missing)...
info.fDescription = LoadRCDATAString( hPlug, NS_INFO_FileDescription);
PRUint32 variants = 0;
// ...mime types...
info.fMimeType = LoadRCDATAString( hPlug, NS_INFO_MIMEType);
if( nsnull == info.fMimeType) break;
info.fMimeTypeArray = BuildStringArray( info.fMimeType, variants);
if( info.fMimeTypeArray == nsnull) break;
// (other lists must be same length as this one)
info.fVariantCount = variants;
// ...bizarre `description' thingy...
info.fMimeDescription = LoadRCDATAString( hPlug, NS_INFO_FileOpenName);
if( nsnull == info.fMimeDescription) break;
info.fMimeDescriptionArray =
BuildStringArray( info.fMimeDescription, variants);
if( nsnull == info.fMimeDescriptionArray) break;
if( variants != info.fVariantCount) break;
// ...file extensions...
info.fExtensions = LoadRCDATAString( hPlug, NS_INFO_FileExtents);
if( nsnull == info.fExtensions) break;
info.fExtensionArray = BuildStringArray( info.fExtensions, variants);
if( nsnull == info.fExtensionArray) break;
if( variants != info.fVariantCount) break;
rc = NS_OK;
break;
}
if( 0 != hPlug)
DosFreeModule( hPlug);
return rc;
}

Просмотреть файл

@ -0,0 +1,223 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1998 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
// OS/2 plugin-loading code.
#define INCL_DOS
#define INCL_DOSERRORS
#include <os2.h>
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
#include "nsPluginDefs.h"
/* Load a string stored as RCDATA in a resource segment */
/* Returned string needs to be PR_Free'd by caller */
static char *LoadRCDATAString( HMODULE hMod, ULONG resid)
{
APIRET rc;
ULONG ulSize = 0;
char *string = 0;
rc = DosQueryResourceSize( hMod, RT_RCDATA, resid, &ulSize);
if( rc == NO_ERROR)
{
char *readOnlyString = 0;
rc = DosGetResource( hMod, RT_RCDATA, resid, (void**) &readOnlyString);
/* allow for 0-termination if user hasn't got it right */
if( readOnlyString[ ulSize - 1] != '\0')
ulSize++;
if( rc == NO_ERROR)
{
/* copy string & zero-terminate */
string = (char*) PR_Malloc( ulSize);
memcpy( string, readOnlyString, ulSize - 1);
string[ ulSize - 1] = '\0';
DosFreeResource( readOnlyString);
}
}
return string;
}
/* Take a string of the form "foo|bar|baz" and return an */
/* array of pointers *into that string* to foo, bar, baz. */
/* There may be embedded nulls after | characters, thanks */
/* to the way the resource compiler works. Technically */
/* the flat string ought to end with a double null, but */
/* I'm not checking here. */
/* The 'flat' string is altered, ['\0'/'|'] */
/* The array returned needs to be PR_Free'd. */
/* Also return the size of the array! */
static char **BuildStringArray( char *aFlat, PRUint32 &aSize)
{
char **array = 0;
aSize = 1;
/* make two passes through the string 'cos I'm lazy */
char *c = aFlat;
while( 0 != (c = PL_strchr( c, '|')))
{
/* skip past <= 1 null char */
c++; if( !*c) c++;
aSize++;
}
PRInt32 index = 0;
array = (char**) PR_Malloc( aSize * sizeof( char *));
c = aFlat;
for(;;) // do-while-do
{
array[ index++] = c;
c = PL_strchr( c, '|');
if( !c) break;
*c++ = '\0';
}
return array;
}
// nsPluginsDir class
nsPluginsDir::nsPluginsDir()
{
// XXX This isn't right for the embedded case, but it's as close
// as we can do right now.
nsSpecialSystemDirectory appdir( nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
appdir += "plugins";
if( !appdir.Exists())
appdir.CreateDirectory();
*(nsFileSpec*)this = appdir;
}
nsPluginsDir::~nsPluginsDir()
{
}
PRBool nsPluginsDir::IsPluginFile( const nsFileSpec &fileSpec)
{
PRBool rc = PR_FALSE;
const char *leafname = fileSpec.GetLeafName();
if( nsnull != leafname)
{
int len = strlen( leafname);
if( len > 6 && // np*.dll
(0 == strnicmp( &(leafname[len - 4]), ".dll", 4)) &&
(0 == strnicmp( leafname, "np", 2)))
{
rc = PR_TRUE;
}
delete [] leafname;
}
return rc;
}
// nsPluginFile implementation
nsPluginFile::nsPluginFile( const nsFileSpec &spec)
: nsFileSpec(spec)
{}
nsPluginFile::~nsPluginFile()
{}
// Loads the plugin into memory using NSPR's shared-library loading
nsresult nsPluginFile::LoadPlugin( PRLibrary *&outLibrary)
{
nsNSPRPath nsprpath( *this);
outLibrary = PR_LoadLibrary( nsprpath);
return outLibrary == nsnull ? NS_ERROR_FAILURE : NS_OK;
}
// Obtains all of the information currently available for this plugin.
nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
{
nsresult rc = NS_ERROR_FAILURE;
nsNSPRPath nsprpath( *this);
HMODULE hPlug = 0; // Need a HMODULE to query resource statements
char failure[ CCHMAXPATH] = "";
APIRET ret;
const char *pszNative = nsprpath;
ret = DosLoadModule( failure, CCHMAXPATH, pszNative, &hPlug);
while( ret == NO_ERROR)
{
info.fPluginInfoSize = sizeof( nsPluginInfo);
char *leaf = GetLeafName();
info.fName = PL_strdup( leaf);
delete [] leaf;
// get description (doesn't matter if it's missing)...
info.fDescription = LoadRCDATAString( hPlug, NS_INFO_FileDescription);
PRUint32 variants = 0;
// ...mime types...
info.fMimeType = LoadRCDATAString( hPlug, NS_INFO_MIMEType);
if( nsnull == info.fMimeType) break;
info.fMimeTypeArray = BuildStringArray( info.fMimeType, variants);
if( info.fMimeTypeArray == nsnull) break;
// (other lists must be same length as this one)
info.fVariantCount = variants;
// ...bizarre `description' thingy...
info.fMimeDescription = LoadRCDATAString( hPlug, NS_INFO_FileOpenName);
if( nsnull == info.fMimeDescription) break;
info.fMimeDescriptionArray =
BuildStringArray( info.fMimeDescription, variants);
if( nsnull == info.fMimeDescriptionArray) break;
if( variants != info.fVariantCount) break;
// ...file extensions...
info.fExtensions = LoadRCDATAString( hPlug, NS_INFO_FileExtents);
if( nsnull == info.fExtensions) break;
info.fExtensionArray = BuildStringArray( info.fExtensions, variants);
if( nsnull == info.fExtensionArray) break;
if( variants != info.fVariantCount) break;
rc = NS_OK;
break;
}
if( 0 != hPlug)
DosFreeModule( hPlug);
return rc;
}

Просмотреть файл

@ -0,0 +1,81 @@
/*
* 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 the Mozilla OS/2 libraries.
*
* The Initial Developer of the Original Code is John Fairhurst,
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
*
*/
#define INCL_PM
#define INCL_DOS
#include <os2.h>
#include "nsViewerApp.h"
#include "nsBrowserWindow.h"
#include "nsIAppShell.h"
#include "resources.h"
nsNativeBrowserWindow::nsNativeBrowserWindow() {}
nsNativeBrowserWindow::~nsNativeBrowserWindow() {}
nsresult
nsNativeBrowserWindow::InitNativeWindow()
{
// override to do something special with platform native windows
return NS_OK;
}
nsresult nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
HWND hwnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WIDGET);
HWND hwndFrame = WinQueryWindow( hwnd, QW_PARENT);
HWND hwndMenu = WinLoadMenu( hwndFrame, 0, IDM_VIEWERBAR);
WinSendMsg( hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_MENU), 0);
return NS_OK;
}
nsEventStatus nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
return nsBrowserWindow::DispatchMenuItem(aID);
}
nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int nsNativeViewerApp::Run()
{
OpenWindow();
mAppShell->Run();
return 0;
}
int main(int argc, char **argv)
{
nsViewerApp* app = new nsNativeViewerApp;
NS_ADDREF(app);
app->Initialize(argc, argv);
app->Run();
NS_RELEASE(app);
return 0;
}

Просмотреть файл

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 "resources.h"
#include <os2.h>
MENU IDM_VIEWERBAR
{
SUBMENU "~File", 0
{
MENUITEM "~New Window", VIEWER_WINDOW_OPEN
MENUITEM "~Open...", VIEWER_FILE_OPEN
MENUITEM "~ViewSource", VIEW_SOURCE
SUBMENU "~Samples", 0
{
MENUITEM "demo #0", VIEWER_DEMO0
MENUITEM "demo #1", VIEWER_DEMO1
MENUITEM "demo #2", VIEWER_DEMO2
MENUITEM "demo #3", VIEWER_DEMO3
MENUITEM "demo #4", VIEWER_DEMO4
MENUITEM "demo #5", VIEWER_DEMO5
MENUITEM "demo #6", VIEWER_DEMO6
MENUITEM "demo #7", VIEWER_DEMO7
MENUITEM "demo #8", VIEWER_DEMO8
MENUITEM "demo #9", VIEWER_DEMO9
MENUITEM "demo #10", VIEWER_DEMO10
MENUITEM "demo #11", VIEWER_DEMO11
MENUITEM "demo #12", VIEWER_DEMO12
MENUITEM "demo #13", VIEWER_DEMO13
MENUITEM "demo #14", VIEWER_DEMO14
MENUITEM "demo #15", VIEWER_DEMO15
MENUITEM "demo #16", VIEWER_DEMO16
MENUITEM "demo #17", VIEWER_DEMO17
}
MENUITEM "~Test sites", VIEWER_TOP100
SUBMENU "~XPToolkit tests", 0
{
MENUITEM "~Toolbar Test 1", VIEWER_XPTOOLKITTOOLBAR1
MENUITEM "T~ree Test 1", VIEWER_XPTOOLKITTREE1
}
MENUITEM SEPARATOR
MENUITEM "Print ~Preview", VIEWER_ONE_COLUMN
MENUITEM "~Print", VIEWER_PRINT
MENUITEM "Print Setup", VIEWER_PRINT_SETUP
MENUITEM SEPARATOR
MENUITEM "E~xit", VIEWER_EXIT
}
SUBMENU "~Edit", 0
{
MENUITEM "Cu~t", VIEWER_EDIT_CUT, , MIA_DISABLED
MENUITEM "~Copy", VIEWER_EDIT_COPY
MENUITEM "~Paste", VIEWER_EDIT_PASTE, , MIA_DISABLED
MENUITEM SEPARATOR
MENUITEM "Select ~All", VIEWER_EDIT_SELECTALL
MENUITEM SEPARATOR
MENUITEM "~Find in Page", VIEWER_EDIT_FINDINPAGE
MENUITEM SEPARATOR
MENUITEM "P~refs", VIEWER_PREFS
}
SUBMENU "~Debug", 0
{
MENUITEM "~Visual Debugging", VIEWER_VISUAL_DEBUGGING
MENUITEM "~Reflow Test", VIEWER_REFLOW_TEST
MENUITEM SEPARATOR
MENUITEM "Dump ~Content", VIEWER_DUMP_CONTENT
MENUITEM "Dump ~Frames", VIEWER_DUMP_FRAMES
MENUITEM "Dump ~Views", VIEWER_DUMP_VIEWS
MENUITEM SEPARATOR
MENUITEM "Dump ~Style Sheets", VIEWER_DUMP_STYLE_SHEETS
MENUITEM "Dump ~Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS
MENUITEM SEPARATOR
MENUITEM "Show Content Size", VIEWER_SHOW_CONTENT_SIZE
MENUITEM "Show Frame Size", VIEWER_SHOW_FRAME_SIZE
MENUITEM "Show Style Size", VIEWER_SHOW_STYLE_SIZE
MENUITEM SEPARATOR
MENUITEM "Debug Save", VIEWER_DEBUGSAVE
MENUITEM "Debug Display Text", VIEWER_DISPLAYTEXT
MENUITEM "Debug Display HTML", VIEWER_DISPLAYHTML
MENUITEM "Debug Toggle Selection", VIEWER_TOGGLE_SELECTION
MENUITEM SEPARATOR
MENUITEM "Debu~g Robot", VIEWER_DEBUGROBOT
MENUITEM SEPARATOR
MENUITEM "Show Content Quality", VIEWER_SHOW_CONTENT_QUALITY
MENUITEM SEPARATOR
}
SUBMENU "~Style", 0
{
SUBMENU "Select ~Style Sheet", 0
{
MENUITEM "List Availabe Sheets", VIEWER_SELECT_STYLE_LIST
MENUITEM SEPARATOR
MENUITEM "Select Default", VIEWER_SELECT_STYLE_DEFAULT
MENUITEM SEPARATOR
MENUITEM "Select Alternate 1", VIEWER_SELECT_STYLE_ONE
MENUITEM "Select Alternate 2", VIEWER_SELECT_STYLE_TWO
MENUITEM "Select Alternate 3", VIEWER_SELECT_STYLE_THREE
MENUITEM "Select Alternate 4", VIEWER_SELECT_STYLE_FOUR
}
SUBMENU "~Compatibility Mode Pref", 0
{
MENUITEM "Nav Quirks", VIEWER_NAV_QUIRKS_MODE
MENUITEM "Standard", VIEWER_STANDARD_MODE
}
SUBMENU "~Widget Rendering Mode Pref", 0
{
MENUITEM "Native", VIEWER_NATIVE_WIDGET_MODE
MENUITEM "Gfx", VIEWER_GFX_WIDGET_MODE
}
}
SUBMENU "~Tools", 0
{
MENUITEM "~JavaScript Console", JS_CONSOLE
MENUITEM "~Editor Mode", EDITOR_MODE
MENUITEM SEPARATOR
SUBMENU "~Privacy Tools", 0
{
MENUITEM "Safe Prefill from ~Wallet", PRVCY_PREFILL
MENUITEM "~Quick Prefill from Wallet", PRVCY_QPREFILL
MENUITEM SEPARATOR
MENUITEM "Display Wa~llet", PRVCY_DISPLAY_WALLET
MENUITEM "Display ~Cookies", PRVCY_DISPLAY_COOKIES
MENUITEM "Display ~Signons", PRVCY_DISPLAY_SIGNONS
}
SUBMENU "Editor Tests", 0
{
MENUITEM "Insert Table", VIEWER_EDIT_INSERT_TABLE
MENUITEM "Insert Cell", VIEWER_EDIT_INSERT_CELL
MENUITEM "Insert Column", VIEWER_EDIT_INSERT_COLUMN
MENUITEM "Insert Row", VIEWER_EDIT_INSERT_ROW
MENUITEM SEPARATOR
MENUITEM "Delete Table", VIEWER_EDIT_DELETE_TABLE
MENUITEM "Delete Cell", VIEWER_EDIT_DELETE_CELL
MENUITEM "Delete Column", VIEWER_EDIT_DELETE_COLUMN
MENUITEM "Delete Row", VIEWER_EDIT_DELETE_ROW
MENUITEM SEPARATOR
MENUITEM "Join with cell to right", VIEWER_EDIT_JOIN_CELL_RIGHT
MENUITEM "Join with cell below", VIEWER_EDIT_JOIN_CELL_BELOW
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
#!gmake
#
# 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.
#
DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
CFLAGS += -DEXPORT_XPC_API
LIBRARY_NAME = xptcmd
MODULE = xpconnect
CPPSRCS= \
xptcinvoke_emx.cpp \
xptcstubs_emx.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..

Просмотреть файл

@ -0,0 +1,174 @@
/* -*- Mode: C; tab-width: 8; 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.
*
* Contributor: John Fairhurst <john_fairhurst@iname.com>
*/
/* Platform specific code to invoke XPCOM methods on native objects */
// This is 80% copied directly from other platforms; the assembler
// stuff is all my fault, though.
//
// In fact it looks pretty much like we could do away with this os2
// directory & use the "unixish-x86" files; it's all gcc after all.
//
// On the other hand, if we ever do decide to support VAC++ then that'll
// require special treatment but should share some code with this easy stuff.
//
// So let's keep it.
//
// XXX docs to come on how VAC++ _Optlink callers/interpreters could work
//
#include "xptcprivate.h"
// Remember that these 'words' are 32bit DWORDS
#if !defined(__EMX__)
#error "This code is for OS/2 EMX only"
#endif
static uint32
invoke_count_words( PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
return result;
}
static void
invoke_copy_to_stack( PRUint32* d, uint32 paramCount, nsXPTCVariant* s)
{
for( PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *((int8*) d) = s->val.i8; break;
case nsXPTType::T_I16 : *((int16*) d) = s->val.i16; break;
case nsXPTType::T_I32 : *((int32*) d) = s->val.i32; break;
case nsXPTType::T_I64 : *((int64*) d) = s->val.i64; d++; break;
case nsXPTType::T_U8 : *((uint8*) d) = s->val.u8; break;
case nsXPTType::T_U16 : *((uint16*) d) = s->val.u16; break;
case nsXPTType::T_U32 : *((uint32*) d) = s->val.u32; break;
case nsXPTType::T_U64 : *((uint64*) d) = s->val.u64; d++; break;
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
case nsXPTType::T_BOOL : *((PRBool*) d) = s->val.b; break;
case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break;
case nsXPTType::T_WCHAR : *((wchar_t*)d) = s->val.wc; break;
default:
// all the others are plain pointer types
*((void**)d) = s->val.p;
break;
}
}
}
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex( nsISupports *that, PRUint32 index,
PRUint32 paramcount, nsXPTCVariant* params)
{
int ibytes;
void *pStack;
int result = NS_OK;
// Find size in bytes necessary for call
ibytes = 4 * invoke_count_words( paramcount, params);
__asm__ __volatile__ (
"movl %1, %%eax\n" /* load |ibytes| into eax */
"subl %%eax, %%esp\n" /* make room on stack */
"movl %%esp, %0" /* store base in |pStack| */
: "=g" (pStack) /* %0 */
: "g" (ibytes) /* %1 */
: "ax", "memory", "sp"
);
// Fill in that gap in the stack with the params to the method
invoke_copy_to_stack( (PRUint32*) pStack, paramcount, params);
// push the hidden 'this' parameter, traverse the vtable,
// and then call the method.
__asm__ __volatile__ (
"movl %2, %%eax\n" /* |that| ptr -> eax */
"pushl %%eax\n" /* enstack |that| */
"movl (%%eax), %%edx\n" /* vptr -> edx */
"movl %3, %%eax\n"
"shl $3, %%eax\n" /* 8 bytes per method.. */
"addl $12, %%eax\n" /* ..plus 12 more at the start */
"addl %%eax, %%edx\n" /* find pointer to code */
"call (%%edx)\n" /* call method */
"movl %%eax, %0\n" /* save rc in |result| */
"movl %1, %%ebx\n" /* clear up stack */
"addl $4, %%ebx\n"
"addl %%ebx, %%esp"
: "=g" (result) /* %0 */
: "g" (ibytes), /* %1 */
"g" (that), /* %2 */
"g" (index) /* %3 */
: "ax", "bx", "dx", "memory", "sp"
);
return result;
}

Просмотреть файл

@ -0,0 +1,134 @@
/* -*- Mode: C; tab-width: 8; 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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Implement shared vtbl methods */
// This is a 98% copy of other implementations; see comment at top of
// xptcinvoke_emx.cpp for why this file exists.
//
#include "xptcprivate.h"
#if !defined(__EMX__)
#error "This code is for OS/2 EMX only"
#endif
static nsresult
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
PRUint32 *args)
{
#define PARAM_BUFFER_COUNT 16
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
// If anything fails before stackBytesToPop can be set then
// the failure is completely catastrophic!
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
PRUint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
register void* method = PrepareAndDispatch; \
register nsresult result; \
__asm__ __volatile__( \
"leal 0x0c(%%ebp), %%ecx\n\t" /* args */ \
"pushl %%ecx\n\t" \
"pushl $"#n"\n\t" /* method index */ \
"movl 0x08(%%ebp), %%ecx\n\t" /* this */ \
"pushl %%ecx\n\t" \
"call *%%edx" /* PrepareAndDispatch */ \
: "=a" (result) /* %0 */ \
: "d" (method) /* %1 */ \
: "ax", "dx", "cx", "memory" ); \
return result; \
}
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"