Ejemplo n.º 1
0
void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
    m_bLinearized = TRUE;
    m_LastObjNum = m_pParser->GetLastObjNum();
    CPDF_Object* pIndirectObj =
        GetIndirectObject(m_pParser->GetRootObjNum(), nullptr);
    m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
    if (!m_pRootDict) {
        return;
    }
    pIndirectObj = GetIndirectObject(m_pParser->GetInfoObjNum(), nullptr);
    m_pInfoDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
    CPDF_Array* pIDArray = m_pParser->GetIDArray();
    if (pIDArray) {
        m_ID1 = pIDArray->GetString(0);
        m_ID2 = pIDArray->GetString(1);
    }
    FX_DWORD dwPageCount = 0;
    CPDF_Object* pCount = pLinearized->GetElement("N");
    if (ToNumber(pCount))
        dwPageCount = pCount->GetInteger();

    m_PageList.SetSize(dwPageCount);
    CPDF_Object* pNo = pLinearized->GetElement("P");
    if (ToNumber(pNo))
        m_dwFirstPageNo = pNo->GetInteger();

    CPDF_Object* pObjNum = pLinearized->GetElement("O");
    if (ToNumber(pObjNum))
        m_dwFirstPageObjNum = pObjNum->GetInteger();
}
Ejemplo n.º 2
0
static ejsval
_ejs_arguments_specop_get (ejsval obj, ejsval propertyName, ejsval receiver)
{
    EJSArguments* arguments = EJSVAL_TO_ARGUMENTS(obj);

    // check if propertyName is an integer, or a string that we can convert to an int
    EJSBool is_index = EJS_FALSE;
    ejsval idx_val = ToNumber(propertyName);
    int idx;
    if (EJSVAL_IS_NUMBER(idx_val)) {
        double n = EJSVAL_TO_NUMBER(idx_val);
        if (floor(n) == n) {
            idx = (int)n;
            is_index = EJS_TRUE;
        }
    }

    if (is_index) {
        if (idx < 0 || idx > arguments->argc) {
            printf ("getprop(%d) on an arguments, returning undefined\n", idx);
            return _ejs_undefined;
        }
        return arguments->args[idx];
    }

    // we also handle the length getter here
    if (EJSVAL_IS_STRING(propertyName) && !ucs2_strcmp (_ejs_ucs2_length, EJSVAL_TO_FLAT_STRING(propertyName))) {
        return NUMBER_TO_EJSVAL(arguments->argc);
    }

    // otherwise we fallback to the object implementation
    return _ejs_Object_specops.Get (obj, propertyName, receiver);
}
Ejemplo n.º 3
0
// 주어진 단어들로부터 알파벳 간의 선후 관계 그래프를 생성한다.
void MakeGraph(const std::vector<std::string>& words) {
  adj = std::vector<std::vector<int> >(26, std::vector<int>(26, 0));
  for (int j = 1; j < words.size(); ++j) {
    int i = j - 1;
    int len = std::min(words[i].size(), words[j].size());
    // words[i]가 words[j]앞에 오는 이유를 찾는다.
    for (int k = 0; k < len; ++k) {
      if (words[i][k] != words[j][k]) {
        int a = ToNumber(words[i][k]);
        int b = ToNumber(words[j][k]);
        adj[a][b] = 1;
        break;
      }
    }
  }
}
Ejemplo n.º 4
0
static void
_ejs_dataview_specop_put (ejsval obj, ejsval propertyName, ejsval val, ejsval receiver, EJSBool flag)
{
     EJSBool is_index = EJS_FALSE;
     ejsval idx_val = ToNumber(propertyName);
     int idx;
     if (EJSVAL_IS_NUMBER(idx_val)) {
         double n = EJSVAL_TO_NUMBER(idx_val);
         if (floor(n) == n) {
             idx = (int)n;
             is_index = EJS_TRUE;
         }
     }

     if (is_index) {
         if (idx < 0 || idx >= EJS_DATA_VIEW_BYTE_LEN(obj))
             return;

         void* data = _ejs_dataview_get_data (EJSVAL_TO_OBJECT(obj));
         ((unsigned char*)data)[idx] = (unsigned char)EJSVAL_TO_NUMBER(val);

         return;
     }

     _ejs_Object_specops.put (obj, propertyName, val, receiver, flag);
}
Ejemplo n.º 5
0
void _Menu::ConnectToHost() {
	_TextBox *Host = Assets.TextBoxes["textbox_connect_host"];
	_TextBox *Port = Assets.TextBoxes["textbox_connect_port"];
	if(Host->Text.length() == 0) {
		FocusedElement = Host;
		return;
	}

	if(Port->Text.length() == 0) {
		FocusedElement = Port;
		return;
	}

	PlayState.HostAddress = Host->Text;
	PlayState.ConnectPort = ToNumber(Port->Text);
	PlayState.Connect(false);

	_Label *Label = Assets.Labels["label_menu_connect_message"];
	Label->Color = COLOR_WHITE;
	Label->Text = "Connecting...";

	_Button *Button = Assets.Buttons["button_connect_connect"];
	((_Label *)Button->Children.front())->Text = "Cancel";

	FocusedElement = nullptr;
}
Ejemplo n.º 6
0
int CPDF_StructElementImpl::GetInteger(const CFX_ByteStringC& owner,
                                       const CFX_ByteStringC& name,
                                       int default_value,
                                       FX_BOOL bInheritable,
                                       int subindex) {
  CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex);
  return ToNumber(pAttr) ? pAttr->GetInteger() : default_value;
}
Ejemplo n.º 7
0
 TrieNode* find(const char* key) {
   if (*key == 0)
     return this;
   int next = ToNumber(*key);
   if (children[next] == NULL)
     return NULL;
   return children[next]->find(key + 1);
 }
