Ejemplo n.º 1
0
CAudioInput::CAudioInput()
{
	SetInit();
	//파일입출력 디버깅용!
	fpBufferData = fopen("bufferData.txt", "w+");
	fpTempoData = fopen("tempoData.txt", "w+");
}
Ejemplo n.º 2
0
Set_t*
SetCreate(long size)
{
	Set_t *set = (Set_t *)emalloc(sizeof(Set_t));
	SetInit(set, size);
	return set;
}
Ejemplo n.º 3
0
//
// ObjectData::SetInit
//
void SetInit(Init &init, ObjectExpression *data, VariableType const *type)
{
   init.data.clear();
   init.type.clear();
   init.dataAll = false;
   init.typeAll = IT_UNKNOWN;

   ObjectExpression::Vector dataVec;
   if(data)
   {
      data->expand(&dataVec);
      init.data.resize(type->getSize(SourcePosition::none()));
      dataVec.resize(init.data.size());
   }
   init.type.resize(type->getSize(SourcePosition::none()));

   InitDataVector::iterator dataItr = init.data.begin();
   InitTypeVector::iterator typeItr = init.type.begin();
   ObjectExpression::Vector::iterator dataVecItr = dataVec.begin();

   SetInit(dataItr, typeItr, dataVecItr, type, !!data);

   // Check if the data is all there.
   init.dataAll = true;
   for(InitDataVector::iterator itr = init.data.begin(), end = init.data.end(); itr != end; ++itr)
   {
      if(!*itr)
      {
         init.dataAll = false;
         break;
      }
   }

   // Check if the types are all the same.
   for(InitTypeVector::iterator itr = init.type.begin(), end = init.type.end(); itr != end; ++itr)
   {
      if(*itr == IT_UNKNOWN || *itr == init.typeAll) continue;

      if(init.typeAll == IT_UNKNOWN)
      {
         init.typeAll = *itr;
      }
      else
      {
         init.typeAll = IT_MIXED;
         break;
      }
   }
}
Ejemplo n.º 4
0
//
// ObjectData::Static::Init
//
bool Static::Init(std::string const &name, VariableType const *type, ObjectExpression *init)
{
   auto itr = Table.find(name);
   if(itr == Table.end()) return false;

   Static &data = itr->second;

   SetInit(data.init, init, type);

   if(!data.init.dataAll) return false;

   if(Target != TARGET_MageCraft) return false;

   return true;
}
Ejemplo n.º 5
0
////////////////// OPERATIONS ///////////////////////////////
int
IADSR::Set(char* mess, float value){

  switch (FindMsg(mess)){

  case 31:
    SetInit(value);
    return 1;

  case 32:
    SetEnd(value);
    return 1;

  default:
    return ADSR::Set(mess,value);
  }

}
Ejemplo n.º 6
0
//
// SetInit
//
// This one recursively scans through type, consuming dataVec and writing to
// initData and initType.
//
static void SetInit(InitDataVector::iterator &initData, InitTypeVector::iterator &initType,
   ObjectExpression::Vector::iterator &dataVec, VariableType const *type, bool hasData)
{
   switch(type->getBasicType())
   {
   case VariableType::BT_VOID:
      break;

   case VariableType::BT_BIT_HRD:
   case VariableType::BT_BIT_SFT:
   case VariableType::BT_CHR:
   case VariableType::BT_ACC_HH:
   case VariableType::BT_ACC_H:
   case VariableType::BT_ACC:
   case VariableType::BT_ANG_HH:
   case VariableType::BT_ANG_H:
   case VariableType::BT_ANG:
   case VariableType::BT_ANG_L:
   case VariableType::BT_ANG_LL:
   case VariableType::BT_FIX_HH:
   case VariableType::BT_FIX_H:
   case VariableType::BT_FIX:
   case VariableType::BT_FLT_HH:
   case VariableType::BT_FLT_H:
   case VariableType::BT_FLT:
   case VariableType::BT_FRA_HH:
   case VariableType::BT_FRA_H:
   case VariableType::BT_FRA:
   case VariableType::BT_FRA_L:
   case VariableType::BT_FRA_LL:
   case VariableType::BT_INT_HH:
   case VariableType::BT_INT_H:
   case VariableType::BT_INT:
   case VariableType::BT_UNS_HH:
   case VariableType::BT_UNS_H:
   case VariableType::BT_UNS:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_ACC_L:
   case VariableType::BT_ACC_LL:
   case VariableType::BT_FIX_L:
   case VariableType::BT_FIX_LL:
   case VariableType::BT_FLT_L:
   case VariableType::BT_FLT_LL:
   case VariableType::BT_INT_L:
   case VariableType::BT_INT_LL:
   case VariableType::BT_UNS_L:
   case VariableType::BT_UNS_LL:
      if(hasData)
      {
         ++dataVec; // TODO
         *initData++ = NULL;
         *initData++ = NULL;
      }
      *initType++ = IT_INTEGER;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_LABEL:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_STR:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_STRING;
      break;

   case VariableType::BT_ARR:
      for(bigsint i = type->getWidth(); i--;)
         SetInit(initData, initType, dataVec, type->getReturn(), hasData);
      break;

   case VariableType::BT_PTR:
      if(VariableType::IsTypeFunction(type->getReturn()->getBasicType()))
      {
         SetInit(initData, initType, dataVec, type->getReturn(), hasData);
         break;
      }

      switch(type->getReturn()->getStoreType())
      {
      case STORE_FAR:
         if(hasData)
         {
            ++dataVec; // TODO
            *initData++ = NULL;
            *initData++ = NULL;
         }
         *initType++ = IT_INTEGER;
         *initType++ = IT_INTEGER;
         break;

      case STORE_STRING:
         if(hasData)
         {
            ++dataVec; // TODO
            *initData++ = NULL;
            *initData++ = NULL;
         }
         *initType++ = IT_STRING;
         *initType++ = IT_INTEGER;
         break;

      default:
         if(hasData) *initData++ = *dataVec++;
         *initType++ = IT_INTEGER;
         break;
      }
      break;

   case VariableType::BT_PTR_NUL:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_ENUM:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_CLX:
   case VariableType::BT_CLX_IM:
   case VariableType::BT_SAT:
   case VariableType::BT_STRUCT:
   case VariableType::BT_BLOCK:
      for(VariableType::Vector::const_iterator end = type->getTypes().end(),
          itr = type->getTypes().begin(); itr != end; ++itr)
      {
         SetInit(initData, initType, dataVec, *itr, hasData);
      }
      break;

   case VariableType::BT_UNION:
      if(hasData) ++dataVec; // TODO
      for(bigsint i = type->getSize(SourcePosition::none()); i--;)
      {
         if(hasData) *initData++ = NULL;
         *initType++ = IT_INTEGER;
      }
      break;

   case VariableType::BT_FUN_ASM:
      if(hasData) ++dataVec; // TODO
      break;

   case VariableType::BT_FUN:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_FUNCTION;
      break;

   case VariableType::BT_FUN_LIN:
   case VariableType::BT_FUN_NAT:
   case VariableType::BT_FUN_SNU:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_INTEGER;
      break;

   case VariableType::BT_FUN_SNA:
      if(hasData) *initData++ = *dataVec++;
      *initType++ = IT_STRING;
      break;
   }
}
Ejemplo n.º 7
0
/*! Constructor
 */
