int main() { { typedef std::vector<bool> T; typedef std::hash<T> H; static_assert((std::is_base_of<std::unary_function<T, std::size_t>, H>::value), ""); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; assert(h(vb) != 0); } #if __cplusplus >= 201103L || defined(_LIBCPP_MSVC) { typedef std::vector<bool, min_allocator<bool>> T; typedef std::hash<T> H; static_assert((std::is_base_of<std::unary_function<T, std::size_t>, H>::value), ""); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; assert(h(vb) != 0); } #endif }
void TargetObject::BuildMesh() { int nverts = 8; int nfaces = 12; Point3 va(-sz,-sz,-sz); Point3 vb( sz, sz, sz); mesh.setNumVerts(nverts); mesh.setNumFaces(nfaces); mesh.setVert(0, Point3( va.x, va.y, va.z)); mesh.setVert(1, Point3( vb.x, va.y, va.z)); mesh.setVert(2, Point3( va.x, vb.y, va.z)); mesh.setVert(3, Point3( vb.x, vb.y, va.z)); mesh.setVert(4, Point3( va.x, va.y, vb.z)); mesh.setVert(5, Point3( vb.x, va.y, vb.z)); mesh.setVert(6, Point3( va.x, vb.y, vb.z)); mesh.setVert(7, Point3( vb.x, vb.y, vb.z)); MakeQuad(&(mesh.faces[ 0]), 0,2,3,1, 1); MakeQuad(&(mesh.faces[ 2]), 2,0,4,6, 2); MakeQuad(&(mesh.faces[ 4]), 3,2,6,7, 4); MakeQuad(&(mesh.faces[ 6]), 1,3,7,5, 8); MakeQuad(&(mesh.faces[ 8]), 0,1,5,4, 16); MakeQuad(&(mesh.faces[10]), 4,5,7,6, 32); mesh.buildNormals(); mesh.EnableEdgeList(1); }
bool get(std::string key, XmlRpc::XmlRpcValue& val) { try { bool v; if (get(key,v)){ XmlRpc::XmlRpcValue vb(v); val = vb; return (val.valid()); } double vd; if (get(key,vd)){ val = vd; return (val.valid()); } int vi; if (get(key,vi)){ val=vi; return (val.valid()); } std::string vs; if (get(key, vs)){ val=vs.c_str(); return (val.valid()); } } catch (...) { return false; } return false; }
int main() { int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; const std::size_t N1 = sizeof(a1)/sizeof(a1[0]); int a2[] = {1, 2, 3, 4, 5}; const std::size_t N2 = sizeof(a2)/sizeof(a2[0]); bool b[N1] = {true, false, false, true, true, false, false, true, false, false, false, true }; std::valarray<int> v1(a1, N1); std::valarray<int> v2(a2, N2); assert(N2 == std::count(b, b+N1, true)); std::valarray<bool> vb(b, N1); v1[vb] &= v2; assert(v1.size() == 16); assert(v1[ 0] == 0); assert(v1[ 1] == 1); assert(v1[ 2] == 2); assert(v1[ 3] == 2); assert(v1[ 4] == 0); assert(v1[ 5] == 5); assert(v1[ 6] == 6); assert(v1[ 7] == 4); assert(v1[ 8] == 8); assert(v1[ 9] == 9); assert(v1[10] == 10); assert(v1[11] == 1); assert(v1[12] == 12); assert(v1[13] == 13); assert(v1[14] == 14); assert(v1[15] == 15); }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- IVertexBuffer* GLGraphicsDevice::createVertexBuffer( LNVertexElemenst* elements, lnU32 vertexCount, const void* data, bool isDynamic ) { LRefPtr<GLVertexBuffer> vb( LN_NEW GLVertexBuffer() ); vb->create( this, elements, vertexCount, data, isDynamic ); vb->addRef(); return vb; }
QVector<QVector3D> SurfaceItem::vertices() const { QSize size = surface()->size(); qreal w = (m_height * size.width()) / size.height(); qreal h = m_height; QVector3D pos = m_pos + m_normal * m_depthOffset; QVector2D center(pos.x(), pos.z()); QVector3D perp = QVector3D::crossProduct(QVector3D(0, 1, 0), m_normal); QVector2D delta = w * QVector2D(perp.x(), perp.z()).normalized() / 2; qreal scale = qMin(1.0, m_time.elapsed() * 0.002); qreal top = m_pos.y() + h * 0.5 * scale; qreal bottom = m_pos.y() - h * 0.5 * scale; QVector2D left = center - delta * scale; QVector2D right = center + delta * scale; QVector3D va(left.x(), top, left.y()); QVector3D vb(right.x(), top, right.y()); QVector3D vc(right.x(), bottom, right.y()); QVector3D vd(left.x(), bottom, left.y()); QVector<QVector3D> result; result << va << vb << vc << vd; return result; }
PointInfo Split( PointInfo &a, PointInfo &b, TLITVERTEX &vec1, TLITVERTEX &vec2, int lineno ) { LineEuqationType l; l.x = b.y-a.y; l.y = a.x-b.x; l.d = -(l.x*b.x+(l.y)*b.y); double cDot = (vec1.x*l.x + vec1.y*l.y); double dDot = (vec2.x*l.x + vec2.y*l.y); double scale = ( - l.d - cDot) / ( dDot - cDot ); v3 va(vec1.x, vec1.y, vec1.z); v3 vb(vec2.x, vec2.y, vec2.z); v3 vc = va + ((vb - va) * (float)scale ); PointInfo d = {vc.x, vc.y, vc.z, -1, lineno}; if( a.onLine == b.onLine && a.onLine >= 0 ) { if( a.onLine == 0 && lineno == 1 ) d.onVtx = 0; else if ( a.onLine == 0 && lineno == 2 ) d.onVtx = 1; else if( a.onLine == 1 && lineno == 0 ) d.onVtx = 0; else if( a.onLine == 1 && lineno == 2 ) d.onVtx = 2; else if( a.onLine == 2 && lineno == 0 ) d.onVtx = 1; else if( a.onLine == 2 && lineno == 1 ) d.onVtx = 2; } return d; }
int agentppSimDeleteTableContents::prepare_set_request(Request* req, int& ind) { int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; Oidx toid; Vbx vb(req->get_value(ind)); if (vb.get_value(toid) != SNMP_CLASS_SUCCESS) return SNMP_ERROR_WRONG_TYPE; MibEntryPtr entry = 0; status = #ifdef _SNMPv3 mib->find_managing_object(mib->get_context(req->get_context()), toid, entry, req); #else mib->find_managing_object(mib->get_default_context(), toid, entry, req); #endif if (status != SNMP_ERROR_SUCCESS) return SNMP_ERROR_WRONG_VALUE; if (entry->type() != AGENTPP_TABLE) return SNMP_ERROR_WRONG_VALUE; return SNMP_ERROR_SUCCESS; }
UINT32 ScriptVirtualButton::internal_InitVirtualButton(MonoString* name) { String nameStr = MonoUtil::monoToString(name); VirtualButton vb(nameStr); return vb.buttonIdentifier; }
// runs the raytrace over all tests and saves the corresponding images int main(int argc, char** argv) { // test that glfw and glew are linked properly uiloop(); message("GLFW and GLEW seem to work\n\n"); // test max_component function vec3f v(1,2,-3); float max_val = max_component(v); message("Result of max_component: %f\n", max_val); // test sum of three vectors vec3f va(1,0,0); vec3f vb(0,4,0); vec3f vc(0,0,2); vec3f vabc = sum_three(va, vb, vc); message("Result of sum_three: %s\n", tostring(vabc).c_str()); // test sum of vectors vector<vec3f> vs = { {3.14,1.5,2.7}, {2.71,8.2,8.2}, {1.61,8.0,3.4}, {1.41,4.2,1.4}, }; vec3f vsum = sum_many(vs); message("Result of sum_many: %s\n", tostring(vsum).c_str()); message("\nThis message indicates a successful build!\n\n"); return 0; }
int Font::write(unsigned int dx, const std::string& text, float r, float g, float b, float a) { FontEntry& e = entries[dx]; if(e.num_vertices) { vertices.erase(vertices.begin()+e.start_dx, vertices.begin()+(e.start_dx+e.num_vertices)); } e.col[0] = r, e.col[1] = g, e.col[2] = b, e.col[3] = a; // Create vertices e.w = 0; e.start_dx = vertices.size(); float x = 0; float y = 0; for(int i = 0; i < text.size(); ++i) { char c = text[i]; stbtt_aligned_quad q; stbtt_GetBakedQuad(cdata, w, h, c-32, &x, &y, &q, 1); CharVertex va(q.x0, q.y1, q.s0, q.t1, e.col); CharVertex vb(q.x1, q.y1, q.s1, q.t1, e.col); CharVertex vc(q.x1, q.y0, q.s1, q.t0, e.col); CharVertex vd(q.x0, q.y0, q.s0, q.t0, e.col); CHAR_TRI(va, vb, vc); CHAR_TRI(va, vc, vd); if(q.x1 > e.w) { e.w = q.x1; } } e.needs_update = true; e.num_vertices = vertices.size() - e.start_dx; flagChanged(); return e.num_vertices; }
/** * A função executa_comando é uma das funções mais importantes pois é ela que vai reagir aos comandos dados pelo utilizador. * A função irá receber a linha de comando separa la em dois, no comando e nos argumentos do comando, e passa los para as funções associadas aos comandos. * @param Tab Tabuleiro do jogo * @param DIM dimensão do tabuleiro * @param linha Recebe uma string que corresponde á linha lida da shell. * @returns torna um inteiro que verifica se foi ou não bem sucedida a função. */ int executa_comando(char *linha,int *DIM,Elem **Tab) { char cmd[1025]; char args[1025]; int nargs=sscanf(linha, "%s %[^\n]", cmd, args); if((strcmp(cmd, "b") == 0 || strcmp(cmd, "p") == 0 || strcmp(cmd, "i") == 0)) return executaJogada(args,cmd,DIM,Tab); if(strcmp(cmd, "cr") == 0 ) return executaCriaJogo(args,DIM,Tab); if(strcmp(cmd,"gr")==0 ) return executaGravaJogo(args,DIM,Tab); if(strcmp(cmd,"?")==0 && nargs==1) return ajuda(); if(strcmp(cmd,"trp")==0 && nargs==1) return trp(Tab,DIM); if(strcmp(cmd,"snd")==0 && nargs==1) return snd(Tab,DIM); if(strcmp(cmd,"pis")==0 && nargs==1) return pis(Tab,DIM); if(strcmp(cmd,"pds")==0 && nargs==1) return pds(Tab,DIM); if(strcmp(cmd,"vb")==0 && nargs==1) return vb(Tab,DIM); if(strcmp(cmd,"vp")==0 && nargs==1) return vp(Tab,DIM); if(strcmp(cmd,"vl")==0 && nargs==1) return vl(Tab,DIM); if(strcmp(cmd,"q")==0) exit(0); return mensagem_de_erro(E_COMMAND); }
void CDEnet_end_listen(struct tcb* tcp) { // TODO vb(2); if (CDE_provenance_mode) { print_listen_prov(tcp); } if (CDE_nw_mode) { char *pidkey = db_read_real_pid_key(currdb, tcp->pid); ull_t id = db_getListenCounterInc(currdb, pidkey); char* prov_pid = getMappedPid(pidkey); // convert this pid to corresponding prov_pid int u_rval = db_getListenResult(netdb, prov_pid, id); // get recorded result // return recorded result struct user_regs_struct regs; long pid = tcp->pid; EXITIF(ptrace(PTRACE_GETREGS, pid, NULL, ®s)<0); SET_RETURN_CODE(®s, u_rval); if (u_rval < 0) { // set errno? TODO } else { db_setListenId(currdb, pidkey, tcp->u_arg[0], id); db_setupAcceptCounter(currdb, pidkey, id); } EXITIF(ptrace(PTRACE_SETREGS, pid, NULL, ®s)<0); free(prov_pid); free(pidkey); } }
int agentppSimDeleteTableContents::commit_set_request(Request* req, int ind) { Oidx toid; Vbx vb(req->get_value(ind)); vb.get_value(toid); MibEntryPtr entry = 0; int status = #ifdef _SNMPv3 mib->find_managing_object(mib->get_context(req->get_context()), toid, entry, req); #else mib->find_managing_object(mib->get_default_context(), toid, entry, req); #endif if (status != SNMP_ERROR_SUCCESS) return SNMP_ERROR_WRONG_VALUE; if (entry->type() != AGENTPP_TABLE) return SNMP_ERROR_WRONG_VALUE; MibTable* table = (MibTable*)entry; entry->start_synch(); table->clear(); entry->end_synch(); return MibLeaf::commit_set_request(req, ind); }
virtual void visit(AstNodeIf* nodep) { VisitBase vb(this, nodep); iterateAndNextNull(nodep->condp()); uint32_t savedCount = m_instrCount; UINFO(8, "ifsp:\n"); m_instrCount = 0; iterateAndNextNull(nodep->ifsp()); uint32_t ifCount = m_instrCount; if (nodep->branchPred() == AstBranchPred::BP_UNLIKELY) ifCount = 0; UINFO(8, "elsesp:\n"); m_instrCount = 0; iterateAndNextNull(nodep->elsesp()); uint32_t elseCount = m_instrCount; if (nodep->branchPred() == AstBranchPred::BP_LIKELY) elseCount = 0; if (ifCount >= elseCount) { m_instrCount = savedCount + ifCount; if (nodep->elsesp()) nodep->elsesp()->user4(0); // Don't dump it } else { m_instrCount = savedCount + elseCount; if (nodep->ifsp()) nodep->ifsp()->user4(0); // Don't dump it } }
virtual void visit(AstNodeCond* nodep) { // Just like if/else above, the ternary operator only evaluates // one of the two expressions, so only count the max. VisitBase vb(this, nodep); iterateAndNextNull(nodep->condp()); uint32_t savedCount = m_instrCount; UINFO(8, "?\n"); m_instrCount = 0; iterateAndNextNull(nodep->expr1p()); uint32_t ifCount = m_instrCount; UINFO(8, ":\n"); m_instrCount = 0; iterateAndNextNull(nodep->expr2p()); uint32_t elseCount = m_instrCount; if (ifCount < elseCount) { m_instrCount = savedCount + elseCount; if (nodep->expr1p()) nodep->expr1p()->user4(0); // Don't dump it } else { m_instrCount = savedCount + ifCount; if (nodep->expr2p()) nodep->expr2p()->user4(0); // Don't dump it } }
vec3 TerrainNoise::getNormal(float x, float y, float eps) const { float ha = getHauteur2(x,y); float g = getHauteur2(x-eps,y), d = getHauteur2(x+eps,y), b = getHauteur2(x,y+eps), h = getHauteur2(x,y-eps); vec3 vg(-eps, 0, g-ha), vd(eps, 0, d-ha), vb(0, eps, b-ha), vh(0, -eps, h-ha); float distg = length(vg), distd = length(vd), distb = length(vb), disth = length(vh); vec3 v1 = cross(vg,vh), v2 = cross(vh,vd), v3 = cross(vd,vb), v4 = cross(vb,vg); v1 = normalize(v1); v2 = normalize(v2); v3 = normalize(v3); v4 = normalize(v4); vec3 normale = v1*distg*disth + v2*disth*distd + v3*distd*distb + v4*distb*distg; return normalize(normale); }
/** * * Points are in world coordinates */ void Gouraud_Shading(face *f, object_copy *obj, vector<light> *lights, camera *camera, int xres, int yres, color **grid, float **depth_grid, MatrixXd *perspective, MatrixXd *inv_cam) { point *a = &(obj->points[f->vertices.index1-1]); color colora = lighting(a, &(obj->normals[f->normals.index1-1]), obj, lights, camera); point *b = &(obj->points[f->vertices.index2-1]); color colorb = lighting(b, &(obj->normals[f->normals.index2-1]), obj, lights, camera); point *c = &(obj->points[f->vertices.index3-1]); color colorc = lighting(c, &(obj->normals[f->normals.index3-1]), obj, lights, camera); point ndca = to_NDC(a, perspective, inv_cam); point ndcb = to_NDC(b, perspective, inv_cam); point ndcc = to_NDC(c, perspective, inv_cam); Vector3d va(ndca.x, ndca.y, ndca.z); Vector3d vb(ndcb.x, ndcb.y, ndcb.z); Vector3d vc(ndcc.x, ndcc.y, ndcc.z); Vector3d cross = (vc - vb).cross(va - vb); // ignore if pointing away from camera or if face is outside NDC box if (cross(2) >= 0 && is_in_box(&ndca) && is_in_box(&ndcb) && is_in_box(&ndcc)) raster_triangle(&ndca, &ndcb, &ndcc, colora, colorb, colorc, xres, yres, grid, depth_grid); }
void Phong_Shading(face *f, object_copy *obj, vector<light> *lights, camera *camera, int xres, int yres, color **grid, float **depth_grid, MatrixXd *perspective, MatrixXd *inv_cam) { // TODO: implement point *a = &(obj->points[f->vertices.index1-1]); point *normal_a = &(obj->normals[f->normals.index1-1]); point *b = &(obj->points[f->vertices.index2-1]); point *normal_b = &(obj->normals[f->normals.index2-1]); point *c = &(obj->points[f->vertices.index3-1]); point *normal_c = &(obj->normals[f->normals.index3-1]); point ndca = to_NDC(a, perspective, inv_cam); point ndcb = to_NDC(b, perspective, inv_cam); point ndcc = to_NDC(c, perspective, inv_cam); Vector3d va(ndca.x, ndca.y, ndca.z); Vector3d vb(ndcb.x, ndcb.y, ndcb.z); Vector3d vc(ndcc.x, ndcc.y, ndcc.z); Vector3d cross = (vc - vb).cross(va - vb); // ignore if pointing away from camera or if face is outside NDC box if (cross(2) >= 0) // && is_in_box(&ndca) && is_in_box(&ndcb) && is_in_box(&ndcc)) raster_triangle_Phong(&ndca, &ndcb, &ndcc, a, b, c, normal_a, normal_b, normal_c, obj, lights, camera, xres, yres, grid, depth_grid, perspective, inv_cam); }
SEXP updateFaceNormals(SEXP vb_, SEXP it_) { try { NumericMatrix vb(vb_); IntegerMatrix it(it_); mat vbA(vb.begin(),vb.nrow(),vb.ncol()); mat normals(it.nrow(), it.ncol()); normals.fill(0.0); imat itA(it.begin(),it.nrow(),it.ncol()); int nit = it.ncol(); colvec tmp0(3), tmp1(3), ntmp(3); for (int i=0; i < nit; ++i) { tmp0 = vbA.col(itA(1,i))-vbA.col(itA(0,i)); tmp1 = vbA.col(itA(2,i))-vbA.col(itA(0,i)); crosspArma(tmp0,tmp1,ntmp); double nlen = norm(ntmp,2); if (nlen > 0) ntmp /= nlen; normals.col(i) = ntmp; } return Rcpp::wrap(normals); } catch (std::exception& e) { ::Rf_error( e.what()); } catch (...) { ::Rf_error("unknown exception"); } }
List polyData2R(vtkSmartPointer<vtkPolyData> polydata) { try { //vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); //poltOutput(); int np = polydata->GetNumberOfPoints(); vtkPoints* points=polydata->GetPoints(); NumericMatrix vb(3,np); double point[3]; for (int i=0; i< np;i++) { polydata->GetPoints()->GetPoint(i,point); for (int j=0; j<3; j++) vb(j,i) = point[j]; } //points->Delete(); int h; vtkIdType npts=3,*pts; int nit = polydata->GetNumberOfPolys(); std::vector<int> it; vtkSmartPointer<vtkCellArray> oCellArr= vtkSmartPointer<vtkCellArray>::New(); polydata->GetPolys()->InitTraversal(); while(polydata->GetPolys()->GetNextCell(npts,pts)) { //for (int i=0; i< nit;i++) { // h = oCellArr->GetNextCell(npts,pts); //if(h == 0){ // break; //} if(npts == 3){ it.push_back(pts[0]+1); it.push_back(pts[1]+1); it.push_back(pts[2]+1); } } int ll = it.size()/3; IntegerMatrix itout(3,ll,it.begin()); List out = List::create(Named("vb")=vb, Named("it")=itout ); if (it.size() > 0) out.attr("class") = "mesh3d"; return out; } catch(...) { ::Rf_error("PolyData to R-Data conversion failed"); return List::create(Named("error")=1); } }
void CDEnet_end_send(struct tcb* tcp) { int sockfd = tcp->u_arg[0]; if (CDE_provenance_mode && CDE_network_content_mode && isProvCapturedSock(sockfd)) { vb(2); if (socket_data_handle(tcp, SOCK_SEND) < 0) { // TODO } } if (CDE_nw_mode && db_isCapturedSock(currdb, sockfd)) { vb(2); if (CDE_verbose_mode >= 3) { char buff[KEYLEN]; size_t buflength = tcp->u_arg[2]; if (umoven(tcp, tcp->u_arg[1], buflength, buff) < 0) { return; } buff[tcp->u_arg[2]] = '\0'; vbp(3, "action %d [%ld] checksum %u ", SOCK_SEND, tcp->u_arg[2], checksum(buff, buflength)); if (CDE_verbose_mode >= 3) printbuf(buff, buflength); } long pid = tcp->pid; char *pidkey, *sockid; db_get_pid_sock(currdb, pid, sockfd, &pidkey, &sockid); if (pidkey == NULL || sockid == NULL) { vbp(0, "error"); return; } ull_t sendid = db_getPkgCounterInc(currdb, pidkey, sockid, SOCK_SEND); char* prov_pid = getMappedPid(pidkey); // convert this pid to corresponding prov_pid ull_t u_rval; db_getSendRecvResult(netdb, SOCK_SEND, prov_pid, sockid, sendid, &u_rval, NULL); // get recorded result struct user_regs_struct regs; EXITIF(ptrace(PTRACE_GETREGS, pid, NULL, ®s)<0); SET_RETURN_CODE(®s, u_rval); if (u_rval < 0) { // set errno? TODO } EXITIF(ptrace(PTRACE_SETREGS, pid, NULL, ®s)<0); free(prov_pid); free(sockid); free(pidkey); } }
trapapp::trapapp(int argc, char *argv[]): valid_(0) { Oid def_ent_oid("1.3.6.1.2.1.1.1.2.0.1"); // def enterprise oid Oid ent, trap; // user specified values if ( argc < 2) // hostname mandatory return; address_ = argv[argc - 1]; if ( !address_.valid()) { cout << "ERROR: Invalid IPv4 address or DNS hostname: " \ << argv[argc] << "\n"; return; } ACE_Argv_Type_Converter to_tchar (argc, argv); ACE_Get_Opt get_opt (argc, to_tchar.get_TCHAR_argv (), ACE_TEXT ("c:e:t:")); for (int c; (c = get_opt ()) != -1; ) switch (c) { case 'c': // community string community_ = ACE_TEXT_ALWAYS_CHAR (get_opt.opt_arg()); target_.set_read_community(community_); break; case 'e': // trap oid to send ent = ACE_TEXT_ALWAYS_CHAR (get_opt.opt_arg()); break; case 't': // trap oid trap = ACE_TEXT_ALWAYS_CHAR (get_opt.opt_arg()); break;; default: break; } if (ent.valid()) pdu_.set_notify_enterprise( ent); // set up the enterprise of the trap else pdu_.set_notify_enterprise( def_ent_oid); if (trap.valid()) pdu_.set_notify_id( trap); // set the id of the trap else pdu_.set_notify_id( coldStart); // set the id of the trap Oid detail_oid("1.3.6.1.4.1.11.2.16.2"); OctetStr detail_value("SNMP++ Trap Send Test"); Vb vb(detail_oid, detail_value); pdu_ += vb; pdu_.get_notify_id(oid_); // store for later use valid_ = 1; }
virtual void visit(AstCCall* nodep) { VisitBase vb(this, nodep); iterateChildren(nodep); m_tracingCall = true; iterate(nodep->funcp()); if (m_tracingCall) { nodep->v3fatalSrc("visit(AstCFunc) should have cleared m_tracingCall."); } }
// int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); // Return accepted socket fd and fill addr, addrlen // On error, -1 is returned, and errno is set appropriately. void CDEnet_begin_accept(struct tcb* tcp) { // TODO // ignore! No value is set up yet (ip, port, etc.) // we only care of the return of accept // which is handled in accept_exit vb(2); if (CDE_nw_mode) { denySyscall(tcp->pid); } }
virtual void visit(AstSel* nodep) { // Similar to AstNodeSel above, a small select into a large vector // is not expensive. Count the cost of the AstSel itself (scales with // its width) and the cost of the lsbp() and widthp() nodes, but not // the fromp() node which could be disproportionately large. VisitBase vb(this, nodep); iterateAndNextNull(nodep->lsbp()); iterateAndNextNull(nodep->widthp()); }
bool Model::EndLoad() { Vector<SharedPtr<VertexBuffer> > vbs; for (size_t i = 0; i < vbDescs.Size(); ++i) { const VertexBufferDesc& vbDesc = vbDescs[i]; SharedPtr<VertexBuffer> vb(new VertexBuffer()); vb->Define(USAGE_IMMUTABLE, vbDesc.numVertices, vbDesc.vertexElements, true, vbDesc.vertexData.Get()); vbs.Push(vb); } Vector<SharedPtr<IndexBuffer> > ibs; for (size_t i = 0; i < ibDescs.Size(); ++i) { const IndexBufferDesc& ibDesc = ibDescs[i]; SharedPtr<IndexBuffer> ib(new IndexBuffer()); ib->Define(USAGE_IMMUTABLE, ibDesc.numIndices, ibDesc.indexSize, true, ibDesc.indexData.Get()); ibs.Push(ib); } // Set the buffers to each geometry geometries.Resize(geomDescs.Size()); for (size_t i = 0; i < geomDescs.Size(); ++i) { geometries[i].Resize(geomDescs[i].Size()); for (size_t j = 0; j < geomDescs[i].Size(); ++j) { const GeometryDesc& geomDesc = geomDescs[i][j]; SharedPtr<Geometry> geom(new Geometry()); geom->lodDistance = geomDesc.lodDistance; geom->primitiveType = geomDesc.primitiveType; geom->drawStart = geomDesc.drawStart; geom->drawCount = geomDesc.drawCount; if (geomDesc.vbRef < vbs.Size()) geom->vertexBuffer = vbs[geomDesc.vbRef]; else LOGERROR("Out of range vertex buffer reference in " + Name()); if (geomDesc.ibRef < ibs.Size()) geom->indexBuffer = ibs[geomDesc.ibRef]; else LOGERROR("Out of range index buffer reference in " + Name()); geometries[i][j] = geom; } } vbDescs.Clear(); ibDescs.Clear(); geomDescs.Clear(); return true; }
// int close(int fd); void CDEnet_close(struct tcb* tcp) { int sockfd = tcp->u_arg[0]; vb(2); if (CDE_provenance_mode) { print_fd_close(tcp); } if (CDE_nw_mode && db_isCapturedSock(currdb, sockfd)) { db_remove_sock(currdb, tcp->pid, sockfd); } }
void foo() { std::vector<bool> vb(30); //std::fill(vb.begin(), vb.end(), true); assert( std::none_of(vb.begin(), vb.end(), [](bool b){return b;}) ); vb[3] = true; assert( ! std::none_of(vb.begin(), vb.end(), [](bool b){return b;}) ); assert( std::any_of(vb.begin(), vb.end(), [](bool b){return b;}) ); assert( ! std::all_of(vb.begin(), vb.end(), [](bool b){return b;}) ); std::fill(vb.begin(), vb.end(), true); assert( std::all_of(vb.begin(), vb.end(), [](bool b){return b;}) ); }
// VISITORS virtual void visit(AstNodeSel* nodep) { // This covers both AstArraySel and AstWordSel // // If some vector is a bazillion dwords long, and we're selecting 1 // dword to read or write from it, our cost should be small. // // Hence, exclude the child of the AstWordSel from the computation, // whose cost scales with the size of the entire (maybe large) vector. VisitBase vb(this, nodep); iterateAndNextNull(nodep->bitp()); }