Ejemplo n.º 1
0
		inline const unsigned char* string::data()
		{
			return ASN1_STRING_data(ptr().get());
		}
Ejemplo n.º 2
0
 bool isIdentity() const
 {
     mat2 i = I();
     return memcmp( ptr(), i.ptr(), sizeof(GLfloat)*4 ) == 0;
 }
Ejemplo n.º 3
0
Worker::ptr Worker::create(boost::asio::io_service& io_srv, boost::asio::ip::address_v4 ip)
{
	return ptr(new Worker(io_srv, ip));
}
Ejemplo n.º 4
0
wxPieChartData::ptr wxPieChartData::make_shared()
{
    return ptr(new wxPieChartData());
}
Ejemplo n.º 5
0
void CTrustSession::DispatchMessageL(const RMessage2& aMessage)
	{
	
	switch(aMessage.Function())
		{
		case EAddTrust:
			{
				TCertInfo certInfo;
				TPckg<TCertInfo> certInfoPckg(certInfo);
				aMessage.ReadL(1,certInfoPckg);
				TInt err = Server().AddSessionTrustL(certInfo);
				TPckg<TInt> result(err);
				aMessage.WriteL(0,result);
			}
			break;
		
		case EGetElementList:
			{
				RElementIdArray array;
				CleanupClosePushL( array);
				TElementType type = EPolicySets;
				
				TPckgBuf<TInt> EleTypePkg(type);
				aMessage.ReadL(1,EleTypePkg);
				type =(TElementType) EleTypePkg();
				
				TInt err = Server().GetElementListL(type,array);
				
				TPckgBuf<TInt> result(err);
			
				TInt count = array.Count();
				
				aMessage.WriteL(0,result);
				CleanupStack::PopAndDestroy();
			}
			break;
			
		case EGetElement:
			{
			    HBufC8* buffer = HBufC8::NewLC( 300 );
			    TPtr8 ptr( buffer->Des() );
			    aMessage.ReadL( 0, ptr );	
			  	TElementInfo elementInfo(ptr);
			  	TPtrC8 ptrNullDes = elementInfo.GetDescription();  //just to get the code coverage
				User::LeaveIfError( Server().GetElementL(elementInfo));
				
				TPtrC8 ptrDes = elementInfo.GetDescription();
				TPtrC8 ptrID = elementInfo.GetElementId();
							
				for ( TInt i = 0; i < elementInfo.GetChildElementArray().Count(); i++)
				{
				    RDEBUG_2("CTrustSession::DispatchMessageL Child element ids %S", elementInfo.GetChildElementArray()[i]);
				}
				CleanupStack::PopAndDestroy(buffer);
			}
			break;
			
		case EGetXACMLDescription:
			{
				HBufC8* buffer = HBufC8::NewLC( 300 );
			    TPtr8 ptr( buffer->Des() );
			    aMessage.ReadL( 0, ptr );	
			  	TElementInfo elementInfo(ptr);
			  	TPtrC8 ptrNullXACML(elementInfo.GetXACML());  //just to get the code coverage
				User::LeaveIfError( Server().GetXACMLDescriptionL(elementInfo));
				
				TPtrC8 ptrXACML(elementInfo.GetXACML());
//				RDEBUG_2("CTrustSession::DispatchMessageLGetXACML %S", ptrXACML);
				
				CleanupStack::PopAndDestroy(buffer);
			}
			break;
   	
		default:
			break;
		}
	}