Ejemplo n.º 8
0
	String LuaState::DumpStack() const
	{
		StringStream stream;
		unsigned int stackTop = GetStackTop();
		stream << stackTop << " entries\n";

		for (unsigned int i = 1; i <= stackTop; ++i)
		{
			stream << i << ": ";
			switch (GetType(i))
			{
				case LuaType_Boolean:
					stream << "Boolean(" << ToBoolean(i) << ')';
					break;

				case LuaType_Function:
					stream << "Function(" << ToPointer(i) << ')';
					break;

				case LuaType_LightUserdata:
				case LuaType_Userdata:
					stream << "Userdata(" << ToUserdata(i) << ')';
					break;

				case LuaType_Nil:
					stream << "Nil";
					break;

				case LuaType_None:
					stream << "None";
					break;

				case LuaType_Number:
					stream << "Number(" << ToNumber(i) << ')';
					break;

				case LuaType_String:
					stream << "String(" << ToString(i) << ')';
					break;

				case LuaType_Table:
					stream << "Table(" << ToPointer(i) << ')';
					break;

				case LuaType_Thread:
					stream << "Thread(" << ToPointer(i) << ')';
					break;

				default:
					stream << "Unknown(" << ToPointer(i) << ')';
					break;
			}

			stream << '\n';
		}

		return stream.ToString();
	}