CFishDory::CFishDory(CAquarium *aquarium) : CFish(aquarium, FishDoryImageName)
{   
    SetInit(3, 20);
    SetItemType(L"CFishDory");
}
Ejemplo n.º 8
0
void SkJS::InitializeDisplayables(const SkBitmap& bitmap, JSContext *cx, JSObject *obj, JSObject *proto) {
    SkJSDisplayable::gCanvas = new SkCanvas(bitmap);
    SkJSDisplayable::gPaint = new SkPaint();
#if SK_USE_CONDENSED_INFO == 0
    GenerateTables();
#else
    SkASSERT(0); // !!! compressed version hasn't been implemented
#endif
    AddInit(cx, obj, proto);
    AddCircleInit(cx, obj, proto);
    AddOvalInit(cx, obj, proto);
    AddPathInit(cx, obj, proto);
    AddRectangleInit(cx, obj, proto);
    AddRoundRectInit(cx, obj, proto);
//  AfterInit(cx, obj, proto);
    ApplyInit(cx, obj, proto);
    // AnimateInit(cx, obj, proto);
//  AnimateColorInit(cx, obj, proto);
    AnimateFieldInit(cx, obj, proto);
//  AnimateRotateInit(cx, obj, proto);
//  AnimateScaleInit(cx, obj, proto);
//  AnimateTranslateInit(cx, obj, proto);
    BitmapInit(cx, obj, proto);
//  BaseBitmapInit(cx, obj, proto);
//  BeforeInit(cx, obj, proto);
    BitmapShaderInit(cx, obj, proto);
    BlurInit(cx, obj, proto);
    ClipInit(cx, obj, proto);
    ColorInit(cx, obj, proto);
    CubicToInit(cx, obj, proto);
    DashInit(cx, obj, proto);
    DataInit(cx, obj, proto);
//  DimensionsInit(cx, obj, proto);
    DiscreteInit(cx, obj, proto);
    DrawToInit(cx, obj, proto);
    EmbossInit(cx, obj, proto);
    EventInit(cx, obj, proto);
//  FontInit(cx, obj, proto);
//  FocusInit(cx, obj, proto);
    ImageInit(cx, obj, proto);
    IncludeInit(cx, obj, proto);
//  InputInit(cx, obj, proto);
    LineInit(cx, obj, proto);
    LinearGradientInit(cx, obj, proto);
    LineToInit(cx, obj, proto);
    MatrixInit(cx, obj, proto);
    MoveInit(cx, obj, proto);
    MoveToInit(cx, obj, proto);
    OvalInit(cx, obj, proto);
    PathInit(cx, obj, proto);
    PaintInit(cx, obj, proto);
    DrawPointInit(cx, obj, proto);
    PolyToPolyInit(cx, obj, proto);
    PolygonInit(cx, obj, proto);
    PolylineInit(cx, obj, proto);
    PostInit(cx, obj, proto);
    QuadToInit(cx, obj, proto);
    RadialGradientInit(cx, obj, proto);
    RandomInit(cx, obj, proto);
    RectToRectInit(cx, obj, proto);
    RectangleInit(cx, obj, proto);
    RemoveInit(cx, obj, proto);
    ReplaceInit(cx, obj, proto);
    RotateInit(cx, obj, proto);
    RoundRectInit(cx, obj, proto);
    ScaleInit(cx, obj, proto);
    SetInit(cx, obj, proto);
    SkewInit(cx, obj, proto);
    // 3D_CameraInit(cx, obj, proto);
    // 3D_PatchInit(cx, obj, proto);
    SnapshotInit(cx, obj, proto);
//  StrokeInit(cx, obj, proto);
    TextInit(cx, obj, proto);
    TextOnPathInit(cx, obj, proto);
    TextToPathInit(cx, obj, proto);
    TranslateInit(cx, obj, proto);
//  UseInit(cx, obj, proto);
}
Ejemplo n.º 9
0
char *CNWNXSortSet::OnRequest(char *gameObject, char *SetName, char* Parameters) {
	char setkey[32], name[22], cmd[32], arg1[1024], arg2[1024], arg3[1024], *lastarg, *pos;


	arg1[0] = 0;
	arg2[0] = 0;
	arg3[0] = 0;

	// Parameters are the call "ADD!value", "GET!15", "LENGTH", etc.
	
	GetNextArg(SetName, name, 22);
	results = Parameters;

	sprintf(setkey, "%08x-%s", gameObject, name);
	
	lastarg = Parameters;
	if ((pos = GetNextArg(Parameters, cmd, 31)) != NULL) {
		lastarg = pos;
		if ((pos = GetNextArg(pos, arg1, 1024)) != NULL) {
			lastarg = pos;
			if ((pos = GetNextArg(pos, arg2, 1024)) != NULL) {
				lastarg = pos;
				if ((pos = GetNextArg(pos, arg3, 1024)) != NULL) {
					lastarg = pos;
				}
			}
		}
	}

	if (strcmp("INIT", cmd) == 0) {
		SetInit(setkey);
	} else if (strcmp("ADD", cmd) == 0) {
		Add(setkey, arg1, arg2, arg3);
	} else if (strcmp("EXISTS", cmd) == 0) {
		Exists(setkey, arg1);
	} else if (strcmp("LENGTH", cmd) == 0) {
		Length(setkey);
	} else if (strcmp("SORT", cmd) == 0) {
		Sort(setkey);
	} else if (strcmp("DESTROY", cmd) == 0) {
		Destroy(setkey);
	} else if (sets.find(setkey) == sets.end()) {
		Log(0, "[%s] Set does not exist\n", setkey);
		sprintf(Parameters, "-5 [%s] Set does not exist.", setkey);
	} else if (strcmp("SETBYIDX", cmd) == 0) {
		SetByIdx(setkey, arg1, arg2, arg3);
	} else if (strcmp("SETBYTAG", cmd) == 0) {
		SetByTag(setkey, arg1, arg2, arg3);
	} else if (strcmp("REMOVE", cmd) == 0) {
		Remove(setkey, arg1);
	} else if (strcmp("GETBYIDX", cmd) == 0) {
		GetByIdx(setkey, arg1);
	} else if (strcmp("GETBYTAG", cmd) == 0) {
		GetByTag(setkey, arg1);
	} else {
		sprintf(Parameters, "[%s] bad command", cmd);
		Log(0, "[%s] %s\n", setkey, Parameters);
	}

	return NULL;
}
Ejemplo n.º 10
0
ConnectInfo::ConnectInfo()
{
	SetInit();
}
Ejemplo n.º 11
0
bool stGateTask::CmdParse(const Cmd::stNullCmd * pt_null_cmd, const int cmd_size)
{
	if((unsigned int)cmd_size < sizeof(Cmd::stProtoBufCmd))
	{
		Global::logger->fatal("[gate_cmd_error] this user send cmd len less sizeof(stprotobufcmd) <ip=%s,port=%u>",
							  GetIP(),GetPort());
		Terminate();
		stAssert(0);
		return false;
	}
	
	const Cmd::stProtoBufCmd * p_recv_cmd = (const Cmd::stProtoBufCmd *)pt_null_cmd;

	DWORD cmd_id = p_recv_cmd->cmdid;
	
	defCheckCmdLen(cmd_id, p_recv_cmd->cmdlen, (defCmdId)cmd_size);
	
	if(!is_check)
	{
		Global::logger->fatal("[gate_cmd_error] this user send cmd length error <ip=%s,port=%u,cmdid=%u,cmdsize=%u>",
							  GetIP(),GetPort(), cmd_id, cmd_size);
		Terminate();
		stAssert(0);
		return false;
	}
	
	Global::logger->debug("[gate_cmd] recv a command <ip=%s,port=%u,id=%u,len=%u>",GetIP(), GetPort(), cmd_id,cmd_size);

	if(IsInit())
	{
		stGateUser * p_user = stGateUserManager::GetInstance().GetUser(userid);
		if(!p_user)
		{
			Terminate();
			return true;
		}
		
		SendCmdToInfo(pt_null_cmd, cmd_size);
	}
	else
	{
		/// 登录
		if(cmd_id == Cmd::enRequestLogin)
		{
			Cmd::cmdRequestLogin p_recv;
			p_recv.google::protobuf::MessageLite::ParseFromArray(p_recv_cmd->data, p_recv_cmd->cmdlen);
		
			Global::logger->debug("[login_cmd] recv login para <token=%s,uniqueid=%s>",
								  p_recv.token().c_str(), p_recv.uniqueid().c_str());

			Cmd::cmdRegisterUser info_cmd;
			info_cmd.set_isrec(false);
			
			if(p_recv.has_tempid())
			{				
				stGateUser * p_old_user = stGateUserManager::GetInstance().GetUser(p_recv.tempid());
				if(p_old_user)
				{
					SetInit(p_recv.tempid());
					p_old_user->Connect();
					p_old_user->SetTask(this);
					
					info_cmd.set_isrec(true);
					info_cmd.set_tempid(p_old_user->GetTempId());
					info_cmd.set_uniqueid(p_old_user->GetUniqueId());

					SendCmdToInfo(Cmd::enRegisterUser, &info_cmd, info_cmd.ByteSize());

					Global::logger->debug("reconnect <tempid=%llu>", p_recv.tempid());

					Cmd::cmdNotifyLoginResult send_cmd;
					send_cmd.set_result(Cmd::cmdNotifyLoginResult::LOGIN_RESULT_OK);
					send_cmd.set_tempid(p_recv.tempid());
					SendCmd(Cmd::enNotifyLoginResult, &send_cmd, send_cmd.ByteSize());
					
					return true;
				}
			}

			stGateUser * p_new_user = new stGateUser(GetTaskId(), p_recv.uniqueid().c_str());
			p_new_user->SetTask(this);
			stGateUserManager::GetInstance().AddUser(p_new_user);
				
			Cmd::cmdNotifyLoginResult send_cmd;
			send_cmd.set_result(Cmd::cmdNotifyLoginResult::LOGIN_RESULT_OK);
			send_cmd.set_tempid(GetTaskId());
			SendCmd(Cmd::enNotifyLoginResult, &send_cmd, send_cmd.ByteSize());
			
			SetInit(GetTaskId());
			
			info_cmd.set_tempid(GetTaskId());
			info_cmd.set_uniqueid(p_recv.uniqueid());
			SendCmdToInfo(Cmd::enRegisterUser, &info_cmd, info_cmd.ByteSize());
		}
		else
		{
			Global::logger->debug("recv error cmd <%u>", cmd_id);
			stAssert(0);
			Terminate();
		}
	}

	return true;
}