xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-apple-macosx10.7.2
2*f4a2713aSLionel Sambuc // PR1084
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc extern "C"
5*f4a2713aSLionel Sambuc {
6*f4a2713aSLionel Sambuc   typedef unsigned char PRUint8;
7*f4a2713aSLionel Sambuc   typedef unsigned int PRUint32;
8*f4a2713aSLionel Sambuc }
9*f4a2713aSLionel Sambuc typedef PRUint32 nsresult;
10*f4a2713aSLionel Sambuc struct nsID
11*f4a2713aSLionel Sambuc {
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc typedef nsID nsIID;
14*f4a2713aSLionel Sambuc class nsISupports
15*f4a2713aSLionel Sambuc {
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc extern "C++"
18*f4a2713aSLionel Sambuc {
19*f4a2713aSLionel Sambuc   template < class T > struct nsCOMTypeInfo
20*f4a2713aSLionel Sambuc   {
GetIIDnsCOMTypeInfo21*f4a2713aSLionel Sambuc     static const nsIID & GetIID ()
22*f4a2713aSLionel Sambuc     {
23*f4a2713aSLionel Sambuc     }
24*f4a2713aSLionel Sambuc   };
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc class nsIDOMEvent:public nsISupports
28*f4a2713aSLionel Sambuc {
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc class nsIDOMEventListener:public nsISupports
31*f4a2713aSLionel Sambuc {
GetIID()32*f4a2713aSLionel Sambuc public:static const nsIID & GetIID ()
33*f4a2713aSLionel Sambuc   {
34*f4a2713aSLionel Sambuc   }
35*f4a2713aSLionel Sambuc   virtual nsresult
36*f4a2713aSLionel Sambuc     __attribute__ ((regparm (0), cdecl)) HandleEvent (nsIDOMEvent * event) =
37*f4a2713aSLionel Sambuc     0;
38*f4a2713aSLionel Sambuc };
39*f4a2713aSLionel Sambuc class nsIDOMMouseListener:public nsIDOMEventListener
40*f4a2713aSLionel Sambuc {
GetIID()41*f4a2713aSLionel Sambuc public:static const nsIID & GetIID ()
42*f4a2713aSLionel Sambuc   {
43*f4a2713aSLionel Sambuc     static const nsIID iid = {
44*f4a2713aSLionel Sambuc     };
45*f4a2713aSLionel Sambuc   }
46*f4a2713aSLionel Sambuc   virtual nsresult
47*f4a2713aSLionel Sambuc     __attribute__ ((regparm (0),
48*f4a2713aSLionel Sambuc 		    cdecl)) MouseDown (nsIDOMEvent * aMouseEvent) = 0;
49*f4a2713aSLionel Sambuc };
50*f4a2713aSLionel Sambuc typedef
51*f4a2713aSLionel Sambuc typeof (&nsIDOMEventListener::HandleEvent)
52*f4a2713aSLionel Sambuc   GenericHandler;
53*f4a2713aSLionel Sambuc      struct EventDispatchData
54*f4a2713aSLionel Sambuc      {
55*f4a2713aSLionel Sambuc        PRUint32 message;
56*f4a2713aSLionel Sambuc        GenericHandler method;
57*f4a2713aSLionel Sambuc        PRUint8 bits;
58*f4a2713aSLionel Sambuc      };
59*f4a2713aSLionel Sambuc      struct EventTypeData
60*f4a2713aSLionel Sambuc      {
61*f4a2713aSLionel Sambuc        const EventDispatchData *events;
62*f4a2713aSLionel Sambuc        int numEvents;
63*f4a2713aSLionel Sambuc        const nsIID *iid;
64*f4a2713aSLionel Sambuc      };
65*f4a2713aSLionel Sambuc      static const EventDispatchData sMouseEvents[] = {
66*f4a2713aSLionel Sambuc        {
67*f4a2713aSLionel Sambuc 	(300 + 2),
68*f4a2713aSLionel Sambuc 	reinterpret_cast < GenericHandler > (&nsIDOMMouseListener::MouseDown),
69*f4a2713aSLionel Sambuc 	0x01}
70*f4a2713aSLionel Sambuc      };
71*f4a2713aSLionel Sambuc static const EventTypeData sEventTypes[] = {
72*f4a2713aSLionel Sambuc   {
73*f4a2713aSLionel Sambuc    sMouseEvents, (sizeof (sMouseEvents) / sizeof (sMouseEvents[0])),
74*f4a2713aSLionel Sambuc    &nsCOMTypeInfo < nsIDOMMouseListener >::GetIID ()}
75*f4a2713aSLionel Sambuc };
76