Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: app/gtk_signal.h

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/gtk_integers.h ('k') | app/gtk_signal_registrar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef APP_GTK_SIGNAL_H_
6 #define APP_GTK_SIGNAL_H_
7 #pragma once
8
9 typedef void* gpointer;
10 typedef struct _GtkWidget GtkWidget;
11
12 // At the time of writing this, there were two common ways of binding our C++
13 // code to the gobject C system. We either defined a whole bunch of "static
14 // MethodThunk()" which just called nonstatic Method()s on a class (which hurt
15 // readability of the headers and signal connection code) OR we declared
16 // "static Method()" and passed in the current object as the gpointer (and hurt
17 // readability in the implementation by having "context->" before every
18 // variable).
19
20 // The hopeful result of using these macros is that the code will be more
21 // readable and regular. There shouldn't be a bunch of static Thunks visible in
22 // the headers and the implementations shouldn't be filled with "context->"
23 // de-references.
24
25 #define CHROMEG_CALLBACK_0(CLASS, RETURN, METHOD, SENDER) \
26 static RETURN METHOD ## Thunk(SENDER sender, gpointer userdata) { \
27 return reinterpret_cast<CLASS*>(userdata)->METHOD(sender); \
28 } \
29 \
30 virtual RETURN METHOD(SENDER);
31
32 #define CHROMEG_CALLBACK_1(CLASS, RETURN, METHOD, SENDER, ARG1) \
33 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, \
34 gpointer userdata) { \
35 return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one); \
36 } \
37 \
38 virtual RETURN METHOD(SENDER, ARG1);
39
40 #define CHROMEG_CALLBACK_2(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2) \
41 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
42 gpointer userdata) { \
43 return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one, two); \
44 } \
45 \
46 virtual RETURN METHOD(SENDER, ARG1, ARG2);
47
48 #define CHROMEG_CALLBACK_3(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3) \
49 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
50 ARG3 three, gpointer userdata) { \
51 return reinterpret_cast<CLASS*>(userdata)-> \
52 METHOD(sender, one, two, three); \
53 } \
54 \
55 virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3);
56
57 #define CHROMEG_CALLBACK_4(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
58 ARG4) \
59 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
60 ARG3 three, ARG4 four, \
61 gpointer userdata) { \
62 return reinterpret_cast<CLASS*>(userdata)-> \
63 METHOD(sender, one, two, three, four); \
64 } \
65 \
66 virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4);
67
68 #define CHROMEG_CALLBACK_5(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
69 ARG4, ARG5) \
70 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
71 ARG3 three, ARG4 four, ARG5 five, \
72 gpointer userdata) { \
73 return reinterpret_cast<CLASS*>(userdata)-> \
74 METHOD(sender, one, two, three, four, five); \
75 } \
76 \
77 virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5);
78
79 #define CHROMEG_CALLBACK_6(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
80 ARG4, ARG5, ARG6) \
81 static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
82 ARG3 three, ARG4 four, ARG5 five, \
83 ARG6 six, gpointer userdata) { \
84 return reinterpret_cast<CLASS*>(userdata)-> \
85 METHOD(sender, one, two, three, four, five, six); \
86 } \
87 \
88 virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
89
90 // These macros handle the common case where the sender object will be a
91 // GtkWidget*.
92 #define CHROMEGTK_CALLBACK_0(CLASS, RETURN, METHOD) \
93 CHROMEG_CALLBACK_0(CLASS, RETURN, METHOD, GtkWidget*);
94
95 #define CHROMEGTK_CALLBACK_1(CLASS, RETURN, METHOD, ARG1) \
96 CHROMEG_CALLBACK_1(CLASS, RETURN, METHOD, GtkWidget*, ARG1);
97
98 #define CHROMEGTK_CALLBACK_2(CLASS, RETURN, METHOD, ARG1, ARG2) \
99 CHROMEG_CALLBACK_2(CLASS, RETURN, METHOD, GtkWidget*, ARG1, ARG2);
100
101 #define CHROMEGTK_CALLBACK_3(CLASS, RETURN, METHOD, ARG1, ARG2, ARG3) \
102 CHROMEG_CALLBACK_3(CLASS, RETURN, METHOD, GtkWidget*, ARG1, ARG2, ARG3);
103
104 #define CHROMEGTK_CALLBACK_4(CLASS, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4) \
105 CHROMEG_CALLBACK_4(CLASS, RETURN, METHOD, GtkWidget*, ARG1, ARG2, ARG3, ARG4);
106
107 #define CHROMEGTK_CALLBACK_5(CLASS, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \
108 ARG5) \
109 CHROMEG_CALLBACK_5(CLASS, RETURN, METHOD, GtkWidget*, ARG1, ARG2, ARG3, \
110 ARG4, ARG5);
111
112 #define CHROMEGTK_CALLBACK_6(CLASS, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \
113 ARG5, ARG6) \
114 CHROMEG_CALLBACK_6(CLASS, RETURN, METHOD, GtkWidget*, ARG1, ARG2, ARG3, \
115 ARG4, ARG5, ARG6);
116
117 #endif // APP_GTK_SIGNAL_H_
OLDNEW
« no previous file with comments | « app/gtk_integers.h ('k') | app/gtk_signal_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698