What does the two colons before the toString() method invocation mean?
For instance, I found the following code:
orderXml.ns::['status'].toString();
Is it the same as ['status'].toString().call(orderXml.ns);?
I am using the Demandware Script above.
Thank you.
In Demandware Script you'll find that a long-deprecated concept called E4X which extends the JavaScript 1.6/ES3 syntax still exists. However, it's usage is now discouraged. You can find some documentation for this syntax here: https://developer.mozilla.org/en-US/docs/Archive/Web/E4X/Processing_XML_with_E4X
In the script snippet you provided, the colons are used to identify the XML namespace of the following expression. Without that namespace, you may find that the incorrect object is referenced or you may get an undefined reference. See the specific area of the documentation archive linked above that pertains to Namespaces: https://developer.mozilla.org/en-US/docs/Archive/Web/E4X/Processing_XML_with_E4X#Handling_namespaces
The code essentially looks for an object property with the name: status. This isn't actually Array notation as it appears upon cursory inspection. Specifically, it looks for a namespaced property. It would not be the same as calling:
['status'].toString().call(orderXml.ns);
The .toString() method is used to ensure we get the String representation of the property rather than a reference to an instance of that XML Node.
Please note that Demandware uses a modified version of the Mozilla Rhino 1.7R5 JavaScript implementation. See feature matrix here: https://mozilla.github.io/rhino/compat/engines.html
Related
I'm trying to find a way to work with Discord.js TypeScript annotations using WebStorm's JSDoc type inference in a non-conflicting pattern.
Here's what "works"...
import Discord from 'discord.js';
/**
* #param {Client} client
* #param {Collection.<Snowflake, Message>} msgs
*/
function handleRemoveMessages(client, msgs) {}
The problem is with Client, multiple definitions exist.
While this works, I'd like to be able to namespace the imported types from the discord.js module into something like Discord.Client instead of Client, as I'd like to use other symbols named such.
So, for example... Message is referencing the correct type;
And Discord.Message appears to be referencing the correct type (but I don't believe it is);
The two Message type references are not compatible, and throw a warning when one is supplied to represent the other.
It's also not possible to reference the type via a JSDoc module path...
I also tried module:discord\.js, module:'discord\.js' and also with double quotes, all with the same results.
I know that using a dot in a JSDoc path name is a bit of a hack, and that the Closure compiler used by JetBrains may not be 100% up on JSDoc compliance.
Is this just a bug in WebStorm or Closure or is there a way to correctly make this module type reference?
according to JSDoc 3 spec, you need to quote the names with 'unusual' chanracters, like module:"discord.js". But it doesn't currently work as expected, please follow WEB-34348 for updates
I use doxygen to document C++ code. In the current project, I use the following format for function signatures:
MyClass(MyClass&& other)
However, in the generated HTML documentation, the brief description has this signature:
MyClass (MyClass &&other)
and the detailed description has this signature:
MyClass ( MyClass && other )
Is there a way of either preserving the original format, or changing the way doxygen formats the signatures? I have not found anything related to this issue in the customization or configuration pages.
Edit: Updated the signatures based on the discussion in the comments.
Short answer: No.
Long (and more correct) answer: Yes, if you're willing to modify the source code.
File memberdef.cpp has the following (line 1668 in what I'm looking at today):
// *** write arguments
if (argsString() && !isObjCMethod())
{
if (!isDefine() && !isTypedef()) ol.writeString(" ");
That last line is going to add space in the brief description. (I've verified this by removing it and recompiling.)
As for the detailed description, that sets up a table, with <td>(</td> opening the arguments list. You might get rid of that space more easily, but doing it well will probably require monkeying with the source code.
I guess the best option is to roll your own, or to request a feature addition from the developers.
When passing anonymous types to an HtmlHelper method like TextBox, you'll get binding errors (because anonymous type members have internal access only), unless you use a RouteDataDictionary to extract the members.
When I saw that the (HtmlHelper extension) InputExtensions.TextBox method accepted anonymous types, I knew it had to be doing some conversion internally or it would fail with the same error.
Sure enough, it calls HtmlHelper.AnonymousObjectToHtmlAttributes method, whose documentation tries to play down the issue by not mentioning it, instead suggesting it's just replacing underscores with dashes to ensure valid attribute names are used. Sure. Anyway...
I wanted to see exactly what that conversion looks like, but when I inspect HtmlHelper's static method with that name in ILSpy, the method appears to just call itself. What is going on here?
public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes)
{
return HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
}
The method AnonymousObjectToHtmlAttributes from System.Web.MVC.HtmlHelper is calling a method with the same name but from System.Web.WebPages.Html.HtmlHelper.
The ILSpy is not explicitly about that. I needed to hover the class to show from where it was coming:
I asked a similar question that was anwered here.
I'm trying to create and instance of an object by reference the class object of the class using
getDefinitionByName()
the problem is that if I don't create at least one instance of the class before when try to use getDefinitionByName() it say
ReferenceError: Error #1065: Variable XXXXXX is not defined.
how can I include the class in the binary without using and instance first??, also I had tried to juts leave in the import but still don't include the class, it could be a compiler param I can pass??
I'm using Flex SDK 4.6 thanks!!!!!
As described in the documentation:
-includes class Links one or more classes to the resulting application SWF file, whether or not those classes are required at compile time
There is a bunch of compiler options which allow you to include classes, but they aren't very scalable / require some manual labour. For example, there's -includes option, but you must know what symbols to include. There's -include-libraries, but again, you'd have to compile a SWC library with the classes you need. -include-namespace - you'd need to write the namespace definition, listing all classes that you want to include.
Since I imagine that the task in the end will get automated one way or another, it would make more sense to just generate an AS file of the following format:
package your.app {
import fully.qualified.class.Name;Name; // it is enough to just mention it
. . .
}
And then include only this this class.
Well I think I found the solution, just add to the compiler the argument -includes like thised
-includes com.example.Myclass
that will include the class object in the binary even though u haven't used and after tried to load it with getDefinitionByName()
hopes this help to someone else, also here is a complete list of arguments for the compiler
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a92.html
I use Doxygen for documenting the JavaScript API of my C++ (Qt) project. The idea is to write one specific documentation for the JavaScript interfaces, and one for the C++ classes us usual.
One example (datasource.dox) looks like this:
\addtogroup JavaScriptAPI
#{
...
\class DataSource
\brief DataSource is the .... some doc goes here ....
\section formats Supported formats
....
\fn isOpen()
\brief returns true if the data source is currently open...
...
#}
The generated help looks nice w.r.t. the class description (or 'object'-description), but the function documentation (isOpen(), ...) is missing. Doxygen creates warning messages like:
Warning: documented function `bool isOpen' was not declared or defined.
The question, now: can I somehow force doxygen to use my \fn-d function descriptions? It would be nice, if doxygen created all those member indices for me...
Two approaches for using doxygen with Javascript are listed here http://www.doxygen.org/helpers.html
(look for JavaScript)