Ejemplo n.º 6
0
void Item_group::add_item_entry(const Item_tag &itemid, int probability)
{
    std::unique_ptr<Item_spawn_data> ptr(new Single_item_creator(itemid, Single_item_creator::S_ITEM, probability));
    add_entry(ptr);
}
Ejemplo n.º 7
0
int Game::loadGamestate(const XMLReader& reader, const sf::String& GSname, const SFG::Pointer<GameState>& included)
{
    SFG::Pointer<GameState> GS_ptr;

    sf::String GSxmlpath = L"xml/gamestate[" + GSname + L"]";
    auto str = reader.getValue(GSxmlpath, 0);

    if (str == L"__xml_failure")
    {
        printf("[Error] Unspecified startup gamestate in %s:%d.\n", __FILE__, __LINE__);
        return -2;
    }
    else
    {

        if (str == L"#included")
        {
            //Use default
            GS_ptr.reset(included);
            if (!GS_ptr.isValid() && included.getElement() != nullptr)
            {
                printf("[Critical] Failed to allocate memory for \"%s\" in %s:%d\n",GSname.toAnsiString().c_str(), __FILE__, __LINE__);
                return -1;
            }

        }
        else
        {
            //Use specified
            //#TODO
            STILL_TO_DO(__FILE__, __LINE__);
            //We first need an instance of a DLLLoadedGameState
            GS_ptr.reset(new DLLLoadedGameState());
            //Set the name
            GS_ptr->setName(GSname);
            if (GS_ptr->getName() == "__xml_failure")
            {
                SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to get Gamestate name, aborting.");
                return -1;
            }
            //Then, load the specified file
            if (GS_ptr.cast<DLLLoadedGameState>()->loadFromDll(str.toAnsiString().c_str()) != 0)
            {
                SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__,
									"Failed to load gamestate \"%s\" from DLL", str.toAnsiString().c_str());
                return -2;
            }

            //We actually should be done


        }

        //Get all modules
        sf::String uses = reader.getValue(GSxmlpath + L"uses.");
        if (uses != L"__xml_failure")
        {
            //We have specifiers
            size_t begin = 0;
            size_t last = 0;
            //Begin needs to be checked as the last module wouldn't be counted otherwise
            while ((last = uses.find(L',', last)) != sf::String::InvalidPos || begin != sf::String::InvalidPos)
            {
                sf::String string;
                if (last == sf::String::InvalidPos)
                {
                    //If the end would otherwise exceed the string length, set it to the maximum (sf::String::end()).
                    //string = sf::String(uses.begin() + begin, uses.end());
                    string = uses.substring(begin, uses.getSize() - begin);
                }
                else
                {
                    //If a ',' was found, use its position
                    //string = sf::String(uses.begin() + begin, uses.begin() + last);
                    string = uses.substring(begin, last - begin);
                }
                //Check for module names
                if (string == L"G2D")
                {
                    SFG::Pointer<ModuleG2D> ptr(new ModuleG2D());
                    if (!ptr.isValid())
                    {
                        char buf[512];
#ifdef _WIN32
                        strerror_s(buf, errno);
#else
                        strerror_r(errno, buf, 512);
#endif // _WIN32
                        printf("[Error] Failed to create Module G2D in %s:%d: %s\n", __FILE__, __LINE__, buf);
                        return -3;
                    }
                    GS_ptr->addModule(ptr);
                }
                else
                {
                    //#TODO: Add more modules (sound etc.)
                    STILL_TO_DO(__FILE__, __LINE__);
                }
                if(last != sf::String::InvalidPos) begin = last + 1; //if a ',' was found, go search on for the next one
                else begin = last; //Meaning begin is sf::String::npos
            }
        }

        //Check for external asset list
        auto ext_assets = reader.getValue(GSxmlpath + "assets.");
        if (ext_assets != "__xml_failure")
        {
            //We found external assets, load them
        }
        auto assets = reader.getXMLGroupHandle(L"xml/assetlist[" + GSname + L"]");
        if (assets == nullptr)
        {
            printf("[Warning] No assets for Gamestate \"%s\" found. This is not encouraged and might be an error. Please check the game.xml file. In: %s:%d\n", GSname.toAnsiString().c_str(), __FILE__, __LINE__);
            //return 1;
        }
        else
        {
            auto ret = GS_ptr->loadAssets(XMLReader(*assets));
            if (ret != 0)
            {
                printf("[Error] Failed to load assets for Gamestate \"%s\" in %s:%d.\n", GSname.toAnsiString().c_str(), __FILE__, __LINE__);
            }
        }

        //Empty path to tell the gamestate to just update what it has (or do nothing if nothing has to be done)
        GS_ptr->load(L"");

        //this->g_gamestates.push_back(GS_ptr);
        this->addGamestate(GS_ptr);
    }
    return 0;
}
Ejemplo n.º 8
0
int main(int argc, char* argv[]) {
    using Test = venum::Enum
        ::Variant<std::string>
        ::Variant<int>
        ::Variant<Thing>;

    std::vector<Test> v;
    v.emplace_back(7);
    v.emplace_back("Hello");
    v.emplace_back(5);
	v.emplace_back(5, 'a');

    for(auto& t : v) {
        t.match(
            [](std::string& s) { std::cout << "string: " << s << std::endl; },
            [](int& i) { std::cout << "int: " << i << std::endl; },
            [](Thing& t) { std::cout << "thing: " << t.i << ", " << t.c << std::endl; }
        );

        std::cout << std::endl;
    }

    venum::Enum::Variant<int>::Variant<std::string>(7).apply([](auto a) { std::cout << a << std::endl; });

    using Test2 = venum::Enum::Variant<int*>::Variant<int>::Variant<char>;

    int z = 67;

    Test2 a(5);
    Test2 b('c');
    Test2 ptr(&z);
    auto c = Test2::construct<char>(47);

    a.match(
        [](int* i) { std::cout << "int* " << *i << std::endl; },
        [](int& i) { std::cout << "int: " << i << std::endl; },
        [](char& c) { std::cout << "char: " << c << std::endl; }
    );

    b.match(
        [](int* i) { std::cout << "int* " << *i << std::endl; },
        [](int& i) { std::cout << "int: " << i << std::endl; },
        [](char& c) { std::cout << "char: " << c << std::endl; }
    );

    ptr.match(
        [](int* i) { std::cout << "int* " << *i << std::endl; },
        [](int& i) { std::cout << "int: " << i << std::endl; },
        [](char& c) { std::cout << "char: " << c << std::endl; }
    );

    std::string s2 = a.match(
        [](int* i) { std::ostringstream str; str << "int*: " << i; return str.str(); },
        [](int i) { std::ostringstream str; str << "int: " << i; return str.str(); },
        [](char c) { std::ostringstream str; str << "char: " << c; return str.str(); }
    );

    c.match(
        [](int* i) { std::cout << "int* " << *i << std::endl; },
        [](int& i) { std::cout << "int: " << i << std::endl; },
        [](char& c) { std::cout << "char: " << c << std::endl; }
    );

    std::cout << c.which() << " " << c.contains<char>() << " " << c.contains<int>() << std::endl;

    try {
        std::cout << "not a real int: " << c.get<int>() << std::endl;
    } catch(std::exception& e) {
        std::cout << e.what() << std::endl;
    }

    std::cout << "not a real int: " << c.get_unchecked<int>() << std::endl;

    // Optional Test
    auto o = Optional<int>::Some(6);
    if(o) {
        std::cout << o.get() << std::endl;
    }

    try {
        Optional<std::string>::None().get();
    } catch(std::exception& e) {
        std::cout << e.what() << std::endl;
    }

    std::string s = o.map([](int i) { return std::to_string(i); }).match(
        [](None) { return std::string(""); },
        [](std::string s) { return s; }
    );
    std::cout << "result: " << s << std::endl;

    o.and_then([](int i) { return Optional<float>::None(); });

    std::cout << std::endl;

    // Tree Test
    Tree<int> tree;
    tree.insert(5);
    tree.insert(2);
    tree.insert(7);
    tree.insert(3);
    tree.insert(19);
    tree.apply([](int i) { std::cout << i << std::endl; });

    std::cout << tree.contains(19) << std::endl;
    std::cout << tree.contains(8) << std::endl;

    []() {}();
}
Ejemplo n.º 9
0
 CppObject *       operator->()       { return ptr(); }