Ejemplo n.º 9
0
void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) {
  m_bLinearized = true;
  LoadDocInternal();

  uint32_t dwPageCount = 0;
  CPDF_Object* pCount = pLinearizationParams->GetObjectFor("N");
  if (ToNumber(pCount))
    dwPageCount = pCount->GetInteger();
  m_PageList.SetSize(dwPageCount);

  CPDF_Object* pNo = pLinearizationParams->GetObjectFor("P");
  if (ToNumber(pNo))
    m_iFirstPageNo = pNo->GetInteger();

  CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O");
  if (ToNumber(pObjNum))
    m_dwFirstPageObjNum = pObjNum->GetInteger();
}
Ejemplo n.º 10
0
double CLuaBase::GetGlobalNumber( char* szName )
{
	double fValue = 0;
	lua_getglobal( m_pLuaState, szName );
	if( lua_isnumber( m_pLuaState, -1 ) )
		fValue = ToNumber( -1 );
	Pop(1);

	return fValue;
}
Ejemplo n.º 11
0
int main(int argc, char* argv[])
{
    if (argc != 5)
    {
        printf("usage: %s <document root> <port> <file cache size> <thread count>\n", GetApplicationName(argv[0]));
        return -1;
    }

    try
    {
        Server::GetInstance().Execute(argv[1], argv[2], ToNumber(argv[3]), ToNumber(argv[4]));
        return 0;
    }
    catch (...)
    {
        Common::LogException();
    }
    return -1;
}
Ejemplo n.º 12
0
 // 이 노드를 루트로 하는 트라이에 문자열 key를 추가한다.
 void insert(const char* key) {
   if (*key == 0) {
     terminal = true;
   } else {
     int next = ToNumber(*key);
     if (children[next] == NULL)
       children[next] = new TrieNode();
     children[next]->insert(key + 1);
   }
 }
