Attribute: alias - nidium/IDL GitHub Wiki
Attribute name: Alias
- Name: alias
- Since: draft
- Usage: on 'Method'
- Allowed value: string with the operation name (e.g. 'log')
- Rationale: Some functions are present to the userprogram under more than one name, to avoid double work, confusing documentation, and strive for a smaller code base an alias can be used.
- Reference: 'console.error', 'console.info', 'console.warn'
Example
IDL
[] interface Console {
static void log( optional DOMString text );
[Alias=log] static void warn (optional DOMString text );
};
C++
JSFunctionSpec *JSConsole::ListMethods()
{
static JSFunctionSpec funcs[] = {
CLASSMAPPER_FN(JSConsole, log, 0),
CLASSMAPPER_FN_ALIAS(JSConsole, warn, 0, log),
JS_FS_END
};
return funcs;
}
javascript
console.log("ok");
console.warn("this is a warning");