Ejemplo n.º 10
0
static jl_value_t *scm_to_julia_(value_t e, int eo)
{
    if (fl_isnumber(e)) {
        int64_t i64;
        if (isfixnum(e)) {
            i64 = numval(e);
        }
        else {
            assert(iscprim(e));
            cprim_t *cp = (cprim_t*)ptr(e);
            numerictype_t nt = cp_numtype(cp);
            switch (nt) {
            case T_DOUBLE:
                return (jl_value_t*)jl_box_float64(*(double*)cp_data(cp));
            case T_FLOAT:
                return (jl_value_t*)jl_box_float32(*(float*)cp_data(cp));
            case T_UINT8:
                return (jl_value_t*)jl_box_uint8(*(uint8_t*)cp_data(cp));
            case T_UINT16:
                return (jl_value_t*)jl_box_uint16(*(uint16_t*)cp_data(cp));
            case T_UINT32:
                return (jl_value_t*)jl_box_uint32(*(uint32_t*)cp_data(cp));
            case T_UINT64:
                return (jl_value_t*)jl_box_uint64(*(uint64_t*)cp_data(cp));
            default:
                ;
            }
            i64 = conv_to_int64(cp_data(cp), nt);
        }
        if (
#ifdef _P64
            jl_compileropts.int_literals==32
#else
            jl_compileropts.int_literals!=64
#endif
            ) {
            if (i64 > (int64_t)S32_MAX || i64 < (int64_t)S32_MIN)
                return (jl_value_t*)jl_box_int64(i64);
            return (jl_value_t*)jl_box_int32((int32_t)i64);
        }
        else {
            return (jl_value_t*)jl_box_int64(i64);
        }
    }
    if (issymbol(e)) {
        if (e == true_sym)
            return jl_true;
        else if (e == false_sym)
            return jl_false;
        return (jl_value_t*)scmsym_to_julia(e);
    }
    if (fl_isstring(e)) {
        return jl_pchar_to_string((char*)cvalue_data(e), cvalue_len(e));
    }
    if (e == FL_F) {
        return jl_false;
    }
    if (e == FL_T) {
        return jl_true;
    }
    if (e == FL_NIL) {
        return (jl_value_t*)jl_null;
    }
    if (iscons(e)) {
        value_t hd = car_(e);
        if (issymbol(hd)) {
            jl_sym_t *sym = scmsym_to_julia(hd);
            /* tree node types:
               goto  gotoifnot  label  return
               lambda  call  =  quote
               null  top  method
               body  file new
               line  enter  leave
            */
            size_t n = llength(e)-1;
            size_t i;
            if (sym == null_sym && n == 0)
                return jl_nothing;
            if (sym == lambda_sym) {
                jl_expr_t *ex = jl_exprn(lambda_sym, n);
                e = cdr_(e);
                value_t largs = car_(e);
                jl_cellset(ex->args, 0, full_list(largs,eo));
                e = cdr_(e);
                
                value_t ee = car_(e);
                jl_array_t *vinf = jl_alloc_cell_1d(3);
                jl_cellset(vinf, 0, full_list(car_(ee),eo));
                ee = cdr_(ee);
                jl_cellset(vinf, 1, full_list_of_lists(car_(ee),eo));
                ee = cdr_(ee);
                jl_cellset(vinf, 2, full_list_of_lists(car_(ee),eo));
                assert(!iscons(cdr_(ee)));
                jl_cellset(ex->args, 1, vinf);
                e = cdr_(e);
                
                for(i=2; i < n; i++) {
                    assert(iscons(e));
                    jl_cellset(ex->args, i, scm_to_julia_(car_(e), eo));
                    e = cdr_(e);
                }
                return
                    (jl_value_t*)jl_new_lambda_info((jl_value_t*)ex, jl_null);
            }

            e = cdr_(e);
            if (!eo) {
                if (sym == line_sym && n==1) {
                    return jl_new_struct(jl_linenumbernode_type,
                                         scm_to_julia_(car_(e),0));
                }
                if (sym == label_sym) {
                    return jl_new_struct(jl_labelnode_type,
                                         scm_to_julia_(car_(e),0));
                }
                if (sym == goto_sym) {
                    return jl_new_struct(jl_gotonode_type,
                                         scm_to_julia_(car_(e),0));
                }
                if (sym == quote_sym) {
                    return jl_new_struct(jl_quotenode_type,
                                         scm_to_julia_(car_(e),0));
                }
                if (sym == top_sym) {
                    return jl_new_struct(jl_topnode_type,
                                         scm_to_julia_(car_(e),0));
                }
                if (sym == newvar_sym) {
                    return jl_new_struct(jl_newvarnode_type,
                                         scm_to_julia_(car_(e),0));
                }
            }
            jl_expr_t *ex = jl_exprn(sym, n);
            // allocate a fresh args array for empty exprs passed to macros
            if (eo && n == 0)
                ex->args = jl_alloc_cell_1d(0);
            for(i=0; i < n; i++) {
                assert(iscons(e));
                jl_cellset(ex->args, i, scm_to_julia_(car_(e),eo));
                e = cdr_(e);
            }
            return (jl_value_t*)ex;
        }
        else {
            jl_error("malformed tree");
        }
    }
    if (iscprim(e) && cp_class((cprim_t*)ptr(e))==wchartype) {
        jl_value_t *wc =
            jl_box32(jl_char_type, *(int32_t*)cp_data((cprim_t*)ptr(e)));
        return wc;
    }
    if (iscvalue(e) && cv_class((cvalue_t*)ptr(e)) == jvtype) {
        return *(jl_value_t**)cv_data((cvalue_t*)ptr(e));
    }
    jl_error("malformed tree");
    
    return (jl_value_t*)jl_null;
}
Ejemplo n.º 11
0
value_t fl_current_julia_module(value_t *args, uint32_t nargs)
{
    value_t opaque = cvalue(jvtype, sizeof(void*));
    *(jl_value_t**)cv_data((cvalue_t*)ptr(opaque)) = (jl_value_t*)jl_current_module;
    return opaque;
}
Ejemplo n.º 12
0
		inline int string::type()
		{
			return ASN1_STRING_type(ptr().get());
		}
