Posts

Featured post

compiler construction - Adding the inreg attribute to LLVM IR function parameters -

i'm working llvm , want recreate piece of ir api: declare void @fun(i32* inreg, i32 inreg) but can't seem it. my current attempt is: function* fun = cast<function>(m.getorinsertfunction("fun",type)); ((fun -> getattributes()).getparamattributes(0)).addattribute(c,0,attribute::inreg); ((fun -> getattributes()).getparamattributes(1)).addattribute(c,0,attribute::inreg); this code literally doesn't after line 1, lines 2 , 3 ignored , in ir output is: declare void @fun(i32* , i32 ) how work correctly? managing function attributes in llvm quite inconvenient attributes packed immutable , global sets. assigning attribute function argument means replacing set representing function , argument attributes new one. fortunately, there @ least helper functions makes job bit easier. suggest using llvm::function::addattribute() method. function* fun = cast<function>(m.getorinsertfunction("fun", type)); fun->addattrib

c++ empty queue initialization isn't empty in Qt creator -

so queue not empty , there random number of elements filled in. reason why program crashes if try push element onto queue. output cerr statements in calculator.cpp : 0 12163576194217602005 calculator.cpp: void calculator::insertzero(){ cerr << input.empty(); cerr << input.size(); //input.push(0.00); } calculator.hpp: #ifndef calculator_h #define calculator_h #include <qstring> #include "widget.h" #include "ui_widget.h" #include <queue> #include <iostream> /* * class holds declarations of calculator. */ using namespace std; class calculator{ private: queue<double> input; queue<double> result; qstring display; public: //numbers void insertzero(); }; #endif // calculator_h widget.h: #ifndef widget_h #define widget_h #include <qwidget> #include <qstring> #include <qpushbutton> #include <qlabel> #i

mongodb - MongoEngine - How to deference a List Field efficiently when converting to json -

class parent(document): name = stringfield() children = listfield(referencefield('child')) class child(document): name = stringfield() parents = listfield(referencefield(parent)) @app.route('/home/') def home(): parents = parent.objects.all() return render_template('home.html', items=parents) i have 2 collections similar above, maintain many many relationship. in template angular, i'm setting javascript variable list of parents so: $scope.items = {{ parents|tojson }}; this results in array of parents who'se chilren array of object ids (references), opposed dereferenced child objects: $scope.items = [{'$oid': '123', 'name': 'foo', 'children': [{'$oid': '456'}]}]; i want angular object contain of dereferenced children. there efficient way this? so far, approach works me, @ o(n^3). i've minimized list comprehensions clarity. multiple obj['_id']

javascript - Starting with AngularJS using a ng-controller directive -

i'm trying make simple exercise doesn't work. think don't call controller variable appropriately. blocked. how can fix code? result page show me: {{dish.name}} {{dish.label}} {{dish.price | currency}} <html lang="en" ng-app="a"> <head>.... </head> <body> <div class="container"> <div class="row row-content" ng-controller="dishdetailcontroller dishdc"> <div class="col-xs-12"> <p>put dish details here</p> <div class="media-body"> <ul class="media-list"> <li class="media" ng-repeat="dish in dishdc.dishes"> <div class="media-left media-middle"> <a href="#"> <img class="media-object img-thumbnail"

winforms - Notification icon transparency issues when dragging -

Image
i have winforms app, major component of icon down in notification area. i've noticed if drag icon (to reorder it, or move to/from list of icons hidden windows) transparent pixels not respected correctly, unlike other icons. this illustrated in animation below; other icons ok when dragged, icon (the red circle) not (excuse animation's compression artefacts). looking @ more closely, icon looks this: looks when dragged: a notifyicon control used, , icon generated dynamically in various colours , different numbers overlaid. in order maintain translucency around edges of icon, png format used (using code sample codeproject ) take bitmap , return icon used notifyicon : private static readonly byte[] _pngiconheader = { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; using (var bmp = new bitmap(image, new size(image.width, image.height))) { byte[] png; using (var ms = new memorystream()) { bmp.save(ms, imageformat.png)

c++ - Assinging pointer to string variable fails -

match give_word( const vector< vector<string> > * source_words, const vector< vector<string> > * target_words, ...) { string synonym1, synonym2; ... // choose synonyms (if available) synonym1=source_words[index][rand()%source_words[index].size()]; synonym2=target_words[index][rand()%target_words[index].size()]; ... i've made technical decision pass vector-in-vector objects pointers because don't want them copied , passed function. it's because vectors hold more 1000 strings. but don't understand why compile error @ 2 lines assignment sign (=) synonym1=source_words[index][rand()%source_words[index].size()]; synonym2=target_words[index][rand()%target_words[index].size()]; it says this: no operator "=" matches these operands synonym1 = source_words[index][rand() % source_words[index].size()]; synonym2 = target_words[index][rand() % target_words[index].size()]; would valid code if used

java - Mock: when() requires an argument which has to be 'a method call on a mock' -

i writing unit tests rest-api , have problems entities creation mocking. don't know how can mock entitymanager. tried example below got error. my controllertest: public class mcontrollertest { private mockmvc mockmvc; @injectmocks a; @injectmocks b b; @injectmocks acontroller acontroller; @injectmocks private aserviceimpl aserviceimpl; @autowired webapplicationcontext webapplicationcontext; @autowired private filterchainproxy springsecurityfilterchain; @autowired @injectmocks private entitymanagerfactory entitymanagerfactory; @before public void setup() { mockitoannotations.initmocks(this); mockmvc = mockmvcbuilders.webappcontextsetup(webapplicationcontext) .addfilter(springsecurityfilterchain) .build(); } @test public void postatest() throws exception { a.setdddd("xxx"); entitymanagerfactory entitym