예제 #1
0
nsresult
nsJSUtils::EvaluateString(JSContext* aCx,
                          JS::SourceBufferHolder& aSrcBuf,
                          JS::Handle<JSObject*> aScopeObject,
                          JS::CompileOptions& aCompileOptions,
                          void **aOffThreadToken)
{
  EvaluateOptions options;
  options.setNeedResult(false);
  JS::RootedValue unused(aCx);
  return EvaluateString(aCx, aSrcBuf, aScopeObject, aCompileOptions,
                        options, &unused, aOffThreadToken);
}
bool ExpressionEvaluator::Evaluate( const string& actualValue, const RoutingKeyword::EVALUATOR_TYPE evalType ) const
{
	switch( evalType )
	{
		case RoutingKeyword::STRING :
			return EvaluateString( actualValue );
		case RoutingKeyword::DATE :
			return EvaluateDate( actualValue );
		case RoutingKeyword::CURRENCY :
			return EvaluateCurrency( actualValue );
	}
	return false;
}
예제 #3
0
nsresult
nsJSUtils::EvaluateString(JSContext* aCx,
                          const nsAString& aScript,
                          JS::Handle<JSObject*> aScopeObject,
                          JS::CompileOptions& aCompileOptions,
                          const EvaluateOptions& aEvaluateOptions,
                          JS::MutableHandle<JS::Value> aRetValue,
                          void **aOffThreadToken)
{
  const nsPromiseFlatString& flatScript = PromiseFlatString(aScript);
  JS::SourceBufferHolder srcBuf(flatScript.get(), aScript.Length(),
                                JS::SourceBufferHolder::NoOwnership);
  return EvaluateString(aCx, srcBuf, aScopeObject, aCompileOptions,
                        aEvaluateOptions, aRetValue, aOffThreadToken);
}
예제 #4
0
afx_msg void
CConsoleWindow::OnCharAdded(NMHDR* nmhdr, LRESULT* result) {
  SCNotification* notify = (SCNotification*)nmhdr;
  if (nmhdr->hwndFrom == __m_InputBar__) {
    if (!m_script_running && notify->ch == '\n') {
      int line = 0;
      int len = SendInputBar(SCI_LINELENGTH, (WPARAM) line);
      if (len >= 0 && len < 512) {
        char buffer[512] = {0};
        int offset = 0;
        if (len > 0) {
          len = SendInputBar(SCI_GETLINE, (LPARAM) line, (WPARAM) buffer);
          if (len >= 2) {
            if (buffer[len + offset - 2] == '\r' || buffer[len + offset - 2] == '\n') {
              buffer[len + offset - 2] = '\0';
              len -= 1;
              offset += 1;
            }
            if (buffer[len + offset - 1] == '\n' || buffer[len + offset - 1] == '\r') {
              buffer[len + offset - 1] = '\0';
              len -= 1;
              offset += 1;
            }
          }
        }
        SendInputBar(SCI_SETTARGETSTART, SendInputBar(SCI_POSITIONFROMLINE, 0));
        SendInputBar(SCI_SETTARGETEND,   SendInputBar(SCI_POSITIONFROMLINE, 1));
        SendInputBar(SCI_REPLACETARGET, 0, (WPARAM)"");
        SendInputBar(SCI_GOTOPOS, SendInputBar(SCI_GETTEXTLENGTH));
        SendInputBar(SCI_EMPTYUNDOBUFFER);
        if (strlen(buffer) >= 1) {
          EvaluateString(buffer);
        }
      }
    }
  }
}