A Better C++ Vector Wrapper In Rogue
When I wrote my first version of this a few days ago I realized that Rogue's inline C++ support was not adequate for working with template types in C++ - there was no way to obtain the C++ name of a Rogue type for templating purposes.
I added a few additional options for the markers that are embedded in the literal strings of inline native code.
I created a GitHub Gist that shows the Vector Wrapper demo with the new modifications. Check it out!
Here are all the possible markers for inline code:
Marker | Description |
---|---|
$this | Writes a reference to the current object. |
$property_name | Accesses the given property of the current object. |
$local_name | Accesses the given local variable. |
$(var_name) | You can put parens around any of the above. |
$(var_name.type) | Writes the C++ type name of the given Rogue variable. Parens are required here. |
$(var_name.retain) | Accesses the given variable, first increasing its reference count if it's a reference type rather than a primitive or compound. Useful in template classes when you don't know whether a variable is a reference type or not. Rogue uses mark and sweep GC but anything with a non-zero reference count is guaranteed not to be collected - necessary if objects are stored in a C++ data structure that Rogue can't see into. Parens required. |
$(var_name.release) | The corollary to $(name.retain) . |
$($DataType) | Writes the C++ type name of the given template placeholder type. Parens required. |