Exemple #1
0
JSBool hasAttribute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	JS_BeginRequest(cx);
	nsCOMPtr<nsIDOMNode> mNode = (nsIDOMNode*)JS_GetPrivate(cx, obj);
	nsCOMPtr<nsIDOMElement> mElement = do_QueryInterface(mNode);
	if(mElement == NULL)
	{
		*rval = JSVAL_FALSE;
		JS_EndRequest(cx);
		return JS_TRUE;
	}
	LPWSTR name;
	if(!JS_ConvertArguments(cx, argc, argv, "W", &name))
	{
		JS_ReportError(cx, "Error parsing arguments in set attribute");
		JS_EndRequest(cx);
		return JS_FALSE;
	}
	JS_EndRequest(cx);

	nsDependentString aName(name);
	PRBool hasAttribute;
	mElement->HasAttribute(aName, &hasAttribute);
	*rval = hasAttribute ? JSVAL_TRUE : JSVAL_FALSE;
	return JS_TRUE;
}
Exemple #2
0
JSBool setAttribute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	JS_BeginRequest(cx);
	nsCOMPtr<nsIDOMNode> mNode = (nsIDOMNode*)JS_GetPrivate(cx, obj);
	nsCOMPtr<nsIDOMElement> mElement = do_QueryInterface(mNode);
	if(mElement == NULL)
	{
		*rval = JSVAL_FALSE;
		JS_EndRequest(cx);
		return JS_TRUE;
	}
	LPWSTR name, value;
	if(!JS_ConvertArguments(cx, argc, argv, "W W", &name, &value))
	{
		JS_ReportError(cx, "Error parsing arguments in set attribute");
		JS_EndRequest(cx);
		return JS_FALSE;
	}
	JS_EndRequest(cx);

	nsDependentString aName(name), aValue(value);
	EnterCriticalSection(&domStateLock);
	domState = 1;
	mElement->SetAttribute(aName, aValue);
	LeaveCriticalSection(&domStateLock);
	return JS_TRUE;
}
    virtual void initialize()
    {
        theTriggerProcessor = ExpressionProcessor( this, theTrigger );
        theTriggerProcessor.initialize( getModel() );
        
        theDelayProcessor = ExpressionProcessor( this, theDelay );
        theDelayProcessor.initialize( getModel() );
        
        for( EANameVector::const_iterator aName( theEANameVector.begin() );
             aName != theEANameVector.end(); ++aName )
        {
            theEventAssignmentMap[ *aName ].initialize( getModel() );
        }

        Process::initialize();
        _LIBECS_MIXIN_CLASS_::initialize();
        
        for( VariableReferenceVector::const_iterator i(
                    getVariableReferenceVector().begin() );
             i != getVariableReferenceVector().end(); ++i )
        {
            if( i->getCoefficient() != 0 )
            {
                theVariableReference = *i;
                return;
            }
        }
        THROW_EXCEPTION_INSIDE(InitializationFailed, "No variable references with non-zero coefficients exist");
    }