Ejemplo n.º 13
0
		inline void string::set_data(const char* _data)
		{
			error::throw_error_if_not(ASN1_STRING_set(ptr().get(), _data, -1) != 0);
		}
Ejemplo n.º 14
0
		inline void string::set_data(const void* _data, size_t data_len)
		{
			error::throw_error_if_not(ASN1_STRING_set(ptr().get(), _data, static_cast<int>(data_len)) != 0);
		}
Ejemplo n.º 15
0
void CSourcePython::OnEdictFreed( const edict_t *edict )
{
	CALL_LISTENERS(OnEdictFreed, ptr(edict));
}
Ejemplo n.º 16
0
 const CppObject * operator->() const { return ptr(); }
Ejemplo n.º 17
0
void CSourcePython::OnEntityDeleted( CBaseEntity *pEntity )
{
	CALL_LISTENERS(OnEntityDeleted, ptr((CBaseEntityWrapper*) pEntity));
}
Ejemplo n.º 18
0
void Texture::set_pixel(const int32_t x, const int32_t y, const D3DXCOLOR& col)
{
  const int32_t safe_x = clamp(x, 0, _width-1);
  const int32_t safe_y = clamp(y, 0, _height-1);
  *ptr(safe_x, safe_y) = col;
}
Ejemplo n.º 19
0
void Item_group::add_group_entry(const Group_tag &groupid, int probability)
{
    std::unique_ptr<Item_spawn_data> ptr(new Single_item_creator(groupid, Single_item_creator::S_ITEM_GROUP, probability));
    add_entry(ptr);
}
Ejemplo n.º 20
0
Archivo: free.c Proyecto: Bekenn/clang
void t5 () {
  extern char *ptr();
  free(ptr()); // no-warning
}
Ejemplo n.º 21
0
// -----------------------------------------------------------------------------
// CSdpOriginField::InternalizeL
// Internalizes from stream
// -----------------------------------------------------------------------------
//	
CSdpOriginField* CSdpOriginField::InternalizeL(
    RReadStream& aStream )
    {    
    RStringPool pool = SdpCodecStringPool::StringPoolL();

    // <username>        
    TUint32 length = aStream.ReadUint32L();
	HBufC8* userName = HBufC8::NewLC( length );
    TPtr8 ptr( userName->Des() );  
    aStream.ReadL( ptr, length );    

    // <session id>
    length = aStream.ReadUint32L();
	HBufC8* sessionId = HBufC8::NewLC( length );
    ptr.Set( sessionId->Des() );
    aStream.ReadL( ptr, length );

    // <version>
    length = aStream.ReadUint32L();
	HBufC8* version = HBufC8::NewLC( length );
    ptr.Set( version->Des() );
    aStream.ReadL( ptr, length );

    // <network type>
    length = aStream.ReadUint32L();
    HBufC8* netType = HBufC8::NewLC( length );
    ptr.Set( netType->Des() );
    aStream.ReadL( ptr, length );

    // <address type>
    length = aStream.ReadUint32L();
    HBufC8* addrType = HBufC8::NewLC( length );
    ptr.Set( addrType->Des() );
    aStream.ReadL( ptr, length );

    // <address>        
    length = aStream.ReadUint32L();
    HBufC8* address = HBufC8::NewLC( length );
    TPtr8 ptr2( address->Des() );
    aStream.ReadL( ptr2, length );
            
    RStringF netTypeStr = pool.OpenFStringL( *netType );
    RStringF addrTypeStr = pool.OpenFStringL( *addrType );
    CleanupClosePushL( netTypeStr );
    CleanupClosePushL( addrTypeStr );

	CSdpOriginField* obj = CSdpOriginField::NewLC( *userName, KDummyValue,
												   KDummyValue, netTypeStr,
												   addrTypeStr, *address );
	// Set the real values
	obj->OriginFieldPtrs().SetSessionIdL( *sessionId );
	obj->OriginFieldPtrs().SetSessionVersionL( *version );
	CleanupStack::Pop( obj );
    CleanupStack::Pop( 2 ); // addrTypeStr, netTypeStr
    CleanupStack::PopAndDestroy( address );
    CleanupStack::PopAndDestroy( addrType );
    CleanupStack::PopAndDestroy( netType );
    CleanupStack::PopAndDestroy( version );
    CleanupStack::PopAndDestroy( sessionId );
    CleanupStack::PopAndDestroy( userName );    

    return obj;
    }
