Exemple #1
0
 RedisCommandFrame(ArgumentArray& cmd) :
         type(REDIS_CMD_INVALID), m_is_inline(false), m_cmd_seted(false), m_raw_data_size(0)
 {
     m_cmd = cmd.front();
     cmd.pop_front();
     m_args = cmd;
 }
Exemple #2
0
 void ExpireCheck::ExpireCheckCallback(const DBID& db, const Slice& key, void* data)
 {
     ExpireCheck* e = (ExpireCheck*) data;
     ArgumentArray args;
     args.push_back("del");
     args.push_back(std::string(key.data(), key.size()));
     RedisCommandFrame cmd(args);
     e->m_server->GetMaster().FeedSlaves(NULL, db, cmd);
 }
XSIPLUGINCALLBACK XSI::CStatus VMFImport_Init( const XSI::CRef& in_context )
{
	Context ctx(in_context);
	Command cmd(ctx.GetSource());

	cmd.EnableReturnValue ( true );


	ArgumentArray args = cmd.GetArguments();

	args.Add( L"arg0", (long)0 );
	
	return XSI::CStatus::OK;
}
Exemple #4
0
 std::string ToString() const
 {
     std::string cmd;
     cmd.append(m_cmd).append(" ");
     for (uint32 i = 0; i < m_args.size(); i++)
     {
         cmd.append(m_args[i]);
         if (i != m_args.size() - 1)
         {
             cmd.append(" ");
         }
     }
     return cmd;
 }
Exemple #5
0
				int OnRawKeyValue(const Slice& key, const Slice& value)
				{
					ArgumentArray args;
					args.push_back("__SET__");
					args.push_back(std::string(key.data(), key.size()));
					args.push_back(std::string(value.data(), value.size()));
					RedisCommandFrame cmd(args);
					conn.conn->Write(cmd);
					count++;
					if (count % 10000 == 0)
					{
						conn.conn->GetService().Continue();
					}
					return 0;
				}
Exemple #6
0
 const std::string* GetArgument(uint32 index) const
 {
     if (index >= m_args.size())
     {
         return NULL;
     }
     return &(m_args[index]);
 }
XSIPLUGINCALLBACK CStatus Coat3DExport_Init( CRef& in_ctxt )
{
	Context ctxt( in_ctxt );
	Command oCmd;
	oCmd = ctxt.GetSource();
	
	// Specify that the command returns a value
	oCmd.EnableReturnValue(true);
	//Application app;
	app.LogMessage(L"Coat3DExport_Init!");

	// Add arguments to the command
	ArgumentArray oArgs;
	oArgs = oCmd.GetArguments();

	oArgs.Add(L"tempLocation", (CString)siString);
	oArgs.Add(L"coatLocation",(CString)siString);
	oArgs.Add(L"typePaint",(CValue)siUInt);
	//oArgs.Add(L"bCopyTexE",(CValue)siBool);
	oArgs.Add(L"bExpMat",(CValue)siBool);
	oArgs.Add(L"bExpUV",(CValue)siBool);
	oArgs.Add(L"bExpNorm",(CValue)siBool);

	return CStatus::OK;
}
Exemple #8
0
 RedisCommandFrame(const char* fmt, ...) :
         type(REDIS_CMD_INVALID), m_is_inline(false), m_cmd_seted(false), m_raw_data_size(0)
 {
     va_list ap;
     va_start(ap, fmt);
     char buf[1024];
     vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
     va_end(ap);
     char * pch;
     pch = strtok(buf, " ");
     while (pch != NULL)
     {
         m_args.push_back(std::string(pch));
         pch = strtok(NULL, " ");
     }
     m_cmd = m_args.front();
     m_args.pop_front();
 }
/** Defines the arguments to the export command */
XSI::CStatus OgreMeshExportCommand_Init( const XSI::CRef& context )
{
	Context ctx(context);
	Command cmd(ctx.GetSource());

	Application app;
	app.LogMessage( L"Defining: " + cmd.GetName() );

	ArgumentArray args = cmd.GetArguments();

    args.Add( L"objectName", L"" );
	args.Add( L"targetMeshFileName", L"c:/default.mesh" );
	args.Add( L"calculateEdgeLists", L"true" );
    args.Add( L"calculateTangents", L"false" );
    args.Add( L"exportSkeleton", L"true" );
	args.Add( L"exportVertexAnimation", L"true" );
    args.Add( L"targetSkeletonFileName", L"c:/default.skeleton" );
    args.Add( L"fps", L"24" );
    args.Add( L"animationList", L"" ); 
	return XSI::CStatus::OK;

}
Exemple #10
0
 inline void FillNextArgument(Buffer& buf, size_t len)
 {
     const char* str = buf.GetRawReadBuffer();
     buf.AdvanceReadIndex(len);
     if (m_cmd_seted)
     {
         m_args.push_back(std::string(str, len));
     }
     else
     {
         m_cmd.append(str, len);
         m_cmd_seted = true;
     }
 }