Exemple #4
0
//------------------------------------------------------------------------------------------------------
// testing
// ESRRemoveService
//------------------------------------------------------------------------------------------------------
TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESRRemoveService>)
{
    TInt result;

    //-- 1. Create and start a connection.
    result = CreateStartDefaultConnection();
    if(result != KErrNone)
        return result;

	result = OpenServiceResolver();
    if(result != KErrNone)
    {
    //-- stop and close connection
    StopCloseConnection();
    return result;
    }

	// "echo" service is on port 7, or we could try "http" on port 80.
	TUint aPort = 7;
	_LIT(KName, "echo");
	TBufC<20> aName(KName);

	result = SendReceive(ESRRemoveService,TIpcArgs(&aName,aPort,0, iSSRes));

    if(result != KErrNone) return result;

    //-- stop and close connection
    StopCloseConnection();

    return result;
}
Exemple #5
0
//------------------------------------------------------------------------------------------------------
// testing
// EHRCancel
//------------------------------------------------------------------------------------------------------
TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<EHRCancel>)
{
    TInt result;

    //-- 1. Create a connection.
    result = CreateConnection();
    if(result != KErrNone)
        return result;

    result = OpenHostResolver();
    if(result != KErrNone)
    {
    //-- stop and close connection
    StopCloseConnection();
    return result;
    }

	_LIT(KName, "www.yahoo.com");
	TBufC<20> aName(KName);

    TNameEntry aResult;

	result = SendReceive(EHRGetByName,TIpcArgs(&aName,&aResult,0, iSSRes));

    result =SendReceive(EHRCancel,TIpcArgs(0,0,0,iSSRes));
    if(result != KErrNone)
        return result;

    //-- stop and close connection
    result = StopCloseConnection();

    return result;
}
Exemple #6
0
//------------------------------------------------------------------------------------------------------
// testing
// EHRSetHostName
// Requires alive connection. Uses Ethernet one
//------------------------------------------------------------------------------------------------------
TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<EHRSetHostName>)
{
    TInt result;

    //-- 1. Create and start a connection.
    result = CreateStartDefaultConnection();
    if(result != KErrNone)
        return result;

    result = OpenHostResolver();
    if(result != KErrNone)
    {
    //-- stop and close connection
    StopCloseConnection();
    return result;
    }

    _LIT(KName, "localhost");
	TBufC<20> aName(KName);


    result =SendReceive(EHRSetHostName,TIpcArgs(&aName,0,0,iSSRes));
    if(result != KErrNotSupported)
        return result;

    //-- stop and close connection
    result = StopCloseConnection();

    return result;
}
Exemple #7
0
//------------------------------------------------------------------------------------------------------
// testing
// EHRGetByAddress
// Requires alive connection. Uses Ethernet one
//------------------------------------------------------------------------------------------------------
TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<EHRGetByAddress>)
{
    TInt result;


    //-- 1. Create  a connection.

	result = OpenHostResolver();
    if(result != KErrNone)
    {
    //-- close connection
    SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes));
    return result;
    }

	_LIT(KName, "127.0.0.1");
	TBufC<20> aName(KName);

    TInetAddr addr;
    addr.Input(aName);
    TNameEntry aResult;

    result =SendReceive(EHRGetByAddress,TIpcArgs(&addr,&aResult,0, iSSRes));
    if(result != KErrNone)
        return result;

    //-- stop  connection
    result = SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes));

    return result;
}
Exemple #8
0
FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
	ASSERT(m_pDocument != NULL);

	if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
		m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
		m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE;

	CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
	ASSERT(pInterForm != NULL);

	CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
	ASSERT(pPDFForm != NULL);

	v8::Isolate* isolate = GetIsolate(cc);
	CJS_Array aName(isolate);

	if (params.size() > 0)
	{
		switch (params[0].GetType())
		{
		default:
			aName.Attach(params[0].ToV8Array());
			break;
		case VT_string:
			aName.SetElement(0,params[0]);
			break;
		}

		CFX_PtrArray aFields;

		for (int i=0,isz=aName.GetLength(); i<isz; i++)
		{
			CJS_Value valElement(isolate);
			aName.GetElement(i,valElement);
			CFX_WideString swVal = valElement.ToCFXWideString();

			for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++)
			{
				aFields.Add((void*)pPDFForm->GetField(j,swVal));
			}
		}

		if (aFields.GetSize() > 0)
		{
			pPDFForm->ResetForm(aFields, TRUE, TRUE);
			m_pDocument->SetChangeMark();

		}
	}
	else
	{
		pPDFForm->ResetForm(TRUE);
		m_pDocument->SetChangeMark();

	}

	return TRUE;
}
Exemple #9
0
bool NetworkPNL::IsIdUnique(const char *nodeId, int nodeToIgnore)
{
    MarkCallFunction("IsIdUnique", true, (String() << nodeId).c_str());
    Vector<String> aName(Graph().Names());
    String name(nodeId);

    for(int i = aName.size(); --i >= 0;)
    {
	if((i != nodeToIgnore) && (aName[i] == name))
	{
	    return false;
	}
    }
    return true;
}
Exemple #10
0
void NameGenerator::load_name( JsonObject &jo )
{
    std::string name = jo.get_string( "name" );
    std::string usage = jo.get_string( "usage" );
    uint32_t type = 0;

    if( usage == "given" ) {
        type |= nameIsGivenName;
        name = pgettext( "Given Name", name.c_str() );
    } else if( usage == "family" ) {
        type |= nameIsFamilyName;
        name = pgettext( "Family Name", name.c_str() );
    } else if( usage == "universal" ) {
        type |= nameIsGivenName | nameIsFamilyName;
        name = pgettext( "Either Name", name.c_str() );
    } else if( usage == "backer" ) {
        type |= nameIsFullName;
        name = pgettext( "Full Name", name.c_str() );
    } else if( usage == "city" ) {
        type |= nameIsTownName;
        name = pgettext( "City Name", name.c_str() );
    } else if( usage == "world" ) {
        type |= nameIsWorldName;
        name = pgettext( "World Name", name.c_str() );
    }

    // Gender is optional
    if( jo.has_member( "gender" ) ) {
        std::string gender = jo.get_string( "gender" );

        if( gender == "male" ) {
            type |= nameIsMaleName;
        } else if( gender == "female" ) {
            type |= nameIsFemaleName;
        } else if( gender == "unisex" ) {
            type |= nameIsUnisexName;
        }
    }

    Name aName( name, type );

    // Add the name to the appropriate bucket
    names[type].push_back( aName );
}
uint32 MetaRecord::attributeIndex(
	const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const
{
	uint32 anIndex;
	switch (inAttributeInfo.AttributeNameFormat)
	{
	    case CSSM_DB_ATTRIBUTE_NAME_AS_STRING:
		{
			string aName(inAttributeInfo.Label.AttributeName);
			NameStringMap::const_iterator it = mNameStringMap.find(aName);
			if (it == mNameStringMap.end())
				CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);

			anIndex = it->second;
			break;
		}
	    case CSSM_DB_ATTRIBUTE_NAME_AS_OID:
	    {
			const CssmOid &aName =
				CssmOid::overlay(inAttributeInfo.Label.AttributeOID);
			NameOIDMap::const_iterator it = mNameOIDMap.find(aName);
			if (it == mNameOIDMap.end())
				CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);
			anIndex = it->second;
			break;
		}
		case CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER:
		{
			uint32 aName = inAttributeInfo.Label.AttributeID;
			NameIntMap::const_iterator it = mNameIntMap.find(aName);
			if (it == mNameIntMap.end())
				CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);
			anIndex = it->second;
			break;
		}
		default:
			CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);
			break;
	}

	return anIndex;
}
void  cAppliBATCH_MICMAC::act(const ElResParseDir & aRPD)  
{
   std::string aName (aRPD.name());
   std::string aNameLoc = aName.substr(mDirIm.size(),aName.size());

   if (! mAutomArg1->Match(aNameLoc))
      return;

  for 
  (
     std::list<string>::iterator itP=mCurB->PatternCommandeBatch().begin();
     itP != mCurB->PatternCommandeBatch().end();
     itP++
  )
  {
     bool aReplace =  mAutomArg1->Replace(*itP);
     ELISE_ASSERT(aReplace,"Cannot Replace in cAppliBATCH_MICMAC::act");
     ExecCom(mAutomArg1->LastReplaced());
  }
}
Exemple #13
0
bool	_HYConsoleWindow::ProcessEvent (_HYEvent* e)
{
	bool	done = false;
	
	_String firstArg;
	long	i,f,k;
	
	if (e->EventClass().Equal(&_hyButtonPushEvent))
	{
		firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1);
		k = firstArg.toNum();
		for (i=0;i<components.lLength;i++)
		{
			if (((_HYGuiObject*)components(i))->MatchID(k))
				break;
		}
		if (i==2)
		{
			firstArg 		= e->EventCode().Cut (f+1,-1);
			k 				= firstArg.toNum();
			_HYButtonBar * bb = (_HYButtonBar*)GetObject (2);
			
			switch	(k)
			{
				case 0:
				case 1:
					{

						_List menuChoices;
						if (k==0)
							for (long k=0; k<userHookins.lLength; k++)
							{
								_String *dName =  (_String*)userHookins(k),
										aName (*dName, dName->FindBackwards (
										#ifdef __MAC__
											':'
										#else
											#ifdef __WINDOZE__
											'\\'
											#else
											'/'
											#endif
										#endif
										,0,-1)+1,-1);
										
								menuChoices && & aName;
							}
						else
						{
							firstArg = "Search Commands";
							menuChoices && & firstArg;
							firstArg = "Search Descriptions";
							menuChoices && & firstArg;
							firstArg = "Search Notes";
							menuChoices && & firstArg;
							firstArg = "Export to LaTeX by name";
							menuChoices && & firstArg;
							firstArg = menuSeparator;
							menuChoices && & firstArg;
							firstArg = "Open in a window";
							menuChoices && & firstArg;
						}
						
						int h,v;
						bb->GetButtonLoc(k,h,v,true);
						_String userAction = HandlePullDown (menuChoices,h,v,0);
						bb->_UnpushButton();
						i = menuChoices.Find (&userAction);
						if (i>=0)
						{
							_ExecutionList uxl;
							if (k==0)
							{
								userAction = ((_String*)userHookins(i))->getStr();
							}
							else
								userAction = baseDirectory&"Help"&baseDirectory.sData[baseDirectory.sLength-1]&"Commands"&baseDirectory.sData[baseDirectory.sLength-1]&"query.bf";
							
							h = PushFilePath  (userAction);
							ReadBatchFile (userAction, uxl);
							
							if (k==1)
							{
								_String addin;
								switch (i)
								{
									case 0:
										addin = "Command";
										break;
									case 1:
										addin = "Description";
										break;
									case 2:
										addin = "Notes";
										break;
									case 3:
										addin = "Export";
										break;
									case 5:
										addin = "Window";
										break;
								}
								firstArg = ((_HYTextBox*)GetObject (1))->GetText();
								_FString qf = _FString (addin,false),
										 qt = _FString (firstArg,false);
								
								firstArg = "QUERY_FIELD";
								setParameter (firstArg,&qf);
								firstArg = "QUERY_TERM";
								setParameter (firstArg,&qt);
							}
								
							uxl.Execute();
							terminateExecution = false;
							if (h)
								PopFilePath   ();
							/*}
							else
							{
								userAction = userAction & " could not be found. Perhaps the file was recently moved or deleted.";
								ProblemReport (userAction, (Ptr)this);
							}*/
						}
					}
					break;
					
				case 2: 
					DoEcho();
					break;					

				case 3: 
				{
					_String webUpdate = baseDirectory&"TemplateBatchFiles"&baseDirectory.sData[baseDirectory.sLength-1]&"WebUpdate.bf";
					_ExecutionList wbl;
					k = PushFilePath  (webUpdate);
					ReadBatchFile (webUpdate, wbl);
					wbl.Execute();
					terminateExecution = false;
					if (k)
						PopFilePath   ();

				}
			}
			
			done = true;
		}
	}
	else
		if (e->EventClass().Equal(&_hyTextEditChange))
		{
			firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1);
			k = firstArg.toNum();
			for (i=0;i<components.lLength;i++)
			{
				if (((_HYGuiObject*)components(i))->MatchID(k))
					break;
			}
			if (i==0) // out box
			{
				_UpdateEditMenu();
				done = true;
			}		
			else
				if (i==1) // in box
				{
					firstArg 		= e->EventCode().Cut (f+1,-1);
					k 				= firstArg.toNum();
					_HYTextBox * ib = (_HYTextBox*)GetObject (1);
					
					if (k==2)
					{
						if (inputStatus == 1)
							inputStatus = 2;
					}
					else
					{
						if (k==3)
						// down arrow
						{
							if (inputLocation<recentInputs.lLength-1)
								ib->SetText (*(_String*)recentInputs(++inputLocation), false);
						}
						else 
							if (k==4)
							// up arrow
							{
								if (inputLocation>0)
									ib->SetText (*(_String*)recentInputs(--inputLocation), false);
							}
							else
							{	
								if (inputStatus == 1)
									inputLocation = recentInputs.lLength;
									
								_HYButtonBar * bb = (_HYButtonBar*)GetObject (2);
								bool 	onOff = ! ib->_IsEmpty();
								bb->EnableButton   (1,onOff);
							}
					}
					done = true;
				}		
		}
								
	if (done) 
	{
		DeleteObject (e);
		return true;
	}
	return _HYTWindow::ProcessEvent(e);	
}