mozilla
Your Search Results

    Template:expTrevorh2

    <%
    /*
     * Pass a JSON object with the following
     * method: (required) [string] Method name
     * implemented: (optional) [gecko version]
     * deprecated: (optional) [gecko version]
     * obsolete: (optional) [gecko version]
     * renamed: (optional) [array of JSON objects] If this method had different name/s in the past, list oldest to newest
     *   old: (required) [string] Old method name
     *   gecko: (required) [gecko version]
     *   new: (optional) [string] New method name, only required for multiple renames
     * For further details of the following see https://developer.mozilla.org/en-US/docs/XPIDL#Methods_and_attributes
     * binaryname: (optional) [string]
     * noscript: (optional) [boolean]
     * notxpcom: (optional) [boolean]
     * nostdcall: (optional) [boolean]
     * jscontext: (optional) [boolean] implicit_jscontext
     * argc: (optional) [boolean] optional_argc
     *
     * Example usage:
     * {"method": "Example","implemented":"1.7","deprecated":"6.0","obsolete":"18.0","renamed":[{"old":"Demonstration","gecko":"8.0","new":"Demo"},{"old":"Demo","gecko":"11.0"}],"binaryname":"Test", "noscript":"true", "notxpcom":"true", "nostdcall":"true", "jscontext":"true", "argc":"true"}
     * {"method": "Example","implemented":"1.7","deprecated":"6.0","renamed":{"old":"Demo","gecko":"11.0"},"binaryname":"Test"}
    */
    
    if (!$0.method) {
        return;
    }
    
    var str_i = [];
    
    if ($0.implemented != '') {
        str_i.push('<div class="standardNote standardNoteMethod">Requires Gecko ' + $0.implemented + ' ' + template("geckoRelease", [$0.implemented]) + '</div>');
    }
    if ($0.deprecated != '') {
        str_i.push('<div class="deprecated deprecatedMethod">Deprecated since Gecko ' + $0.deprecated + ' ' + template("geckoRelease", [$0.deprecated]) + '</div>');
    }
    if ($0.obsolete != '') {
        str_i.push('<div class="obsolete obsoleteMethod">Obsolete since Gecko ' + $0.obsolete + ' ' + template("geckoRelease", [$0.obsolete]) + '</div>');
    }
    if ($0.renamed) {
        var arr = $0.renamed;
        if (!Array.isArray($0.renamed)) {
            arr = [$0.renamed];
        }
        arr.forEach(function(item) {
            var renamed_new = '';
            if (item.new) {
                renamed_new = ' to ' + item.new;
            }
            str_i.push('<div class="renamed renamedMethod">Renamed from ' + item.old + renamed_new + ' in Gecko ' + item.gecko + ' ' + template("geckoRelease", [item.gecko]) + '</div>');
        });
    }
    if ($0.binaryname != '') {
        var binaryname_local = mdn.localString({
            'en-US': '[binaryname] The C++ method is called "<binaryname>".'
        });
        str_i.push('<div class="binaryname binarynameMethod">' + binaryname_local.replace('<binaryname>', $0.binaryname) + '</div>');
    }
    if ($0.noscript || $0.notxpcom) {
        var noscript_local = mdn.localString({
            "en-US": "[noscript] This method may only be called from C++; don't use it from JavaScript.",
            "ja": "[noscript] このメソッドは C++ で内部的に使用されるものです。JavaScript のコード内で使用しないよう、ご注意ください。"
        });
        str_i.push('<div class="noscript noscriptMethod">' + noscript_local + '</div>');
    }
    if ($0.notxpcom) {
        var notxpcom_local = mdn.localString({
            "en-US": "[notxpcom] The C++ implementation does not return <code>nsresult</code> (implies <code>noscript</code>)."
        });
        str_i.push('<div class="notXPCOM notXPCOMMethod">' + notxpcom_local + '</div>');
    }
    if ($0.nostdcall) {
        var nostdcall_local = mdn.localString({
            "en-US": "[nostdcall] The C++ implementation uses <code>virtual nsresult</code> instead of <code>NS_IMETHOD/NS_IMETHODIMP</code>."
        });
        str_i.push('<div class="nostdcall nostdcallMethod">' + nostdcall_local + '</div>');
    }
    if ($0.jscontext) {
        var jscontext_local = mdn.localString({
            "en-US": "[implicit_jscontext] Adds an additional <code>JSContext *cx parameter</code> to the C++ implementation."
        });
        str_i.push('<div class="jscontext implicit_jscontextMethod">' + jscontext_local + '</div>');
    }
    if ($0.argc) {
        var argc_local = mdn.localString({
            "en-US": "[optional_argc] Adds an additional <code>uint8_t _argc</code> parameter to the C++ implementation."
        });
        str_i.push('<div class="jscontext implicit_jscontextMethod">' + argc_local + '</div>');
    }
    
    var str = '<div>';
    if (str_i != []) {
        str += '<div class="indicatorInHeadline">' + string.Join(str_i,'') + '</div>';
    }
    str += '<h3>' + $0.method + '()</h3></div>';
    %>
    <%- str %>
    Search for pages that use Template:expTrevorh2 to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Contributors to this page: openjck, trevorh
    Last updated by: trevorh,