Exemplo n.º 1
0
void CallStmt::Expand(Fragment *fragment)
{
	if (Fragment *sub = gProgram->GetSub(fName))
	{
                const RCX_Target *t = gProgram->GetTarget();
                if (!t->fSubParams)
                {
                        // sub call
                        if (!fragment->IsTask())
                        {
                                Error(kErr_NestedSubs).Raise(&fLocation);
                        }
                        else if (fParams.size() != 0)
                        {
                                Error(kErr_ParamCount).Raise(&fLocation);
                        }
                        else
                        {
                                SetBody(new GosubStmt(sub, fLocation));
                                sub->AssignTaskID(fragment->GetTaskID());
                        }
                }
                else
                {
                        GosubParamStmt *g = new GosubParamStmt(sub, fLocation);
                        g->AddParams(fParams);
                        SetBody(g);
                        sub->AssignTaskID(fragment->GetTaskID());
                }
	}
	else if (FunctionDef *func = gProgram->GetFunction(fName))
	{
		if (func->IsExpanded())
		{
			Error(kErr_RecursiveCall, fName->GetKey()).Raise(&fLocation);
		}
		else
		{
			func->SetExpanded(true);
			ExpandFunction(func, fragment);
			func->SetExpanded(false);
		}
	}
	else
	{
		Error(kErr_UndefinedFunction, fName->GetKey()).Raise(&fLocation);
	}
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------
|   PLT_HttpHelper::SetBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::SetBody(NPT_HttpMessage& message, 
                        NPT_String&      body, 
                        NPT_HttpEntity** entity /* = NULL */)
{
    return SetBody(message, (const char*)body, body.GetLength(), entity);
}
Exemplo n.º 3
0
OgreNewtonSceneBody::OgreNewtonSceneBody (OgreNewtonWorld* const ogreWorld, dLong collisionMask)
	:dNewtonDynamicBody (NULL)
{
	Matrix4 matrix (Matrix4::IDENTITY);
	dNewtonCollisionScene collision (ogreWorld, collisionMask);
	SetBody (NewtonCreateDynamicBody (ogreWorld->GetNewton (), collision.GetShape(), matrix[0]));
}
Exemplo n.º 4
0
SanityCrystal::SanityCrystal(Renderer* pRenderer, Engine* pEngine)
	: RenderedEntity(pRenderer, pEngine, new TextureRenderObject(pRenderer))
{
	auto textureObject = reinterpret_cast<TextureRenderObject*>(renderObject.get());

	textureObject->SetTextureName(L"Entities1");
	textureObject->SetTextureClip(Rect(128, 1, 160, 43));

	b2BodyDef bodyDef;
	bodyDef.fixedRotation = true;
	bodyDef.type = b2_staticBody;
	bodyDef.angle = 0.0f;

	b2PolygonShape box;
	box.SetAsBox(0.25f, 0.32f);

	b2FixtureDef fixtureDef;
	fixtureDef.shape = &box;
	fixtureDef.density = 1.0f;
	fixtureDef.friction = 0.0f;
	fixtureDef.isSensor = true;

	SetBody(parent->GetPhysics()->CreateBody(&bodyDef));
	body->CreateFixture(&fixtureDef);
}
Exemplo n.º 5
0
/*----------------------------------------------------------------------
|   PLT_HttpHelper::SetBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::SetBody(NPT_HttpMessage& message, 
                        const char*      text, 
                        NPT_HttpEntity** entity /* = NULL */)
{
    return SetBody(message, (const char*)text, NPT_StringLength(text), entity);
}
Exemplo n.º 6
0
ClassDef::ClassDef(class Ast* ast, const location& loc, AstNode* nm,
		AstNode* arglist, AstNode* suite) :
    Stmt(AST_CLASSDEF, ast, loc), starargs(NULL), kwargs(NULL)
{
	SetName(nm);
	SetBody(suite);
	ParseArglist(arglist);
}
Exemplo n.º 7
0
While::While(class Ast* ast, const location& loc, AstNode* _test, AstNode* _body,
		AstNode* _orelse) :
    Stmt(AST_WHILE, ast, loc), test(NULL)
{
	SetTest(_test);
	SetBody(_body);
	SetOrElse(_orelse);
}
Exemplo n.º 8
0
If::If(class Ast* _ast, const location& _loc,  AstNode *_test,
		AstNode *_body, AstNode *_orelse):
		Stmt(AST_IF, _ast, _loc), test(NULL)
{
	SetTest(_test);
	SetBody(_body);
	SetOrElse(_orelse);
}
dNewtonVehicleManager::dNewtonVehicle::~dNewtonVehicle ()
{
	NewtonBody* const body = m_controller->GetBody();	
	if (NewtonBodyGetDestructorCallback(body)) {
		SetBody(NULL);
		dNewtonVehicleManager* const manager = (dNewtonVehicleManager*)m_controller->GetManager();
		manager->DestroyController (m_controller);
	}
}
Exemplo n.º 10
0
nsresult nsMsgSearchValidityManager::InitLocalNewsBodyTable()
{
  NS_ASSERTION (nsnull == m_localNewsBodyTable, "already have local news+body validity table");
  nsresult rv = NewTable(getter_AddRefs(m_localNewsBodyTable));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = SetLocalNews(m_localNewsBodyTable);
  NS_ENSURE_SUCCESS(rv, rv);
  return SetBody(m_localNewsBodyTable);
}
Exemplo n.º 11
0
For::For(Ast* ast, const location& loc, AstNode* _target, AstNode* _iter,
	AstNode* _body, AstNode* _orelse) :
	Stmt(AST_FOR, ast, loc), target(NULL), iter(NULL)
{
	if (_target) SetTarget(_target);
	if (_iter) SetIter(_iter);
	if (_body) SetBody(_body);
	if (_orelse) SetOrElse(_orelse);
}
Exemplo n.º 12
0
void ArpUniDimens::SetTo(float pre, float minb, float prefb, float maxb, float post)
{
	ArpVALIDATE(pre >= 0, pre = 0);
	ArpVALIDATE(post >= 0, post = 0);
	
	mPreLabel = pre;
	mPostLabel = post;
	
	SetBody(minb, prefb, maxb);
}
Exemplo n.º 13
0
void CDirtSpriteWithBody::init(float x, float y, int color_type, float scale)
{
    SetSprite("ZybbleTrail.png", scale);
    
    this->color_type = color_type;
    sprite->setColor(colors[color_type]);
    
    if(fadeoutOnInit)
        fadeoutDirectly();
    
    if (scale == 1.5)
    {
        SetBody(x, y, 0, 0);
    }
    else 
    {
        SetBody(x, y, CCRANDOM_MINUS1_1() / 2048, 0);
    }
}
Exemplo n.º 14
0
Arquivo: Player.cpp Projeto: mpre/pm
Player::Player(float xPosition=0.0f, float yPosition=0.0f) : CProcess(), temp_i(0)
{
	m_tLast_surface_change = SDL_GetTicks();
	b2BodyDef def;
	def.type = b2_dynamicBody;
	def.position.Set( xPosition, yPosition );
	def.awake = true;
	SetBody(def);
	m_sState = new StandingState(this);
	initPoint = b2Vec2(xPosition, yPosition);
}
Exemplo n.º 15
0
void putObject(ClientPtrType client, String bucketName, String key, String path, Map metadata, size_t loop)
{
    String base = "=== Put Object [" + bucketName + "/" + key;
    std::cout << base << "]: Start ===\n";
    std::cout << "Reading from " << path << "\n";
    auto inpData = Aws::MakeShared<Aws::FStream>("PutObjectInputStream",
            path.c_str(), std::ios_base::in | std::ios_base::binary);
    auto objReq = Aws::S3::Model::PutObjectRequest();
    objReq.WithBucket(bucketName).SetBody(inpData);;
    if (!metadata.empty())
    {
        std::cout << "Map Key\t:\t\tValue\n";
        for(auto& it: metadata)
        {
            auto key = it.first;
            auto value = it.second;
            std::cout << key << "\t:\t\t" << value << "\n";
        }
        objReq.SetMetadata(metadata);
    }
    if (loop == 0)
    {
        auto objRes = client->PutObject(objReq.WithKey(key));
        if (!objRes.IsSuccess())
        {
            std::cout << base << "]: Client Side failure ===\n";
            std::cout << objRes.GetError().GetExceptionName() << "\t" <<
                        objRes.GetError().GetMessage() << "\n";
        }
        if (!std::get<0>(doesObjectExists(client, bucketName, key)))
        {
            std::cout << base << "]: Failed ===\n";
        }
    }
    for (size_t i = 0; i < loop; ++i)
    {
        auto inpData = Aws::MakeShared<Aws::FStream>("PutObjectInputStream",
                path.c_str(), std::ios_base::in | std::ios_base::binary);
        objReq.SetBody(inpData);;
        String key_suffix = std::to_string(i).c_str();
        auto objRes = client->PutObject(objReq.WithKey(key + key_suffix));
        if (!objRes.IsSuccess())
        {
            std::cout << base << key_suffix << "]: Client Side failure ===\n";
            std::cout << objRes.GetError().GetExceptionName() << "\t" <<
                        objRes.GetError().GetMessage() << "\n";
        }
        if (!std::get<0>(doesObjectExists(client, bucketName, key + key_suffix)))
        {
            std::cout << base << key_suffix << "]: Failed ===\n";
        }
    }
    std::cout << base << "]: End ===\n\n";
}
Exemplo n.º 16
0
/*----------------------------------------------------------------------
|   NPT_HttpMessage::SetBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::SetBody(NPT_HttpMessage& message, 
                        const char*      body, 
                        NPT_LargeSize    len, 
                        NPT_HttpEntity** entity /* = NULL */)
{
    if (len == 0) return NPT_SUCCESS;

    // dump the body in a memory stream
    NPT_MemoryStreamReference stream(new NPT_MemoryStream);
    stream->Write(body, (NPT_Size)len);

    // set content length
    return SetBody(message, (NPT_InputStreamReference)stream, entity);
}
Exemplo n.º 17
0
/*----------------------------------------------------------------------
|   NPT_HttpMessage::SetBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::SetBody(NPT_HttpMessage* message, const char* body, NPT_Size len)
{
    if (len == 0) {
        return NPT_SUCCESS;
    }

    // dump the body in a memory stream
    NPT_MemoryStreamReference stream(new NPT_MemoryStream);
    stream->Write(body, len);

    // set content length
    PLT_HttpHelper::SetContentLength(message, len);

    return SetBody(message, (NPT_InputStreamReference&)stream, len);
}
Exemplo n.º 18
0
NS_IMETHODIMP nsMsgCompFields::ConvertBodyToPlainText()
{
  nsresult rv = NS_OK;
  
  if (!m_body.IsEmpty())
  {
    nsAutoString body;
    rv = GetBody(body);
    if (NS_SUCCEEDED(rv))
    {
      rv = ConvertBufToPlainText(body, UseFormatFlowed(GetCharacterSet()));
      if (NS_SUCCEEDED(rv))
        rv = SetBody(body);
    }
  }
  return rv;
}
Exemplo n.º 19
0
 CDynamics2DEPuckModel::CDynamics2DEPuckModel(CDynamics2DEngine& c_engine,
                                              CEPuckEntity& c_entity) :
    CDynamics2DSingleBodyObjectModel(c_engine, c_entity),
    m_cEPuckEntity(c_entity),
    m_cWheeledEntity(m_cEPuckEntity.GetWheeledEntity()),
    m_cDiffSteering(c_engine,
                    EPUCK_MAX_FORCE,
                    EPUCK_MAX_TORQUE,
                    EPUCK_INTERWHEEL_DISTANCE),
    m_fCurrentWheelVelocity(m_cWheeledEntity.GetWheelVelocities()) {
    /* Create the body with initial position and orientation */
    cpBody* ptBody =
       cpSpaceAddBody(GetDynamics2DEngine().GetPhysicsSpace(),
                      cpBodyNew(EPUCK_MASS,
                                cpMomentForCircle(EPUCK_MASS,
                                                  0.0f,
                                                  EPUCK_RADIUS + EPUCK_RADIUS,
                                                  cpvzero)));
    const CVector3& cPosition = GetEmbodiedEntity().GetOriginAnchor().Position;
    ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
    CRadians cXAngle, cYAngle, cZAngle;
    GetEmbodiedEntity().GetOriginAnchor().Orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
    cpBodySetAngle(ptBody, cZAngle.GetValue());
    /* Create the body shape */
    cpShape* ptShape =
       cpSpaceAddShape(GetDynamics2DEngine().GetPhysicsSpace(),
                       cpCircleShapeNew(ptBody,
                                        EPUCK_RADIUS,
                                        cpvzero));
    ptShape->e = 0.0; // No elasticity
    ptShape->u = 0.7; // Lots of friction
    /* Constrain the actual base body to follow the diff steering control */
    m_cDiffSteering.AttachTo(ptBody);
    /* Set the body so that the default methods work as expected */
    SetBody(ptBody, EPUCK_HEIGHT);
 }
