Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(785)

Side by Side Diff: lily/include/callback.hh

Issue 549480043: Run scripts/auxiliar/fixcc.py (Closed)
Patch Set: Created 5 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lily/include/break-align-interface.hh ('k') | lily/include/change-iterator.hh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 2016--2020 David Kastrup <dak@gnu.org> 4 Copyright (C) 2016--2020 David Kastrup <dak@gnu.org>
5 5
6 LilyPond is free software: you can redistribute it and/or modify 6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 { 53 {
54 return trampoline_ (target, arg); 54 return trampoline_ (target, arg);
55 } 55 }
56 // Callback wrappers are for an unchanging entity, so we do the Lisp 56 // Callback wrappers are for an unchanging entity, so we do the Lisp
57 // creation just once on the first call of make_smob. So we only 57 // creation just once on the first call of make_smob. So we only
58 // get a single Callback_wrapper instance for each differently 58 // get a single Callback_wrapper instance for each differently
59 // templated make_smob call. 59 // templated make_smob call.
60 template <SCM (*trampoline) (SCM, SCM)> 60 template <SCM (*trampoline) (SCM, SCM)>
61 static SCM make_smob () 61 static SCM make_smob ()
62 { 62 {
63 static SCM res = 63 static SCM res
64 scm_permanent_object (Callback_wrapper (trampoline).smobbed_copy ()); 64 = scm_permanent_object (Callback_wrapper (trampoline).smobbed_copy ());
65 return res; 65 return res;
66 } 66 }
67 }; 67 };
68 68
69 class Callback2_wrapper : public Simple_smob<Callback2_wrapper> 69 class Callback2_wrapper : public Simple_smob<Callback2_wrapper>
70 { 70 {
71 // See Callback_wrapper for the details. Callback2_wrapper just 71 // See Callback_wrapper for the details. Callback2_wrapper just
72 // supports an additional SCM argument as compared to 72 // supports an additional SCM argument as compared to
73 // Callback_wrapper but is otherwise identical. 73 // Callback_wrapper but is otherwise identical.
74 SCM (*trampoline_) (SCM, SCM, SCM); 74 SCM (*trampoline_) (SCM, SCM, SCM);
75 Callback2_wrapper (SCM (*trampoline) (SCM, SCM, SCM)) 75 Callback2_wrapper (SCM (*trampoline) (SCM, SCM, SCM))
76 : trampoline_ (trampoline) 76 : trampoline_ (trampoline)
77 { } // Private constructor, use only in make_smob 77 { } // Private constructor, use only in make_smob
78 public: 78 public:
79 LY_DECLARE_SMOB_PROC (&Callback2_wrapper::call, 3, 0, 0) 79 LY_DECLARE_SMOB_PROC (&Callback2_wrapper::call, 3, 0, 0)
80 SCM call (SCM target, SCM arg1, SCM arg2) 80 SCM call (SCM target, SCM arg1, SCM arg2)
81 { 81 {
82 return trampoline_ (target, arg1, arg2); 82 return trampoline_ (target, arg1, arg2);
83 } 83 }
84 84
85 template <SCM (*trampoline) (SCM, SCM, SCM)> 85 template <SCM (*trampoline) (SCM, SCM, SCM)>
86 static SCM make_smob () 86 static SCM make_smob ()
87 { 87 {
88 static SCM res = 88 static SCM res
89 scm_permanent_object (Callback2_wrapper (trampoline).smobbed_copy ()); 89 = scm_permanent_object (Callback2_wrapper (trampoline).smobbed_copy ());
90 return res; 90 return res;
91 } 91 }
92 }; 92 };
93 93
94 class Callback0_wrapper : public Simple_smob<Callback0_wrapper> 94 class Callback0_wrapper : public Simple_smob<Callback0_wrapper>
95 { 95 {
96 // See Callback_wrapper for the details. Callback0_wrapper does not 96 // See Callback_wrapper for the details. Callback0_wrapper does not
97 // pass arguments but is otherwise identical to Callback_wrapper. 97 // pass arguments but is otherwise identical to Callback_wrapper.
98 SCM (*trampoline_) (SCM); 98 SCM (*trampoline_) (SCM);
99 Callback0_wrapper (SCM (*trampoline) (SCM)) 99 Callback0_wrapper (SCM (*trampoline) (SCM))
100 : trampoline_ (trampoline) 100 : trampoline_ (trampoline)
101 { } // Private constructor, use only in make_smob 101 { } // Private constructor, use only in make_smob
102 public: 102 public:
103 LY_DECLARE_SMOB_PROC (&Callback0_wrapper::call, 1, 0, 0) 103 LY_DECLARE_SMOB_PROC (&Callback0_wrapper::call, 1, 0, 0)
104 SCM call (SCM target) 104 SCM call (SCM target)
105 { 105 {
106 return trampoline_ (target); 106 return trampoline_ (target);
107 } 107 }
108 108
109 template <SCM (*trampoline) (SCM)> 109 template <SCM (*trampoline) (SCM)>
110 static SCM make_smob () 110 static SCM make_smob ()
111 { 111 {
112 static SCM res = 112 static SCM res
113 scm_permanent_object (Callback0_wrapper (trampoline).smobbed_copy ()); 113 = scm_permanent_object (Callback0_wrapper (trampoline).smobbed_copy ());
114 return res; 114 return res;
115 } 115 }
116 // Since there are no arguments at all, we might as well provide 116 // Since there are no arguments at all, we might as well provide
117 // default trampolines 117 // default trampolines
118 template <class T, SCM (T::*p)()> 118 template <class T, SCM (T::*p) ()>
119 static SCM trampoline (SCM target) 119 static SCM trampoline (SCM target)
120 { 120 {
121 T *t = LY_ASSERT_SMOB (T, target, 1); 121 T *t = LY_ASSERT_SMOB (T, target, 1);
122 return (t->*p) (); 122 return (t->*p) ();
123 } 123 }
124 124
125 template <class T, void (T::*p)()> 125 template <class T, void (T::*p) ()>
126 static SCM trampoline (SCM target) 126 static SCM trampoline (SCM target)
127 { 127 {
128 T *t = LY_ASSERT_SMOB (T, target, 1); 128 T *t = LY_ASSERT_SMOB (T, target, 1);
129 (t->*p) (); 129 (t->*p) ();
130 return SCM_UNSPECIFIED; 130 return SCM_UNSPECIFIED;
131 } 131 }
132 132
133 template <class T, SCM (T::*p)()> 133 template <class T, SCM (T::*p) ()>
134 static SCM make_smob () 134 static SCM make_smob ()
135 { 135 {
136 return make_smob<trampoline<T, p> > (); 136 return make_smob<trampoline<T, p> > ();
137 } 137 }
138 138
139 template <class T, void (T::*p)()> 139 template <class T, void (T::*p) ()>
140 static SCM make_smob () 140 static SCM make_smob ()
141 { 141 {
142 return make_smob<trampoline<T, p> > (); 142 return make_smob<trampoline<T, p> > ();
143 } 143 }
144 }; 144 };
145 145
146 // The following will usually be used unsmobbified, relying on its 146 // The following will usually be used unsmobbified, relying on its
147 // constituents being protected independently. 147 // constituents being protected independently.
148 148
149 class Method_instance : public Simple_smob<Method_instance> 149 class Method_instance : public Simple_smob<Method_instance>
(...skipping 27 matching lines...) Expand all
177 return scm_call_3 (method_, instance_, arg1, arg2); 177 return scm_call_3 (method_, instance_, arg1, arg2);
178 } 178 }
179 SCM mark_smob () const 179 SCM mark_smob () const
180 { 180 {
181 scm_gc_mark (method_); 181 scm_gc_mark (method_);
182 return instance_; 182 return instance_;
183 } 183 }
184 }; 184 };
185 185
186 #endif 186 #endif
OLDNEW
« no previous file with comments | « lily/include/break-align-interface.hh ('k') | lily/include/change-iterator.hh » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b