Support for xpidl keyword.
git-svn-id: svn://10.0.0.236/trunk@23549 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -52,6 +52,9 @@ static const char *kDisclaimerStr = "/* AUTO-GENERATED. DO NOT EDIT!!! */\n";
|
||||
static const char *kObjTypeStr = "nsIDOM%s*";
|
||||
static const char *kObjTypePtrStr = "nsIDOM%sPtr";
|
||||
static const char *kUuidStr = "NS_IDOM%s_IID";
|
||||
static const char *kXPIDLObjTypeStr = "%s*";
|
||||
static const char *kXPIDLObjTypePtrStr = "%sPtr";
|
||||
static const char *kXPIDLUuidStr = "NS_I%s_IID";
|
||||
|
||||
FileGen::FileGen()
|
||||
{
|
||||
@@ -133,6 +136,8 @@ FileGen::GetVariableTypeForMethodLocal(char *aBuffer, IdlVariable &aVariable)
|
||||
case TYPE_OBJECT:
|
||||
sprintf(aBuffer, kObjTypePtrStr, aVariable.GetTypeName());
|
||||
break;
|
||||
case TYPE_XPIDL_OBJECT:
|
||||
sprintf(aBuffer, kXPIDLObjTypePtrStr, aVariable.GetTypeName());
|
||||
default:
|
||||
// XXX Fail for other cases
|
||||
break;
|
||||
@@ -173,6 +178,9 @@ FileGen::GetVariableTypeForLocal(char *aBuffer, IdlVariable &aVariable)
|
||||
case TYPE_OBJECT:
|
||||
sprintf(aBuffer, kObjTypeStr, aVariable.GetTypeName());
|
||||
break;
|
||||
case TYPE_XPIDL_OBJECT:
|
||||
sprintf(aBuffer, kXPIDLObjTypeStr, aVariable.GetTypeName());
|
||||
break;
|
||||
default:
|
||||
// XXX Fail for other cases
|
||||
break;
|
||||
@@ -213,6 +221,9 @@ FileGen::GetVariableTypeForParameter(char *aBuffer, IdlVariable &aVariable)
|
||||
case TYPE_OBJECT:
|
||||
sprintf(aBuffer, kObjTypeStr, aVariable.GetTypeName());
|
||||
break;
|
||||
case TYPE_XPIDL_OBJECT:
|
||||
sprintf(aBuffer, kXPIDLObjTypeStr, aVariable.GetTypeName());
|
||||
break;
|
||||
default:
|
||||
// XXX Fail for other cases
|
||||
break;
|
||||
@@ -260,6 +271,23 @@ FileGen::GetInterfaceIID(char *aBuffer, IdlInterface &aInterface)
|
||||
GetInterfaceIID(aBuffer, aInterface.GetName());
|
||||
}
|
||||
|
||||
void
|
||||
FileGen::GetXPIDLInterfaceIID(char* aBuffer, char* aInterfaceName)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
strcpy(buf, aInterfaceName);
|
||||
StrUpr(buf);
|
||||
|
||||
sprintf(aBuffer, kXPIDLUuidStr, buf);
|
||||
}
|
||||
|
||||
void
|
||||
FileGen::GetXPIDLInterfaceIID(char* aBuffer, IdlInterface &aInterface)
|
||||
{
|
||||
GetInterfaceIID(aBuffer, aInterface.GetName());
|
||||
}
|
||||
|
||||
void
|
||||
FileGen::GetCapitalizedName(char *aBuffer, IdlObject &aObject)
|
||||
{
|
||||
@@ -290,9 +318,9 @@ FileGen::CollectAllInInterface(IdlInterface &aInterface,
|
||||
for (a = 0; a < acount; a++) {
|
||||
IdlAttribute *attr = aInterface.GetAttributeAt(a);
|
||||
|
||||
if ((attr->GetType() == TYPE_OBJECT) &&
|
||||
if (((attr->GetType() == TYPE_OBJECT) || (attr->GetType() == TYPE_XPIDL_OBJECT)) &&
|
||||
!PL_HashTableLookup(aTable, attr->GetTypeName())) {
|
||||
PL_HashTableAdd(aTable, attr->GetTypeName(), (void *)1);
|
||||
PL_HashTableAdd(aTable, attr->GetTypeName(), (void *)(attr->GetType()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,18 +329,18 @@ FileGen::CollectAllInInterface(IdlInterface &aInterface,
|
||||
IdlFunction *func = aInterface.GetFunctionAt(m);
|
||||
IdlVariable *rval = func->GetReturnValue();
|
||||
|
||||
if ((rval->GetType() == TYPE_OBJECT) &&
|
||||
if (((rval->GetType() == TYPE_OBJECT) || (rval->GetType() == TYPE_XPIDL_OBJECT)) &&
|
||||
!PL_HashTableLookup(aTable, rval->GetTypeName())) {
|
||||
PL_HashTableAdd(aTable, rval->GetTypeName(), (void *)1);
|
||||
PL_HashTableAdd(aTable, rval->GetTypeName(), (void *)(rval->GetType()));
|
||||
}
|
||||
|
||||
int p, pcount = func->ParameterCount();
|
||||
for (p = 0; p < pcount; p++) {
|
||||
IdlParameter *param = func->GetParameterAt(p);
|
||||
|
||||
if ((param->GetType() == TYPE_OBJECT) &&
|
||||
if (((param->GetType() == TYPE_OBJECT) || (param->GetType() == TYPE_XPIDL_OBJECT)) &&
|
||||
!PL_HashTableLookup(aTable, param->GetTypeName())) {
|
||||
PL_HashTableAdd(aTable, param->GetTypeName(), (void *)1);
|
||||
PL_HashTableAdd(aTable, param->GetTypeName(), (void *)(param->GetType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +379,7 @@ FileGen::EnumerateAllObjects(IdlSpecification &aSpec,
|
||||
|
||||
if (((i == 0) || !aOnlyPrimary) &&
|
||||
!PL_HashTableLookup(htable, iface->GetName())) {
|
||||
PL_HashTableAdd(htable, iface->GetName(), (void *)1);
|
||||
PL_HashTableAdd(htable, iface->GetName(), (void *)(int)TYPE_OBJECT);
|
||||
}
|
||||
|
||||
CollectAllInInterface(*iface, htable);
|
||||
|
||||
@@ -54,6 +54,8 @@ protected:
|
||||
void GetParameterType(char *aBuffer, IdlParameter &aParameter);
|
||||
void GetInterfaceIID(char *aBuffer, IdlInterface &aInterface);
|
||||
void GetInterfaceIID(char *aBuffer, char *aInterfaceName);
|
||||
void GetXPIDLInterfaceIID(char *aBuffer, char *aInterfaceName);
|
||||
void GetXPIDLInterfaceIID(char *aBuffer, IdlInterface &aInterface);
|
||||
void GetCapitalizedName(char *aBuffer, IdlObject &aObject);
|
||||
void EnumerateAllObjects(IdlSpecification &aSpec,
|
||||
PLHashEnumerator aEnumerator,
|
||||
|
||||
@@ -49,4 +49,3 @@ int IdlAttribute::GetReadOnly()
|
||||
{
|
||||
return mReadOnly;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
|
||||
void SetReadOnly(int aReadOnlyFlag);
|
||||
int GetReadOnly();
|
||||
|
||||
};
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
@@ -239,7 +239,7 @@ IdlInterface* IdlParser::ParseInterface(IdlSpecification &aSpecification)
|
||||
* enum_type = "enum" identifier "{" enumerator < "," enumerator > "}"
|
||||
* const_dcl = "const" const_type identifier "=" const_exp
|
||||
* except_dcl = "exception" identifier "{" < member > "}"
|
||||
* attr_dcl = [ "readonly" ] "attribute" param_type_spec identifier
|
||||
* attr_dcl = [ "readonly" ] [ "xpidl" ] "attribute" param_type_spec identifier
|
||||
* op_dcl = [ op_attribute ] op_type_spec identifier parameter_dcls
|
||||
* [ raises_expr ] [ context_expr ]
|
||||
* op_attribute = "oneway" .
|
||||
@@ -545,9 +545,10 @@ IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aT
|
||||
isReadOnly = 1;
|
||||
TrimComments();
|
||||
token = mScanner->NextToken();
|
||||
if (ATTRIBUTE_TOKEN != token->id) {
|
||||
throw AttributeParsingException("Missing attribute specifier.");
|
||||
}
|
||||
aTokenID = token->id;
|
||||
}
|
||||
if (ATTRIBUTE_TOKEN != aTokenID) {
|
||||
throw AttributeParsingException("Missing attribute specifier.");
|
||||
}
|
||||
TrimComments();
|
||||
|
||||
@@ -601,6 +602,13 @@ IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aT
|
||||
attrObj->SetTypeName(token->stringID);
|
||||
break;
|
||||
//}
|
||||
case XPIDL_TOKEN:
|
||||
token = mScanner->NextToken();
|
||||
if (IDENTIFIER_TOKEN == token->id) {
|
||||
attrObj->SetType(TYPE_XPIDL_OBJECT);
|
||||
attrObj->SetTypeName(token->stringID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
delete attrObj;
|
||||
throw AttributeParsingException("Unknow attribute type.");
|
||||
@@ -673,6 +681,14 @@ IdlFunction* IdlParser::ParseFunction(IdlSpecification &aSpecification, Token &a
|
||||
funcObj->SetReturnValue(TYPE_OBJECT, aToken.stringID);
|
||||
break;
|
||||
//}
|
||||
case XPIDL_TOKEN:
|
||||
{
|
||||
Token* token = mScanner->NextToken();
|
||||
if (IDENTIFIER_TOKEN == token->id) {
|
||||
funcObj->SetReturnValue(TYPE_XPIDL_OBJECT, token->stringID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
delete funcObj;
|
||||
throw AttributeParsingException("Unknown type.");
|
||||
@@ -830,7 +846,7 @@ IdlParameter* IdlParser::ParseFunctionParameter(IdlSpecification &aSpecification
|
||||
Token *token = mScanner->NextToken();
|
||||
if (token->id == OPTIONAL_TOKEN) {
|
||||
argObj->SetIsOptional(1);
|
||||
mScanner->NextToken();
|
||||
token = mScanner->NextToken();
|
||||
}
|
||||
|
||||
// the paramenter attribute (in, out, inout)
|
||||
@@ -909,6 +925,13 @@ IdlParameter* IdlParser::ParseFunctionParameter(IdlSpecification &aSpecification
|
||||
argObj->SetTypeName(token->stringID);
|
||||
break;
|
||||
//}
|
||||
case XPIDL_TOKEN:
|
||||
token = mScanner->NextToken();
|
||||
if (IDENTIFIER_TOKEN == token->id) {
|
||||
argObj->SetType(TYPE_XPIDL_OBJECT);
|
||||
argObj->SetTypeName(token->stringID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
delete argObj;
|
||||
throw ParameterParsingException("Unknow type in parameters list.");
|
||||
|
||||
@@ -205,6 +205,9 @@ Token* IdlScanner::NextToken()
|
||||
case 'w':
|
||||
WKeywords(mTokenName + 1, mCurrentToken);
|
||||
break;
|
||||
case 'x':
|
||||
XKeywords(mTokenName + 1, mCurrentToken);
|
||||
break;
|
||||
case '"':
|
||||
String(c, mCurrentToken); // has to be a string
|
||||
break;
|
||||
@@ -1113,6 +1116,40 @@ void IdlScanner::WKeywords(char *aCurrentPos, Token *aToken)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Either 'xpidl' or an identifier
|
||||
//
|
||||
void IdlScanner::XKeywords(char *aCurrentPos, Token *aToken)
|
||||
{
|
||||
int c = mInputFile->get();
|
||||
if (c != EOF && c == 'p' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'i' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'd' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'l' && (*aCurrentPos++ = c)) {
|
||||
// if terminated is a keyword
|
||||
c = mInputFile->get();
|
||||
if (c != EOF) {
|
||||
if (isalpha(c) || isdigit(c) || c == '_') {
|
||||
// more characters, it must be an identifier
|
||||
*aCurrentPos++ = c;
|
||||
Identifier(aCurrentPos, aToken);
|
||||
}
|
||||
else {
|
||||
// it is a keyword
|
||||
aToken->SetToken(XPIDL_TOKEN);
|
||||
mInputFile->putback(c);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aToken->SetToken(XPIDL_TOKEN);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// it must be an identifier
|
||||
KeywordMismatch(c, aCurrentPos, aToken);
|
||||
}
|
||||
}
|
||||
|
||||
void IdlScanner::Identifier(char *aCurrentPos, Token *aToken)
|
||||
{
|
||||
int index = aCurrentPos - mTokenName;
|
||||
|
||||
@@ -42,6 +42,7 @@ enum EIDLTokenType {
|
||||
EXCEPTION_TOKEN,
|
||||
READONLY_TOKEN,
|
||||
OPTIONAL_TOKEN,
|
||||
XPIDL_TOKEN,
|
||||
ELLIPSIS_TOKEN,
|
||||
IID_TOKEN,
|
||||
ATTRIBUTE_TOKEN,
|
||||
@@ -196,6 +197,7 @@ protected:
|
||||
void UKeywords(char *aCurrentPos, Token *aToken);
|
||||
void VKeywords(char *aCurrentPos, Token *aToken);
|
||||
void WKeywords(char *aCurrentPos, Token *aToken);
|
||||
void XKeywords(char *aCurrentPos, Token *aToken);
|
||||
void Identifier(char *aCurrentPos, Token *aToken);
|
||||
void Number(int aStartChar, Token *aToken);
|
||||
void String(int aStartChar, Token *aToken);
|
||||
|
||||
@@ -38,6 +38,7 @@ enum Type {
|
||||
TYPE_UINT,
|
||||
TYPE_STRING,
|
||||
TYPE_OBJECT,
|
||||
TYPE_XPIDL_OBJECT,
|
||||
TYPE_VOID
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ static const char *kIncludeDefaultsStr =
|
||||
static const char *kIncludeStr = "#include \"nsIDOM%s.h\"\n";
|
||||
static const char *kIncludeJSStr = "#include \"jsapi.h\"\n";
|
||||
static const char *kForwardClassStr = "class nsIDOM%s;\n";
|
||||
static const char *kForwardXPIDLClassStr = "class %s;\n";
|
||||
static const char *kUuidStr =
|
||||
"#define %s \\\n"
|
||||
"%s\n\n";
|
||||
@@ -191,7 +192,20 @@ ForwardDeclEnumerator(PLHashEntry *he, PRIntn i, void *arg)
|
||||
char buf[512];
|
||||
|
||||
ofstream *file = (ofstream *)arg;
|
||||
sprintf(buf, kForwardClassStr, (char *)he->key);
|
||||
switch ((Type)(int)(he->value)) {
|
||||
case TYPE_OBJECT:
|
||||
sprintf(buf, kForwardClassStr, (char *)he->key);
|
||||
break;
|
||||
|
||||
case TYPE_XPIDL_OBJECT:
|
||||
sprintf(buf, kForwardXPIDLClassStr, (char *)he->key);
|
||||
break;
|
||||
|
||||
default:
|
||||
// uh oh...
|
||||
break;
|
||||
}
|
||||
|
||||
*file << buf;
|
||||
|
||||
return HT_ENUMERATE_NEXT;
|
||||
|
||||
Reference in New Issue
Block a user