lib/protobuf.js
function exportProtobuf(pkgname, obj, callback) {
    var lstexport = [];
    var lstreq = [];
    var lstres = [];

    if (Array.isArray(obj)) {
        var str = 'package ' + pkgname + ';\r\n\r\n';

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                if (base.isResMsg(obj[i].name)) {
                    lstres.push({name: obj[i].name, comment: obj[i].comment});
                }
                else if (base.isReqMsg(obj[i].name)) {
                    lstreq.push({name: obj[i].name, comment: obj[i].comment});
                }
            }
        }

        str += exportEnumMsgID(lstreq, base.getGlobalObj('REQ_MSGID_BEGIN', obj).val.val, lstres, base.getGlobalObj('RES_MSGID_BEGIN', obj).val.val);

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                lstexport = exportMember(obj[i], lstexport, obj);
            }
        }

        for (var i = 0; i < lstexport.length; ++i) {
            var co = base.getGlobalObj(lstexport[i], obj);
            if (co.type == 'enum') {
                var cs = exportEnum(co, callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
            else {
                var cs = exportMsg(co, callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
        }

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                var cs = exportMsg(obj[i], callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
        }

        return str;
    }

    return undefined;
}
function exportProtobuf(pkgname, obj, callback) {
    var lstexport = [];
    var lstreq = [];
    var lstres = [];

    if (Array.isArray(obj)) {
        var str = 'package ' + pkgname + ';\r\n\r\n';

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                if (base.isResMsg(obj[i].name)) {
                    lstres.push({name: obj[i].name, comment: obj[i].comment});
                }
                else if (base.isReqMsg(obj[i].name)) {
                    lstreq.push({name: obj[i].name, comment: obj[i].comment});
                }
            }
        }

        str += exportEnumMsgID(lstreq, base.getGlobalObj('REQ_MSGID_BEGIN', obj).val.val, lstres, base.getGlobalObj('RES_MSGID_BEGIN', obj).val.val);

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                lstexport = exportMember(obj[i], lstexport, obj);
            }
        }

        for (var i = 0; i < lstexport.length; ++i) {
            var co = base.getGlobalObj(lstexport[i], obj);
            if (co.type == 'enum') {
                var cs = exportEnum(co, callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
            else {
                var cs = exportMsg(co, callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
        }

        for (var i = 0; i < obj.length; ++i) {
            if (obj[i].type == 'message') {
                var cs = exportMsg(obj[i], callback, obj);
                if (cs == undefined) {
                    return ;
                }

                str += cs + '\r\n';
            }
        }

        return str;
    }

    return undefined;
}
function exportProtobuf ( pkgname , obj , callback ) { var lstexport = [ ] ; var lstreq = [ ] ; var lstres = [ ] ; if ( Array . isArray ( obj ) ) { var str = 'package ' + pkgname + ';\r\n\r\n' ; for ( var i = 0 ; i < obj . length ; ++ i ) { if ( obj [ i ] . type == 'message' ) { if ( base . isResMsg ( obj [ i ] . name ) ) { lstres . push ( { name : obj [ i ] . name , comment : obj [ i ] . comment } ) ; } else if ( base . isReqMsg ( obj [ i ] . name ) ) { lstreq . push ( { name : obj [ i ] . name , comment : obj [ i ] . comment } ) ; } } } str += exportEnumMsgID ( lstreq , base . getGlobalObj ( 'REQ_MSGID_BEGIN' , obj ) . val . val , lstres , base . getGlobalObj ( 'RES_MSGID_BEGIN' , obj ) . val . val ) ; for ( var i = 0 ; i < obj . length ; ++ i ) { if ( obj [ i ] . type == 'message' ) { lstexport = exportMember ( obj [ i ] , lstexport , obj ) ; } } for ( var i = 0 ; i < lstexport . length ; ++ i ) { var co = base . getGlobalObj ( lstexport [ i ] , obj ) ; if ( co . type == 'enum' ) { var cs = exportEnum ( co , callback , obj ) ; if ( cs == undefined ) { return ; } str += cs + '\r\n' ; } else { var cs = exportMsg ( co , callback , obj ) ; if ( cs == undefined ) { return ; } str += cs + '\r\n' ; } } for ( var i = 0 ; i < obj . length ; ++ i ) { if ( obj [ i ] . type == 'message' ) { var cs = exportMsg ( obj [ i ] , callback , obj ) ; if ( cs == undefined ) { return ; } str += cs + '\r\n' ; } } return str ; } return undefined ; }
callback(isok, err)
callback ( isok err )