Exemplo n.º 20
0
void CGargantua::RunTask( const Task_t& task )
{
	switch ( task.iTask )
	{
	case TASK_DIE:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			SetRenderFX( kRenderFxExplode );
			SetRenderColor( Vector( 255, 0, 0 ) );
			StopAnimation();
			SetNextThink( gpGlobals->time + 0.15 );
			SetThink( &CGargantua::SUB_Remove );
			int i;
			int parts = MODEL_FRAMES( gGargGibModel );
			for ( i = 0; i < 10; i++ )
			{
				auto pGib = CGib::GibCreate( GARG_GIB_MODEL );
				
				int bodyPart = 0;
				if ( parts > 1 )
					bodyPart = RANDOM_LONG( 0, GetBody() -1 );

				pGib->SetBody( bodyPart );
				pGib->m_bloodColor = BLOOD_COLOR_YELLOW;
				pGib->m_material = matNone;
				pGib->SetAbsOrigin( GetAbsOrigin() );
				pGib->SetAbsVelocity( UTIL_RandomBloodVector() * RANDOM_FLOAT( 300, 500 ) );
				pGib->SetNextThink( gpGlobals->time + 1.25 );
				pGib->SetThink( &CGib::SUB_FadeOut );
			}
			MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, GetAbsOrigin() );
				WRITE_BYTE( TE_BREAKMODEL);

				// position
				WRITE_COORD( GetAbsOrigin().x );
				WRITE_COORD( GetAbsOrigin().y );
				WRITE_COORD( GetAbsOrigin().z );

				// size
				WRITE_COORD( 200 );
				WRITE_COORD( 200 );
				WRITE_COORD( 128 );

				// velocity
				WRITE_COORD( 0 ); 
				WRITE_COORD( 0 );
				WRITE_COORD( 0 );

				// randomization
				WRITE_BYTE( 200 ); 

				// Model
				WRITE_SHORT( gGargGibModel );	//model id#

				// # of shards
				WRITE_BYTE( 50 );

				// duration
				WRITE_BYTE( 20 );// 3.0 seconds

				// flags

				WRITE_BYTE( BREAK_FLESH );
			MESSAGE_END();

			return;
		}
		else
			CBaseMonster::RunTask( task );
		break;

	case TASK_FLAME_SWEEP:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			FlameDestroy();
			TaskComplete();
			FlameControls( 0, 0 );
			SetBoneController( 0, 0 );
			SetBoneController( 1, 0 );
		}
		else
		{
			bool cancel = false;

			Vector angles = g_vecZero;

			FlameUpdate();
			CBaseEntity *pEnemy = m_hEnemy;
			if ( pEnemy )
			{
				Vector org = GetAbsOrigin();
				org.z += 64;
				Vector dir = pEnemy->BodyTarget(org) - org;
				angles = UTIL_VecToAngles( dir );
				angles.x = -angles.x;
				angles.y -= GetAbsAngles().y;
				if ( dir.Length() > 400 )
					cancel = true;
			}
			if ( fabs(angles.y) > 60 )
				cancel = true;
			
			if ( cancel )
			{
				m_flWaitFinished -= 0.5;
				m_flameTime -= 0.5;
			}
			// FlameControls( angles.x + 2 * sin(gpGlobals->time*8), angles.y + 28 * sin(gpGlobals->time*8.5) );
			FlameControls( angles.x, angles.y );
		}
		break;

	default:
		CBaseMonster::RunTask( task );
		break;
	}
}
Exemplo n.º 21
0
void CallStmt::ExpandFunction(FunctionDef *func, Fragment *fragment)
{
	size_t argCount = func->GetArgCount();

	// check number of parameters
	if (argCount != fParams.size())
	{
		Error(kErr_ParamCount).Raise(&fLocation);
		return;
	}

	/* statement should look like this:
	 *
	 * CallStmt
	 *   |
	 * InlineStmt
	 *   |
	 * ScopeStmt
	 *   |
	 * BlockStmt
	 *   /        |       \
	 * DeclareStmt...   body of function
	 */
	BlockStmt *block = new BlockStmt();
	SetBody( new InlineStmt(new ScopeStmt(block), func));

	Mapping mapping;

	for(size_t i=0; i<argCount; i++)
	{
		const Expr* arg = fParams[i];
		int var = func->GetArgVar(i);
		int val;

		switch(func->GetArgType(i))
		{
			case FunctionDef::kConstantArg:
				if (!arg->Evaluate(val))
				{
					Error(kErr_ParamType, "constant").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, new AtomExpr(kRCX_ConstantType, val, fLocation));
				break;
			case FunctionDef::kIntegerArg:
				val = gProgram->NextVirtualVar();
				mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation));
				{
					DeclareStmt *ds = new DeclareStmt(func->GetArgName(i), val, fLocation, 1, false, true);
					ds->SetInitialValue(arg->Clone(0));
					block->Add(ds);
				}
				break;
			case FunctionDef::kReferenceArg:
				val = arg->GetLValue();
				if (val == kIllegalVar)
				{
					Error(kErr_ParamType, "variable").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation));
				break;
			case FunctionDef::kConstRefArg:
				mapping.Add(var, arg->Clone(0));
				break;
			case FunctionDef::kSensorArg:
				if (RCX_VALUE_TYPE(arg->GetStaticEA()) != kRCX_InputValueType)
				{
					Error(kErr_ParamType, "sensor").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, arg->Clone(0));
				break;
                        case FunctionDef::kPointerArg:
                                if (!arg->LValueIsPointer())
                                {
                                    Error(kErr_ParamType, "pointer").Raise(&arg->GetLoc());
                                    return;
                                }
                                mapping.Add(var, arg->Clone(0));
                                break;
                        case FunctionDef::kConstPtrArg:
                                if (!arg->LValueIsPointer())
                                {
                                    Error(kErr_ParamType, "pointer").Raise(&arg->GetLoc());
                                    return;
                                }
                                val = gProgram->NextVirtualVar();
                                {
                                    DeclareStmt *ds = new DeclareStmt(func->GetArgName(i), val, fLocation, 1, true, true);
                                    ds->SetInitialValue(arg->Clone(0));
                                    block->Add(ds);
                                }
                                mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation, true));
                                break;
			default:
				Error(kErr_ParamType, "???").Raise(&fParams[i]->GetLoc());
				return;
		}
	}


	// add body of inline and then expand
	block->Add(func->GetBody()->Clone(&mapping));

	Expander e(fragment);
	Apply(GetBody(), e);
}
Exemplo n.º 22
0
/*----------------------------------------------------------------------
|   PLT_HttpHelper::SetBody
+---------------------------------------------------------------------*/
NPT_Result
PLT_HttpHelper::SetBody(NPT_HttpMessage* message, NPT_String& body)
{
    return SetBody(message, (const char*)body, body.GetLength());
}
Exemplo n.º 23
0
void DeclareStmt::SetInitialValue(Expr *e)
{
	SetBody(new AssignStmt(new AtomExpr(kRCX_VariableType, fVar, e->GetLoc()), e));
}
Exemplo n.º 24
0
void sfHttpRequest_SetBody(sfHttpRequest* httpRequest, const char* body)
{
    CSFML_CALL(httpRequest, SetBody(body ? body : ""));
}
Exemplo n.º 25
0
// Custom information packet, only transported via SIP for conformalities' sake.
SIPInfoPacket::SIPInfoPacket(String i_body)
: SIPPacket(SIP_INFO){
	SetBody(i_body);
	cSeq = "3326 "+PacketTypeName();	
}