示例#1
0
void Lstar_spec::
do_print(const _Tt_ostream &os, const _Tt_object *obj)
{
	((Lstar_spec *)obj)->print(os.theFILE());
}
示例#2
0
文件: tt_string.C 项目: juddy/edcde
// a non-member function for use when you have a char *, but don't
// yet have a _Tt_string.
void
_tt_print_escaped_string(const _Tt_ostream &os, const char *s, int length,
                         int max_print_width, int quote_it)
{
    int i, count;

    static int width_inited = 0;
    static int _max_print_width;
    if (! width_inited) {
        width_inited = 1;
        _max_print_width = 40;
        char *s = _tt_get_first_set_env_var(2, "TT_ARG_TRACE_WIDTH",
                                            "_SUN_TT_ARG_TRACE_WIDTH");
        if (s != 0) {
            _max_print_width = atoi(s);
        }
    }
    switch (max_print_width) {
    case _Tt_string_unlimited:
        max_print_width = 80000;
        break;
    case _Tt_string_user_width:
        max_print_width = _max_print_width;
        break;
    }
    if (s == 0) {
        os << "(null)";
    } else {
        wchar_t wc;
        int n;

        if (quote_it) {
            os << '"';
        }

        for (count=0, i=0; count < max_print_width && i < length;) {

            if (length - i >= MB_LEN_MAX) {

                if ((n = mbtowc(&wc, &s[i], MB_LEN_MAX)) != -1) {
                    // multi-byte character buffer. Interpret it appropriately.

                    if (iswprint(wc) || iswspace(wc)) {
                        count += (n == 0) ? 1 : n;

                        // We do it this way rather than through
                        // _Tt_iostream operator<<  method because
                        // wchar_t is equivalent  to a long and the
                        // compiler doesn't know which method to use.
                        os.sprintf(MB_LEN_MAX, "%C", wc);
                    } else {
                        count += (3  + ((n == 0) ? 1 : n));

                        // don't print past limit, even a little.
                        if (count < max_print_width) {
                            os.sprintf(10, "\\%03C", wc);
                        }
                    }

                    i += (n == 0) ? 1 : n;

                    continue;
                }
            }

            // non-multi-byte character buffer...
            if (isprint((unsigned char) s[i]) ||
                    isspace((unsigned char) s[i])) {
                count += 1;
                os << s[i];
            } else {
                count += 3;

                // don't print past limit, even a little.
                if (count < max_print_width) {
                    os.sprintf(10, "\\%03o", (unsigned char) s[i]);
                }
            }
            i++;
        }

        if (quote_it) {
            os << '"';
        }

        if (i < length) {
            os << "[...]";
        }
    }
}
示例#3
0
void _Tt_signature::
print(const _Tt_ostream &os) const
{
    _Tt_arg_list_cursor	argc;

    //
    // XXX This is only used for Classing Engine, never for
    // tracing, so we can be lazy and write directly to the
    // FILE * of the _Tt_ostream.
    //
    FILE *fs = os.theFILE();
    fprintf(fs,"(\n");
    fprintf(fs,"\t\t(%s,%s,<",
            _tt_ce_attr_string(_TYPE_NAME),
            _tt_ce_attr_string(_TT_TOOLTALK_TYPE));
    if (_otid.len()) {
        _otid.print(fs);
    } else {
        _ptid.print(fs);
    }
    fputs("::", fs);
    _op.print(fs);
    if (0==_mangled_args.len()) {
        fputc('_',fs);
    } else {
        _mangled_args.print(fs);
    }
    fputs(">)\n", fs);
    fprintf(fs,"\t\t(%s,string,<%s>)\n",
            _tt_ce_attr_string(_TT_TOOLTALK_TYPE),
            _tt_ce_attr_string(_TT_TOOLTALK_SIGNATURE));
    fprintf(fs,"\t\t(%s,string,<", _tt_ce_attr_string(_TT_OP));
    _op.print(fs);
    fputs(">)\n", fs);
    fprintf(fs,"\t\t(%s,string,<%s>)\n",
            _tt_ce_attr_string(_TT_CATEGORY),
            _tt_enumname(_pattern_category));
    argc.reset(_args);
    int argn=0;
    while (argc.next()) {
        fprintf(fs,"\t\t(%s%d,string,<%s ",
                _tt_ce_attr_string(_TT_ARG), argn,
                _tt_enumname(argc->mode()));
        argc->type().print(fs);
        fputs(" ", fs);
        argc->name().print(fs);
        fputs(">)\n", fs);
        argn++;
    }
    fprintf(fs,"\t\t(%s,string,<%s>)\n",
            (_otid.len()) ? _tt_ce_attr_string(_TT_MSET_SCOPE) :
            _tt_ce_attr_string(_TT_SCOPE),
            _tt_enumname(_scope));
    fprintf(fs,"\t\t(%s,string,<%s>)\n",
            _tt_ce_attr_string(_TT_CLASS),
            _tt_enumname(_message_class));
    switch (_reliability) {
    case TT_START+TT_QUEUE:
#ifdef NOT_BACKWARD_COMPATIBLE
        fprintf(fs,"\t\t(%s,string,<TT_START+TT_QUEUE>)\n",
                _tt_ce_attr_string(_TT_MSET_DISPOSITION));
#else
        //
        // Version 1.0 can't deal with start+queue, so we
        // hide it in the typename, which version 1.0 doesn't
        // check.
        //
        fprintf(fs,"\t\t(%s,string:TT_START+TT_QUEUE,<TT_START>)\n",
                _tt_ce_attr_string(_TT_MSET_DISPOSITION));
#endif /*NOT_BACKWARD_COMPATIBLE*/
        break;
    case TT_QUEUE:
        fprintf(fs,"\t\t(%s,string,<TT_QUEUE>)\n",
                _tt_ce_attr_string(_TT_MSET_DISPOSITION));
        break;
    case TT_START:
        fprintf(fs,"\t\t(%s,string,<TT_START>)\n",
                _tt_ce_attr_string(_TT_MSET_DISPOSITION));
        break;
    case TT_DISCARD:
    default:
        fprintf(fs,"\t\t(%s,string,<TT_DISCARD>)\n",
                _tt_ce_attr_string(_TT_MSET_DISPOSITION));
        break;
    }
    fprintf(fs,"\t\t(%s,string,<%d>)\n",
            _tt_ce_attr_string(_TT_MSET_OPNUM), _opnum);
    fprintf(fs,"\t\t(%s,string,<",
            _tt_ce_attr_string(_TT_MSET_HANDLER_PTYPE));
    _ptid.print(fs);
    fputs(">)\n", fs);
    if (_otid.len()) {
        fprintf(fs,"\t\t(%s,string,<",
                _tt_ce_attr_string(_TT_MSET_OTYPE));
        _otid.print(fs);
        fputs(">)\n", fs);
    }
    fprintf(fs,"\t)");
}