зеркало из https://github.com/mozilla/pjs.git
Added support for noscript qualifier to attributes and methods. When this qualifier is used, the corresponding attribute or method is not reflected in the glue.
This commit is contained in:
Родитель
00898c565a
Коммит
c4b12aea87
|
@ -34,6 +34,7 @@ ostream& operator<<(ostream &s, IdlAttribute &aAttribute)
|
|||
IdlAttribute::IdlAttribute()
|
||||
{
|
||||
mReadOnly = 0;
|
||||
mIsNoScript = 0;
|
||||
}
|
||||
|
||||
IdlAttribute::~IdlAttribute()
|
||||
|
@ -49,3 +50,15 @@ int IdlAttribute::GetReadOnly()
|
|||
{
|
||||
return mReadOnly;
|
||||
}
|
||||
|
||||
int
|
||||
IdlAttribute::GetIsNoScript()
|
||||
{
|
||||
return mIsNoScript;
|
||||
}
|
||||
|
||||
void
|
||||
IdlAttribute::SetIsNoScript(int aIsNoScript)
|
||||
{
|
||||
mIsNoScript = aIsNoScript;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class IdlAttribute : public IdlVariable {
|
|||
|
||||
private:
|
||||
int mReadOnly;
|
||||
int mIsNoScript;
|
||||
|
||||
public:
|
||||
IdlAttribute();
|
||||
|
@ -32,6 +33,9 @@ public:
|
|||
|
||||
void SetReadOnly(int aReadOnlyFlag);
|
||||
int GetReadOnly();
|
||||
|
||||
int GetIsNoScript();
|
||||
void SetIsNoScript(int aIsNoScript);
|
||||
};
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
|
|
@ -60,6 +60,7 @@ IdlFunction::IdlFunction()
|
|||
mParameters = (nsVoidArray*)0;
|
||||
mExceptions = (nsVoidArray*)0;
|
||||
mHasEllipsis = 0;
|
||||
mIsNoScript = 0;
|
||||
}
|
||||
|
||||
IdlFunction::~IdlFunction()
|
||||
|
@ -167,3 +168,14 @@ IdlFunction::SetHasEllipsis(int aHasEllipsis)
|
|||
mHasEllipsis = aHasEllipsis;
|
||||
}
|
||||
|
||||
int
|
||||
IdlFunction::GetIsNoScript()
|
||||
{
|
||||
return mIsNoScript;
|
||||
}
|
||||
|
||||
void
|
||||
IdlFunction::SetIsNoScript(int aIsNoScript)
|
||||
{
|
||||
mIsNoScript = aIsNoScript;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
nsVoidArray *mParameters;
|
||||
nsVoidArray *mExceptions;
|
||||
int mHasEllipsis;
|
||||
int mIsNoScript;
|
||||
|
||||
public:
|
||||
IdlFunction();
|
||||
|
@ -50,6 +51,9 @@ public:
|
|||
|
||||
int GetHasEllipsis();
|
||||
void SetHasEllipsis(int aHasEllipsis);
|
||||
|
||||
int GetIsNoScript();
|
||||
void SetIsNoScript(int aIsNoScript);
|
||||
};
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
|
|
@ -290,13 +290,26 @@ void IdlParser::ParseInterfaceBody(IdlSpecification &aSpecification, IdlInterfac
|
|||
case EXCEPTION_TOKEN:
|
||||
aInterface.AddException(ParseException(aSpecification));
|
||||
break;
|
||||
case NOSCRIPT_TOKEN:
|
||||
{
|
||||
IdlAttribute* attr;
|
||||
|
||||
attr = MaybeParseAttribute(aSpecification, token->id);
|
||||
if (NULL == attr) {
|
||||
aInterface.AddFunction(ParseFunction(aSpecification, token));
|
||||
}
|
||||
else {
|
||||
aInterface.AddAttribute(attr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case READONLY_TOKEN:
|
||||
case ATTRIBUTE_TOKEN:
|
||||
aInterface.AddAttribute(ParseAttribute(aSpecification, token->id));
|
||||
break;
|
||||
default:
|
||||
// it's either a function or an error
|
||||
aInterface.AddFunction(ParseFunction(aSpecification, *token));
|
||||
aInterface.AddFunction(ParseFunction(aSpecification, token));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -531,16 +544,34 @@ IdlException* IdlParser::ParseException(IdlSpecification &aSpecification)
|
|||
return (IdlException*)0;
|
||||
}
|
||||
|
||||
IdlAttribute* IdlParser::MaybeParseAttribute(IdlSpecification &aSpecification, int aTokenID)
|
||||
{
|
||||
Token *token;
|
||||
int isNoScript = 0;
|
||||
|
||||
// if it was a noscript keyword check if this is an attribute
|
||||
if (NOSCRIPT_TOKEN == aTokenID) {
|
||||
isNoScript = 1;
|
||||
TrimComments();
|
||||
token = mScanner->PeekToken();
|
||||
if ((token->id != READONLY_TOKEN) && (token->id != ATTRIBUTE_TOKEN)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return ParseAttribute(aSpecification, aTokenID, isNoScript);
|
||||
}
|
||||
|
||||
/**
|
||||
* attr_dcl = [ "readonly" ] "attribute" param_type_spec identifier
|
||||
* param_type_spec = base_type_spec / string_type / scoped_name
|
||||
*/
|
||||
IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aTokenID)
|
||||
IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aTokenID, int aIsNoScript)
|
||||
{
|
||||
Token *token;
|
||||
int isReadOnly = 0;
|
||||
|
||||
// if it was a readonly keyword read the attribute keyword
|
||||
// if it was a readonly keyword read the next keyword
|
||||
if (READONLY_TOKEN == aTokenID) {
|
||||
isReadOnly = 1;
|
||||
TrimComments();
|
||||
|
@ -554,6 +585,7 @@ IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aT
|
|||
|
||||
// create the attribute object
|
||||
IdlAttribute *attrObj = new IdlAttribute();
|
||||
attrObj->SetIsNoScript(aIsNoScript);
|
||||
attrObj->SetReadOnly(isReadOnly);
|
||||
|
||||
// this must be the attribute type
|
||||
|
@ -632,14 +664,23 @@ IdlAttribute* IdlParser::ParseAttribute(IdlSpecification &aSpecification, int aT
|
|||
return attrObj;
|
||||
}
|
||||
|
||||
IdlFunction* IdlParser::ParseFunction(IdlSpecification &aSpecification, Token &aToken)
|
||||
IdlFunction* IdlParser::ParseFunction(IdlSpecification &aSpecification, Token *aToken)
|
||||
{
|
||||
// NOTE: we don't process the function specifier "oneway"
|
||||
int isNoScript = 0;
|
||||
|
||||
// if it was a readonly keyword read the next keyword
|
||||
if (NOSCRIPT_TOKEN == aToken->id) {
|
||||
isNoScript = 1;
|
||||
TrimComments();
|
||||
aToken = mScanner->NextToken();
|
||||
}
|
||||
|
||||
IdlFunction *funcObj = new IdlFunction();
|
||||
funcObj->SetIsNoScript(isNoScript);
|
||||
|
||||
// a function name starts with the return value
|
||||
switch(aToken.id) {
|
||||
switch(aToken->id) {
|
||||
// base type
|
||||
case BOOLEAN_TOKEN:
|
||||
funcObj->SetReturnValue(TYPE_BOOLEAN);
|
||||
|
@ -683,8 +724,8 @@ IdlFunction* IdlParser::ParseFunction(IdlSpecification &aSpecification, Token &a
|
|||
break;
|
||||
// scoped name
|
||||
case IDENTIFIER_TOKEN:
|
||||
//if (aSpecification.ContainInterface(aToken.stringID)) {
|
||||
funcObj->SetReturnValue(TYPE_OBJECT, aToken.stringID);
|
||||
//if (aSpecification.ContainInterface(aToken->stringID)) {
|
||||
funcObj->SetReturnValue(TYPE_OBJECT, aToken->stringID);
|
||||
break;
|
||||
//}
|
||||
case XPIDL_TOKEN:
|
||||
|
|
|
@ -55,8 +55,9 @@ protected:
|
|||
IdlUnion* ParseUnion(IdlSpecification &aSpecification);
|
||||
IdlVariable* ParseConst(IdlSpecification &aSpecification);
|
||||
IdlException* ParseException(IdlSpecification &aSpecification);
|
||||
IdlAttribute* ParseAttribute(IdlSpecification &aSpecification, int aTokenID);
|
||||
IdlFunction* ParseFunction(IdlSpecification &aSpecification, Token &aToken);
|
||||
IdlAttribute* MaybeParseAttribute(IdlSpecification &aSpecification, int aTokenID);
|
||||
IdlAttribute* ParseAttribute(IdlSpecification &aSpecification, int aTokenID, int aIsNoScript=0);
|
||||
IdlFunction* ParseFunction(IdlSpecification &aSpecification, Token *aToken);
|
||||
|
||||
IdlParameter* ParseFunctionParameter(IdlSpecification &aSpecification);
|
||||
|
||||
|
|
|
@ -184,6 +184,9 @@ Token* IdlScanner::NextToken()
|
|||
case 'l':
|
||||
LKeywords(mTokenName + 1, mCurrentToken);
|
||||
break;
|
||||
case 'n':
|
||||
NKeywords(mTokenName + 1, mCurrentToken);
|
||||
break;
|
||||
case 'o':
|
||||
OKeywords(mTokenName + 1, mCurrentToken);
|
||||
break;
|
||||
|
@ -776,6 +779,44 @@ void IdlScanner::LKeywords(char *aCurrentPos, Token *aToken)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 'noscript' is the only keyword starting with 'nl'.
|
||||
// If that is not it, it must be an identifier
|
||||
//
|
||||
void IdlScanner::NKeywords(char *aCurrentPos, Token *aToken)
|
||||
{
|
||||
int c = mInputFile->get();
|
||||
if (c != EOF && c == 'o' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 's' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'c' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'r' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'i' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 'p' && (*aCurrentPos++ = c) && (c = mInputFile->get()) &&
|
||||
c != EOF && c == 't' && (*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(NOSCRIPT_TOKEN);
|
||||
mInputFile->putback(c);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aToken->SetToken(NOSCRIPT_TOKEN);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// it must be an identifier
|
||||
KeywordMismatch(c, aCurrentPos, aToken);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 'out' is the only keyword starting with 'o'.
|
||||
// If that is not it, it must be an identifier
|
||||
|
|
|
@ -72,6 +72,7 @@ enum EIDLTokenType {
|
|||
FUNC_PARAMS_SPEC_BEGIN_TOKEN, // '('
|
||||
FUNC_PARAMS_SPEC_END_TOKEN, // ')'
|
||||
VOID_TOKEN,
|
||||
NOSCRIPT_TOKEN,
|
||||
UNKNOWN_TOKEN,
|
||||
// constant values
|
||||
INTEGER_CONSTANT = 1000,
|
||||
|
@ -192,6 +193,7 @@ protected:
|
|||
void FKeywords(char *aCurrentPos, Token *aToken);
|
||||
void IKeywords(char *aCurrentPos, Token *aToken);
|
||||
void LKeywords(char *aCurrentPos, Token *aToken);
|
||||
void NKeywords(char *aCurrentPos, Token *aToken);
|
||||
void OKeywords(char *aCurrentPos, Token *aToken);
|
||||
void RKeywords(char *aCurrentPos, Token *aToken);
|
||||
void SKeywords(char *aCurrentPos, Token *aToken);
|
||||
|
|
|
@ -259,15 +259,22 @@ JSStubGen::GeneratePropertySlots(IdlSpecification &aSpec)
|
|||
IdlAttribute *attr = iface->GetAttributeAt(a);
|
||||
char attr_name[128];
|
||||
|
||||
any_props = 1;
|
||||
if ((i == 0) && (a == 0)) {
|
||||
if (attr->GetIsNoScript()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is the first time...
|
||||
if (!any_props) {
|
||||
sprintf(buf, kPropEnumStr, iface->GetName(), iface->GetName());
|
||||
*file << buf;
|
||||
}
|
||||
// If this is the first time for this interface...
|
||||
else if (a == 0) {
|
||||
*file << ",\n";
|
||||
}
|
||||
|
||||
any_props = 1;
|
||||
|
||||
strcpy(attr_name, attr->GetName());
|
||||
StrUpr(attr_name);
|
||||
|
||||
|
@ -473,7 +480,7 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
|
|||
strcpy(attr_name, attr->GetName());
|
||||
StrUpr(attr_name);
|
||||
|
||||
if (!aIsGetter && (attr->GetReadOnly())) {
|
||||
if (attr->GetIsNoScript() || (!aIsGetter && (attr->GetReadOnly()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1097,6 +1104,10 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
|
|||
char return_type[128];
|
||||
int p, pcount = func->ParameterCount();
|
||||
|
||||
if (func->GetIsNoScript()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GetCapitalizedName(method_name, *func);
|
||||
// If this is a constructor don't have a method for it
|
||||
if (strcmp(method_name, iface_name) == 0) {
|
||||
|
@ -1322,6 +1333,10 @@ JSStubGen::GenerateClassProperties(IdlSpecification &aSpec)
|
|||
IdlAttribute *attr = iface->GetAttributeAt(a);
|
||||
char attr_name[128];
|
||||
|
||||
if (attr->GetIsNoScript()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy(attr_name, attr->GetName());
|
||||
StrUpr(attr_name);
|
||||
|
||||
|
@ -1373,6 +1388,10 @@ JSStubGen::GenerateClassFunctions(IdlSpecification &aSpec)
|
|||
char method_name[128];
|
||||
IdlFunction *func = iface->GetFunctionAt(m);
|
||||
|
||||
if (func->GetIsNoScript()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GetCapitalizedName(method_name, *func);
|
||||
// If this is a constructor don't have a method for it.
|
||||
if (strcmp(method_name, iface_name) == 0) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче