public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* Issue with template_argument when template argument is an integer.
@ 2009-08-03  7:23 Lucien Anti-Spam
  2009-08-03 17:56 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Lucien Anti-Spam @ 2009-08-03  7:23 UTC (permalink / raw)
  To: archer



Hi,

I was attempting to write a pretty pritner for a class and found that I cant get the arguments to a template if they are NOT a type (eg if they are int).  

I was trying this with the 6.8.50 from 2009-08-3rd and got the following sort of output...
       gdb main
    b some-line
    run
    print MYYABA
    { var=10, woo=30 }
    py print gdb.history(0).type.template_argument(0)
    int
    py print gdb.history(0).type.template_argument(1)
    float
    py print gdb.history(0).type.template_argument(2)
    RuntimeError: No type named 12.

Am I approaching this from the wrong angle?


Cheers,
Luc

---------- CODE -------------
---------- CODE -------------
---------- CODE -------------

// SOME SORT OF CLASS
template <typename W, class Z, int F >
class YABA
{
public:
    W var ;
    Z woo ;

    YABA( )
    {
    }

    void set( W v )
    {
        var = v + F ;
        woo = woo / (F *1.0);
    }

    W get( void )
    {
        return( var+woo );
    }

};


// MAIN
void main( void )
{
    int result ;

    // print MYYABA
    // py print gdb.history(0).type.template_argument(0)
    // py print gdb.history(0).type.template_argument(1)
    //
    // error now, "RuntimeError: No type named 12."
    // py print gdb.history(0).type.template_argument(2)
    //
    YABA<int, float, 12 > MYYABA ;

    // Direct access...
    MYYABA.var = 10 ;
    MYYABA.woo = 30 ;

    MYYABA.set( 5 ) ; 
    result = MYYABA.get( ) ; 

    result = result ;
}


      

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Issue with template_argument when template argument is an integer.
  2009-08-03  7:23 Issue with template_argument when template argument is an integer Lucien Anti-Spam
@ 2009-08-03 17:56 ` Tom Tromey
  2009-08-04  4:37   ` Lucien Anti-Spam
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-08-03 17:56 UTC (permalink / raw)
  To: Lucien Anti-Spam; +Cc: archer

>>>>> "Lucien" == Lucien Anti-Spam <lucienmp_antispam@yahoo.com> writes:

Lucien> I was attempting to write a pretty pritner for a class and found
Lucien> that I cant get the arguments to a template if they are NOT a
Lucien> type (eg if they are int).

Yeah, that is a problem.  I think there may also be much harder cases to
support than this one.

Lucien> Am I approaching this from the wrong angle?

Nope.  Basically, python-type.c:typy_template_argument needs to learn
that it should create a Value rather than a Type in some situations.

Could you file a bug report for this?  Thanks.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Issue with template_argument when template argument is an integer.
  2009-08-03 17:56 ` Tom Tromey
@ 2009-08-04  4:37   ` Lucien Anti-Spam
  0 siblings, 0 replies; 4+ messages in thread
From: Lucien Anti-Spam @ 2009-08-04  4:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: archer


Hi Tom,

Logged complete with a "workaround" example pp.py that uses string extraction to 
get the other template parameters, not very sleak but it does the job for now.

Bugzilla 10476:
   http://sourceware.org/bugzilla/show_bug.cgi?id=10476

Cheers,
Luc




----- Original Message ----
From: Tom Tromey <tromey@redhat.com>
To: Lucien Anti-Spam <lucienmp_antispam@yahoo.com>
Cc: archer@sourceware.org
Sent: Tuesday, August 4, 2009 2:56:34 AM
Subject: Re: Issue with template_argument when template argument is an integer.

>>>>> "Lucien" == Lucien Anti-Spam <lucienmp_antispam@yahoo.com> writes:

Lucien> I was attempting to write a pretty pritner for a class and found
Lucien> that I cant get the arguments to a template if they are NOT a
Lucien> type (eg if they are int).

Yeah, that is a problem.  I think there may also be much harder cases to
support than this one.

Lucien> Am I approaching this from the wrong angle?

Nope.  Basically, python-type.c:typy_template_argument needs to learn
that it should create a Value rather than a Type in some situations.

Could you file a bug report for this?  Thanks.

Tom



      

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Issue with template_argument when template argument is an integer.
@ 2009-08-03  9:13 Lucien Anti-Spam
  0 siblings, 0 replies; 4+ messages in thread
From: Lucien Anti-Spam @ 2009-08-03  9:13 UTC (permalink / raw)
  To: archer


Hi,

I did a bit more digging and found that I also couldnt use non-type parameters either.  For example;
   bools, function pointers, double &flt_ref,  char *string, enum_types, ...

Cheers,
Luc

---------- SNIPPETS
---------- SNIPPETS
---------- SNIPPETS

enum en_some_ranges { EN_ONE=10, EN_TWO, EN_THREE } ;
double Yflt =2.125;
char hello_s[] = "hello world" ;
int func( int I )
{
  return 0 ;
}

template <typename W, class Z, int F, 
      en_some_ranges R,   // 3
      bool B,                     // 4
      int FF(int),                 // 5
      double &FLT,             // 6
      char *str  >               // 7
....
....

main()
{
    YABA<int, float, 12, EN_THREE, true, &func,  Yflt, hello_s > MYYABA ;
}

(gdb) py print gdb.history(0).type.template_argument(3)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: No type named EN_THREE.
Error while executing Python code.
(gdb) py print gdb.history(0).type.template_argument(4)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: No type named true.
Error while executing Python code.
(gdb) py print gdb.history(0).type.template_argument(5)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: No type named func.
Error while executing Python code.
(gdb) py print gdb.history(0).type.template_argument(6)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: No type named (double&)(&Y).
Error while executing Python code.
(gdb) py print gdb.history(0).type.template_argument(7)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: No type named (char*)(&cstr_two).
Error while executing Python code.





----- Original Message ----
From: Lucien Anti-Spam <lucienmp_antispam@yahoo.com>
To: archer@sourceware.org
Sent: Monday, August 3, 2009 4:22:49 PM
Subject: Issue with template_argument when template argument is an integer.


Hi,

I was attempting to write a pretty pritner for a class and found that I cant get the arguments to a template if they are NOT a type (eg if they are int).  

I was trying this with the 6.8.50 from 2009-08-3rd and got the following sort of output...
       gdb main
    b some-line
    run
    print MYYABA
    { var=10, woo=30 }
    py print gdb.history(0).type.template_argument(0)
    int
    py print gdb.history(0).type.template_argument(1)
    float
    py print gdb.history(0).type.template_argument(2)
    RuntimeError: No type named 12.

Am I approaching this from the wrong angle?


Cheers,
Luc

---------- CODE -------------
---------- CODE -------------
---------- CODE -------------

// SOME SORT OF CLASS
template <typename W, class Z, int F >
class YABA
{
public:
    W var ;
    Z woo ;

    YABA( )
    {
    }

    void set( W v )
    {
        var = v + F ;
        woo = woo / (F *1.0);
    }

    W get( void )
    {
        return( var+woo );
    }

};


// MAIN
void main( void )
{
    int result ;

    // print MYYABA
    // py print gdb.history(0).type.template_argument(0)
    // py print gdb.history(0).type.template_argument(1)
    //
    // error now, "RuntimeError: No type named 12."
    // py print gdb.history(0).type.template_argument(2)
    //
    YABA<int, float, 12 > MYYABA ;

    // Direct access...
    MYYABA.var = 10 ;
    MYYABA.woo = 30 ;

    MYYABA.set( 5 ) ; 
    result = MYYABA.get( ) ; 

    result = result ;
}


      

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-04  4:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-03  7:23 Issue with template_argument when template argument is an integer Lucien Anti-Spam
2009-08-03 17:56 ` Tom Tromey
2009-08-04  4:37   ` Lucien Anti-Spam
2009-08-03  9:13 Lucien Anti-Spam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).