Exemple #11
0
/* ウィンドウクラス登録実行、XSIのウィンドウハンドル取得はここで */
XSIPLUGINCALLBACK CStatus GMenu_Init( CRef& in_ctxt )
{
	Context ctxt( in_ctxt );
	Command oCmd(ctxt.GetSource());
	oCmd.PutDescription(L"");
	oCmd.SetFlag(siCannotBeUsedInBatch,true);
	oCmd.SetFlag(siNoLogging,true);
	oCmd.EnableReturnValue(true);

	ArgumentArray oArgs = oCmd.GetArguments();
	oArgs.Add(L"MenuSetName");

	gWnd = (HWND)Application().GetDesktop().GetApplicationWindowHandle();	//XSI のウィンドウハンドル
	gInstance = GetModuleHandle(NULL);										//自分のインスタンス


	if ( myWindowClassReg( gInstance ) == 0 ) {	//ウィンドウクラス登録
		Application().LogMessage(L" cannnot regiser window class.",siVerboseMsg);
		return CStatus::False;
	}
	DebugLog(L" registered windows class.");
	return CStatus::OK;
}
Exemple #12
0
Command::ArgumentArray Command::getEffectiveArguments() const {
	uint effectiveArgumentsStart;
	switch (_subTypeDesc->controlFlowType) {
		case kFlowEnd:
			effectiveArgumentsStart = 0;
			break;
		case kFlowNormal:
			effectiveArgumentsStart = 1;
			break;
		case kFlowBranch:
			effectiveArgumentsStart = 2;
			break;
		default:
			error("Unhandled control flow type '%d'", _subTypeDesc->controlFlowType);
	}

	ArgumentArray effectiveArguments;
	for (uint i = effectiveArgumentsStart; i < _arguments.size(); i++) {
		effectiveArguments.push_back(_arguments[i]);
	}

	return  effectiveArguments;
}
Exemple #13
0
void BSpit::xbchangeboiler(const ArgumentArray &args) {
	uint32 heat = _vm->_vars["bheat"];
	uint32 water = _vm->_vars["bblrwtr"];
	uint32 platform = _vm->_vars["bblrgrt"];

	// Stop any background videos
	_vm->_video->closeVideos();

	if (args[0] == 1) {
		// Water is filling/draining from the boiler
		if (water == 0) {
			if (platform == 1)
				_vm->getCard()->playMovie(12);
			else
				_vm->getCard()->playMovie(10);
		} else if (heat == 1) {
			if (platform == 1)
				_vm->getCard()->playMovie(22);
			else
				_vm->getCard()->playMovie(19);
		} else {
			if (platform == 1)
				_vm->getCard()->playMovie(16);
			else
				_vm->getCard()->playMovie(13);
		}
	} else if (args[0] == 2 && water != 0) {
		if (heat == 1) {
			// Turning on the heat
			if (platform == 1)
				_vm->getCard()->playMovie(23);
			else
				_vm->getCard()->playMovie(20);
		} else {
			// Turning off the heat
			if (platform == 1)
				_vm->getCard()->playMovie(18);
			else
				_vm->getCard()->playMovie(15);
		}
	} else if (args[0] == 3) {
		if (platform == 1) {
			// Lowering the platform
			if (water == 1) {
				if (heat == 1)
					_vm->getCard()->playMovie(24);
				else
					_vm->getCard()->playMovie(17);
			} else {
				_vm->getCard()->playMovie(11);
			}
		} else {
			// Raising the platform
			if (water == 1) {
				if (heat == 1)
					_vm->getCard()->playMovie(21);
				else
					_vm->getCard()->playMovie(14);
			} else {
				_vm->getCard()->playMovie(9);
			}
		}
	}

	if (args.size() > 1)
		_vm->getCard()->playSound(args[1]);
	else if (args[0] == 2)
		_vm->getCard()->playSound(1);

	RivenVideo *video = _vm->_video->openSlot(11);
	video->playBlocking();
}
Exemple #14
0
    int LUAInterpreter::CallArdb(lua_State *lua, bool raise_error)
    {
        int j, argc = lua_gettop(lua);
        ArgumentArray cmdargs;

        /* Require at least one argument */
        if (argc == 0)
        {
            luaPushError(lua, "Please specify at least one argument for redis.call()");
            return 1;
        }

        /* Build the arguments vector */
        for (j = 0; j < argc; j++)
        {
            if (!lua_isstring(lua, j + 1))
                break;
            std::string arg;
            arg.append(lua_tostring(lua, j + 1), lua_strlen(lua, j + 1));
            cmdargs.push_back(arg);
        }

        /* Check if one of the arguments passed by the Lua script
         * is not a string or an integer (lua_isstring() return true for
         * integers as well). */
        if (j != argc)
        {
            luaPushError(lua, "Lua redis() command arguments must be strings or integers");
            return 1;
        }

        /* Setup our fake client for command execution */

        RedisCommandFrame cmd(cmdargs);
        Ardb::RedisCommandHandlerSetting* setting = g_db->FindRedisCommandHandlerSetting(cmd);
        /* Command lookup */
        if (NULL == setting)
        {
            luaPushError(lua, "Unknown Redis command called from Lua script");
            return -1;
        }

        /* There are commands that are not allowed inside scripts. */
        if (!setting->IsAllowedInScript())
        {
            luaPushError(lua, "This Redis command is not allowed from scripts");
            return -1;
        }
        LuaExecContext* ctx = g_lua_exec_ctx.GetValue();

        /* Write commands are forbidden against read-only slaves, or if a
         * command marked as non-deterministic was already called in the context
         * of this script. */
        if (setting->IsWriteCommand())
        {
            if (!g_db->GetConf().master_host.empty() && g_db->GetConf().slave_readonly && !g_db->IsLoadingData() && !(ctx->caller->flags.slave))
            {
                luaPushError(lua, "-READONLY You can't write against a read only slave.");
                return -1;
            }
        }

        Context& lua_ctx = ctx->exec;
        RedisReply& reply = lua_ctx.GetReply();
        reply.Clear();
        lua_ctx.ClearFlags();
        lua_ctx.flags.lua = 1;
        g_db->DoCall(lua_ctx, *setting, cmd);
        if (raise_error && reply.type != REDIS_REPLY_ERROR)
        {
            raise_error = 0;
        }
        redisProtocolToLuaType(lua, reply);

        if (raise_error)
        {
            /* If we are here we should have an error in the stack, in the
             * form of a table with an "err" field. Extract the string to
             * return the plain error. */
            lua_pushstring(lua, "err");
            lua_gettable(lua, -2);
            return lua_error(lua);
        }
        return 1;
    }
Exemple #15
0
// Command 18: transition
// Note that this opcode has 1 or 5 parameters, depending on args.size()
// Parameter 0: transition type
// Parameters 1-4: transition rectangle
void RivenSimpleCommand::transition(uint16 op, const ArgumentArray &args) {
	if (args.size() == 1)
		_vm->_gfx->scheduleTransition((RivenTransition) args[0]);
	else
		_vm->_gfx->scheduleTransition((RivenTransition) args[0], Common::Rect(args[1], args[2], args[3], args[4]));
}
Exemple #16
0
// Command 1: draw tBMP resource (tbmp_id, left, top, right, bottom, u0, u1, u2, u3)
void RivenSimpleCommand::drawBitmap(uint16 op, const ArgumentArray &args) {
	if (args.size() < 5) // Copy the image to the whole screen, ignoring the rest of the parameters
		_vm->_gfx->copyImageToScreen(args[0], 0, 0, 608, 392);
	else          // Copy the image to a certain part of the screen
		_vm->_gfx->copyImageToScreen(args[0], args[1], args[2], args[3], args[4]);
}
bool csShaderGLCGCommon::DefaultLoadProgram (iShaderProgramCG* cgResolve,
  const char* programStr, ProgramType _type,
  const ProfileLimitsPair& customLimitsPair, uint flags)
{
  if (!programStr || !*programStr) return false;

  const ProfileLimits& customLimits = (_type == progVP) ?
    customLimitsPair.vp : customLimitsPair.fp;
  CGGLenum type = (_type == progVP) ? CG_GL_VERTEX : CG_GL_FRAGMENT;

  size_t i;
  csString augmentedProgramStr = GetAugmentedProgram (programStr,
    (flags & loadFlagUnusedV2FForInit) != 0);
    
  programStr = augmentedProgramStr;
  CGprofile profile = customLimits.profile;
  CS::PluginCommon::ShaderProgramPluginGL::HardwareVendor vendor =
    customLimits.vendor;

  if (shaderPlug->doVerbose || shaderPlug->doVerbosePrecache)
  {
    shaderPlug->Report (CS_REPORTER_SEVERITY_NOTIFY,
      "Cg %s program %s: using profile %s[%d]", GetProgramType(),
      CS::Quote::Single (description.GetData ()),
      cgGetProfileString (profile), profile);
  }

  ArgumentArray args;
  shaderPlug->GetProfileCompilerArgs (GetProgramType(), profile, 
    customLimitsPair,
    vendor,
    (flags & loadIgnoreConfigProgramOpts) ? csGLShader_CG::argsNoConfig
      : csGLShader_CG::argsAll, args);
  for (i = 0; i < compilerArgs.GetSize(); i++) 
    args.Push (compilerArgs[i]);
  programPositionInvariant = false;
  for (i = 0; i < args.GetSize(); ) 
  {
    if (strcmp (args[i], "-posinv") == 0)
    {
      if (profile >= CG_PROFILE_GPU_VP)
      {
	/* Work around Cg 2.0 and above (including 3.0) bug: it emits
	   "OPTION ARB_position_invariant;" AND computes result.position in
	   the VP - doing both is verboten.
	   Affected are the GP4VP and higher profiles.
	   Remedy: remove -posinv argument 
	 */
	args.DeleteIndex (i);
	continue;
      }
      programPositionInvariant = true;
    }
    i++;
  }
  customLimits.ToCgOptions (args);
  args.Push (0);
 
  if (program)
  {
    cgDestroyProgram (program);
  }
  shaderPlug->SetCompiledSource (programStr);
  shaderPlug->SetIgnoreErrors (true);
  program = cgCreateProgram (shaderPlug->context, 
    CG_SOURCE, programStr, 
    profile, !entrypoint.IsEmpty() ? entrypoint : "main", args.GetArray());
  shaderPlug->SetIgnoreErrors (false);
  
  if (!(flags & loadIgnoreErrors)) shaderPlug->PrintAnyListing();

  if (!program)
  {
    shaderPlug->SetCompiledSource (0);
    /*if (shaderPlug->debugDump)
    {
      EnsureDumpFile();
      WriteAdditionalDumpInfo ("Failed program source", programStr);
    }*/
    return false;
  }
  programProfile = cgGetProgramProfile (program);

  GetParamsFromVmapConstants();
  if (flags & loadApplyVmap)
    GetParamsFromVmap();

  if (flags & loadIgnoreErrors) shaderPlug->SetIgnoreErrors (true);
  cgCompileProgram (program);
  if (flags & loadIgnoreErrors)
    shaderPlug->SetIgnoreErrors (false);
  else
    shaderPlug->PrintAnyListing();
  
  if (flags & loadApplyVmap)
    GetPostCompileParamProps ();

  if (flags & loadLoadToGL)
  {
    cgGetError(); // Clear error
    cgGLLoadProgram (program);
    if (!(flags & loadIgnoreErrors)) shaderPlug->PrintAnyListing();
    if ((cgGetError() != CG_NO_ERROR)
      || !cgGLIsProgramLoaded (program)) 
    {
      if (shaderPlug->debugDump)
	DoDebugDump();

      if (shaderPlug->doVerbose
	  && (((type == CG_GL_VERTEX) && (profile >= CG_PROFILE_ARBVP1))
	    || ((type == CG_GL_FRAGMENT) && (profile >= CG_PROFILE_ARBFP1))))
      {
	csString err = (char*)glGetString (GL_PROGRAM_ERROR_STRING_ARB);
	if (!err.IsEmpty())
	  shaderPlug->Report (CS_REPORTER_SEVERITY_WARNING,
	    "OpenGL error string: %s", err.GetData());
      }

      shaderPlug->SetCompiledSource (0);
      return false;
    }
  }

  if (shaderPlug->debugDump)
    DoDebugDump();
  
  shaderPlug->SetCompiledSource (0);

  bool result = true;
  if (programType == progFP)
  {
    int numVaryings = 0;
    CGparameter param = cgGetFirstLeafParameter (program, CG_PROGRAM);
    while (param)
    {
      if (cgIsParameterUsed (param, program)
	&& cgIsParameterReferenced (param))
      {
	const CGenum var = cgGetParameterVariability (param);
	if (var == CG_VARYING)
	  numVaryings++;
      }
  
      param = cgGetNextLeafParameter (param);
    }
    
    /* WORKAROUND: Even NVs G80 doesn't support passing more than 16 attribs
       into an FP, yet Cg happily generates code that uses more (and GL falls 
       back to SW).
       So manually check the number of varying inputs and reject more than 16.
       
       @@@ This should be at least configurable
     */
    const int maxNumVaryings = 16;
    if (numVaryings > maxNumVaryings)
    {
      if (shaderPlug->doVerbose || shaderPlug->doVerbosePrecache)
      {
	shaderPlug->Report (CS_REPORTER_SEVERITY_NOTIFY,
	  "Discarding compiled program for having too much varyings "
	  "(%d, limit is %d)",
	  numVaryings, maxNumVaryings);
      }
      cgDestroyProgram (program);
      program = 0;
      result = false;
    }
  }
  if (!result && !debugFN.IsEmpty())
  {
    csRef<iVFS> vfs = csQueryRegistry<iVFS> (objectReg);
    vfs->DeleteFile (debugFN);
  }
  return result;
}
Exemple #18
0
 void Clear()
 {
     m_cmd_seted = false;
     m_cmd.clear();
     m_args.clear();
 }