Can anyone explain briefly on what does 'ovm_do_with actually does? - sequence

I'm new to OVM and Saola. Can anyone explain what does
'ovm_do_with(a,{b=0}) actually does?

`uvm_do_with(req, CONSTRAINT)
is a macro. It expands to
req = tx_type::type_id::create("req");
start_item(req);
if( !req.randomize() with CONSTRAINT ) `uvm_error(...)
finish_item(req);
So
'ovm_do_with(a,{b=0})
expands to
a = tx_type::type_id::create("a");
start_item(a);
if( !a.randomize() with {b=0}) `uvm_error(...)
finish_item(a);

Related

Get marked range from NSTextInputContext

I was trying to clean up deprecation warnings of a certain project and the snippet of code looked like:
NSInputManager* im = [NSInputManager currentInputManager];
if (im && [im markedRange].length > 0) return NO;
I got this far:
NSTextInputContext* im = [NSTextInputContext currentInputContext];
if (im && [im /* What goes here? */].length > 0) return NO;
I am trying to get the marked range of the NSTextInputContext. How would I go about doing that?
This should work:
NSTextInputContext* context = [NSTextInputContext currentInputContext];
id<NSTextInputClient> client = context.client;
if (client && client.markedRange.length > 0) return NO;
The client is usually the text view with the focus, so the first responder of the key window. So, you can maybe bypass looking it up this way and just go straight to the text view.

wxBufferedPaintDC GetGraphicsContext return NULL pointer

To get rid of flicker, I use wxBufferedPaintDC in place of wxPaintDC. But there comes a problem. In my paint function, in order to draw a cubic beizer curve I must use GetGraphicsContext to create a path. My question is why GetGraphicsContext returns a NULL pointer when using wxBufferedPaintDC.
void DotGraphView::OnPaint(wxPaintEvent & WXUNUSED(evt))
{
wxBufferedPaintDC dc(this);
PrepareDC(dc);
PaintBackground(dc);
wxGCDC &gdc = (wxGCDC&)dc;
wxGraphicsContext * gc = gdc.GetGraphicsContext(); /* here gc = NULL */
wxGraphicsPath path = gc->CreatePath(); /* program collapses here */
...
}
The cast that you have from wxBufferedPaintDC to wxGCDC looks a little suspicious to me, the wxGraphicsContext pages suggests doing it like this:
wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
if (gc)
{
//drawing code here
delete gc;
}
I feel suspicious too, the suggestion page does not work.
Now I use the following codes and the program run ok.
wxBufferedPaintDC pdc(this);
wxGCDC gdc;
wxGraphicsRenderer * const renderer = wxGraphicsRenderer::GetDefaultRenderer();
wxGraphicsContext * context = renderer->CreateContext(pdc);
gdc.SetGraphicsContext(context);
wxDC & dc = (wxDC &)gdc;
PrepareDC(dc);
Draw(dc);
...
You should use wxAutoBufferedPaintDC.
There is no need to buffer on some platform (like GTK).
Then, you can use the constructor
wxGCDC gcdc(dc);
This works at least on GTK and MSW.

How to redefine FrontEndEventActions?

Good day,
This question comes from the question on aborting evaluation of the full sequence of inputs.
I think it is probably possible to achieve the desired behavior by redefining FrontEndEventActions for two events: "EvaluateCells" (or pressing Shift+Enter) and for pressing Alt+.. It should be something like:
SetOptions[$FrontEndSession,
FrontEndEventActions -> {"EvaluateCells" :> Last$PreRead,
{{"Alt", "."} :> AbortAllNextInputs}}]
or
SetOptions[$FrontEndSession,
FrontEndEventActions -> {{{"ShiftKey", "ReturnKeyDown"} :> Last$PreRead}
{{"Alt", "."} :> AbortAllNextInputs}}]
Where AbortAllNextInputs and Last$PreRead are defined as follows:
AbortAllNextInputs := AbortProtect[
$new$PreRead = True;
last$PreRead = ToString[Definition[$PreRead], InputForm];
ClearAll[$PreRead];
$PreRead := # &] /; ! TrueQ[$new$PreRead]
Last$PreRead :=
$PreRead := AbortProtect[
$new$PreRead = False;
ClearAll[$PreRead];
If[last$PreRead === "Null", #,
ToExpression[last$PreRead]; $PreRead##]
] &
But I can not get FrontEndEventActions working. Can anyone help me?
I believe you need to modify KeyEventTranslations.tr as referenced here and here.

boost::asio and make_shared does not work?

I seem to be able to use boost::make_shared everywhere except with boost asio?
example: _ioService = boost::shared_ptr<io_service>(new io_service)
if I turn this into: _ioService = boost::make_shared<io_service>()
I get all kinds of errors?
Same problem if I take:
_acceptor = boost::shared_ptr<tcp::acceptor>(new tcp::acceptor(*_ioService));
and turn it into this:
_acceptor = boost::make_shared<tcp::acceptor>(*_ioService);
As boost::asio::tcp::acceptor takes a boost::asio::io_service by non-const reference you need to change:
_acceptor = boost::make_shared<tcp::acceptor>(*_ioService);
to:
_acceptor = boost::make_shared<tcp::acceptor>(boost::ref(*_ioService));

How to get an outline view in sublime texteditor?

How do I get an outline view in sublime text editor for Windows?
The minimap is helpful but I miss a traditional outline (a klickable list of all the functions in my code in the order they appear for quick navigation and orientation)
Maybe there is a plugin, addon or similar? It would also be nice if you can shortly name which steps are neccesary to make it work.
There is a duplicate of this question on the sublime text forums.
Hit CTRL+R, or CMD+R for Mac, for the function list. This works in Sublime Text 1.3 or above.
A plugin named Outline is available in package control, try it!
https://packagecontrol.io/packages/Outline
Note: it does not work in multi rows/columns mode.
For multiple rows/columns work use this fork:
https://github.com/vlad-wonderkidstudio/SublimeOutline
I use the fold all action. It will minimize everything to the declaration, I can see all the methods/functions, and then expand the one I'm interested in.
I briefly look at SublimeText 3 api and view.find_by_selector(selector) seems to be able to return a list of regions.
So I guess that a plugin that would display the outline/structure of your file is possible.
A plugin that would display something like this:
Note: the function name display plugin could be used as an inspiration to extract the class/methods names or ClassHierarchy to extract the outline structure
If you want to be able to printout or save the outline the ctr / command + r is not very useful.
One can do a simple find all on the following grep ^[^\n]*function[^{]+{ or some variant of it to suit the language and situation you are working in.
Once you do the find all you can copy and paste the result to a new document and depending on the number of functions should not take long to tidy up.
The answer is far from perfect, particularly for cases when the comments have the word function (or it's equivalent) in them, but I do think it's a helpful answer.
With a very quick edit this is the result I got on what I'm working on now.
PathMaker.prototype.start = PathMaker.prototype.initiate = function(point){};
PathMaker.prototype.path = function(thePath){};
PathMaker.prototype.add = function(point){};
PathMaker.prototype.addPath = function(path){};
PathMaker.prototype.go = function(distance, angle){};
PathMaker.prototype.goE = function(distance, angle){};
PathMaker.prototype.turn = function(angle, distance){};
PathMaker.prototype.continue = function(distance, a){};
PathMaker.prototype.curve = function(angle, radiusX, radiusY){};
PathMaker.prototype.up = PathMaker.prototype.north = function(distance){};
PathMaker.prototype.down = PathMaker.prototype.south = function(distance){};
PathMaker.prototype.east = function(distance){};
PathMaker.prototype.west = function(distance){};
PathMaker.prototype.getAngle = function(point){};
PathMaker.prototype.toBezierPoints = function(PathMakerPoints, toSource){};
PathMaker.prototype.extremities = function(points){};
PathMaker.prototype.bounds = function(path){};
PathMaker.prototype.tangent = function(t, points){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.bezierTangent = function(path, t){};
PathMaker.prototype.splitBezier = function(points, t){};
PathMaker.prototype.arc = function(start, end){};
PathMaker.prototype.getKappa = function(angle, start){};
PathMaker.prototype.circle = function(radius, start, end, x, y, reverse){};
PathMaker.prototype.ellipse = function(radiusX, radiusY, start, end, x, y , reverse/*, anchorPoint, reverse*/ ){};
PathMaker.prototype.rotateArc = function(path /*array*/ , angle){};
PathMaker.prototype.rotatePoint = function(point, origin, r){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.rotate = function(path /*object or array*/ , R){};
PathMaker.prototype.moveTo = function(path /*object or array*/ , x, y){};
PathMaker.prototype.scale = function(path, x, y /* number X scale i.e. 1.2 for 120% */ ){};
PathMaker.prototype.reverse = function(path){};
PathMaker.prototype.pathItemPath = function(pathItem, toSource){};
PathMaker.prototype.merge = function(path){};
PathMaker.prototype.draw = function(item, properties){};