Ejemplo n.º 13
0
double CLuaBase::GetFieldToNumber( int nStackPos, char* szName )
{
	double fValue = 0;
	lua_getfield( m_pLuaState, nStackPos, szName );
	if( lua_isnumber( m_pLuaState, -1 ) )
		fValue = ToNumber( -1 );
	Pop( 1 );

	return fValue;
}
Ejemplo n.º 14
0
int main(int argc, char* argv[])
{
	try
	{
		//Parameters
		if(argc!=3 && argc!=4)
		{
			std::cout<<"XFS <path> <disk> [<disk size>]"<<std::endl;
			return 0;
		}

		std::string windows_path=argv[1];
		std::string xfs_disk=argv[2];
		u32 xfs_disk_size=(argc==4?ToNumber(argv[3]):FLOPPY_SIZE);

		//Instanciamos el disco
		Disk* disk=Disk::GetDisk(xfs_disk, xfs_disk_size);
		
		//Variables del disco
		OFFSET xft_entry=TO_OFFSET(XFT_LBA);
		LBA writing_sector=XFT_LBA+XFT_SECTORS;

		//Escribimos el sector de arranque
		MappedFile boot_file(windows_path + "\\BOOT\\" BOOT_NAME);
		disk->Write(0, boot_file.GetBasePointer(), SECTOR_SIZE);

		//Escribimos el loader 
		//MappedFile loader_file(windows_path + "\\BOOT\\" LOADER_NAME);
		writing_sector+=XFS_FileWriter::Write(disk, windows_path + "\\BOOT", LOADER_NAME, xft_entry, writing_sector);
		xft_entry+=XFS_ENTRY_SIZE;

		//Escribimos el kernel
		writing_sector+=XFS_DirectoryWriter::Write(disk, windows_path, "KRNL", true, xft_entry, writing_sector, XFT_LBA);
		xft_entry+=XFS_ENTRY_SIZE;
		
		//Escribimos XFS
		writing_sector+=XFS_DirectoryWriter::Write(disk, windows_path, "XFS", false, xft_entry, writing_sector, XFT_LBA);
		xft_entry+=XFS_ENTRY_SIZE;

		delete disk;
	}
	catch(char* error)
	{
		std::cout<<error<<std::endl;
	}
	catch(std::string error)
	{
		std::cout<<error.c_str()<<std::endl;
	}
	catch(...)
	{
		std::cout<<"Unexpected error!"<<std::endl;
	}
	return 0;
}
Ejemplo n.º 15
0
Archivo: Text.cpp Proyecto: lcs2/carpg
//=================================================================================================
bool TextHelper::ToFloat(cstring s, float& result)
{
	__int64 i;
	float f;
	if(ToNumber(s, i, f) != 0)
	{
		result = f;
		return true;
	}
	else
		return false;
}
Ejemplo n.º 16
0
Archivo: Text.cpp Proyecto: lcs2/carpg
//=================================================================================================
bool TextHelper::ToUint(cstring s, uint& result)
{
	__int64 i;
	float f;
	if(ToNumber(s, i, f) != 0 && InRange<uint>(i))
	{
		result = (uint)i;
		return true;
	}
	else
		return false;
}
Ejemplo n.º 17
0
int32_t ToInteger(ejsval exp)
{
    // XXX sorely lacking
    /* 1. Let number be the result of calling ToNumber on the input argument. */
    ejsval number = ToNumber(exp);
    /* 2. If number is NaN, return +0. */
    if (EJSVAL_EQ(number, _ejs_nan))
        return 0;
    /* 3. If number is +0, 0, +, or , return number. */
    double d = ToDouble(number);
    int classified = fpclassify(d);
    if (classified == FP_ZERO || classified == FP_INFINITE)
        return d;
    /* 4. Return the result of computing sign(number)  floor(abs(number) */
    int sign = d < 0 ? -1 : 1;
    return (int)(sign * floor(abs(d)));
}
Ejemplo n.º 18
0
static EJSBool
_ejs_arguments_specop_has_property (ejsval obj, ejsval propertyName)
{
    EJSArguments* arguments = (EJSArguments*)EJSVAL_TO_OBJECT(obj);
    // check if propertyName is an integer, or a string that we can convert to an int
    ejsval idx_val = ToNumber(propertyName);
    int idx;
    if (EJSVAL_IS_NUMBER(idx_val)) {
        double n = EJSVAL_TO_NUMBER(idx_val);
        if (floor(n) == n) {
            idx = (int)n;
            return idx >= 0 && idx < arguments->argc;
        }
    }

    // if we fail there, we fall back to the object impl below
    return _ejs_Object_specops.HasProperty (obj, propertyName);
}
Ejemplo n.º 19
0
ejsval ToNumber(ejsval exp)
{
    if (EJSVAL_IS_NUMBER(exp))
        return exp;
    else if (EJSVAL_IS_BOOLEAN(exp))
        return EJSVAL_TO_BOOLEAN(exp) ? _ejs_one : _ejs_zero;
    else if (EJSVAL_IS_STRING(exp)) {
        char* num_utf8 = ucs2_to_utf8(EJSVAL_TO_FLAT_STRING(exp));
        char *endptr;
        double d = strtod(num_utf8, &endptr);
        if (*endptr != '\0')
            return _ejs_nan;
        ejsval rv = NUMBER_TO_EJSVAL(d); // XXX NaN
        free (num_utf8);
        return rv;
    }
    else if (EJSVAL_IS_UNDEFINED(exp))
        return _ejs_nan;
    else if (EJSVAL_IS_OBJECT(exp)) {
        if (EJSVAL_IS_DATE(exp)) {
            return NUMBER_TO_EJSVAL(_ejs_date_get_time ((EJSDate*)EJSVAL_TO_OBJECT(exp)));
        }
        else if (EJSVAL_IS_ARRAY(exp)) {
            int len = EJS_ARRAY_LEN(exp);
            if (len == 0) return _ejs_zero;
            else if (len > 1) return _ejs_nan;
            else {
                // XXX we need to support sparse arrays here too
                EJS_ASSERT (EJSVAL_IS_DENSE_ARRAY(exp));
                return ToNumber(EJS_DENSE_ARRAY_ELEMENTS(exp)[0]);
            }
        }
        else
            return _ejs_nan;
    }
    else
        EJS_NOT_IMPLEMENTED();
}
Ejemplo n.º 20
0
double ToDouble(ejsval exp)
{
    return EJSVAL_TO_NUMBER(ToNumber(exp));
}