Ejemplo n.º 22
0
void
inline_through_me (void (*ptr)(void))
{
  ptr();
}
Ejemplo n.º 23
0
 operator CUdeviceptr()
 { return ptr(); }
Ejemplo n.º 24
0
// just a sanity test, the same behavior as t1()
char t2 () {
  *ptr() = 'c';
  return '0';
}
 SmartArray<T> reverse() const { SmartArray<T> res(size()); T* dst = res.ptr(); const T* end = ptr(); const T* cursor = end + size() - 1; while(cursor >= end) *dst++ = *cursor--; return res; }
Ejemplo n.º 26
0
char t4 () {
  char* p = ptr();
  *p = 'c'; // no-warning
  if (*p) return *p;
  return *(char*)0; // no-warning
}
Ejemplo n.º 27
0
std::shared_ptr<dt::NetworkEvent> CustomNetworkEvent::Clone() const {
    std::shared_ptr<dt::NetworkEvent> ptr(new CustomNetworkEvent(mData, mEnum));
    return ptr;
}
Ejemplo n.º 28
0
//-----------------------------------------------------------------------------
// Purpose: called on
//-----------------------------------------------------------------------------
void CSourcePython::ClientPutInServer( edict_t *pEntity, char const *playername )
{
	CALL_LISTENERS(OnClientPutInServer, ptr(pEntity), playername);
}
Ejemplo n.º 29
0
EXPORT_C TInt RLbsNetworkLocationRequests::SetNetworkLocationRequest(const TLbsNetLocMsgBase& aMessage)
{
    __ASSERT_DEBUG(iNetLocRequestProperty.Handle() != NULL, User::Invariant());
    TPtrC8 ptr(reinterpret_cast<const TUint8*>(&aMessage), aMessage.Size());
    return (iNetLocRequestProperty.Set(ptr));
}
Ejemplo n.º 30
0
		inline size_t string::size()
		{
			return ASN1_STRING_length(ptr().get());
		}