Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/bindings/generator.h

Issue 29426559: Issue 5137 - [emscripten] Added basic filter storage implementation (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Rebased Created May 10, 2017, 12:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/FilterNotifier.h ('k') | compiled/bindings/generator.cpp » ('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 Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 std::string name; 173 std::string name;
174 FunctionInfo call; 174 FunctionInfo call;
175 }; 175 };
176 176
177 struct DifferentiatorInfo 177 struct DifferentiatorInfo
178 { 178 {
179 size_t offset; 179 size_t offset;
180 std::vector<std::pair<int, std::string>> mapping; 180 std::vector<std::pair<int, std::string>> mapping;
181 }; 181 };
182 182
183 typedef std::vector<PropertyInfo> Properties;
184 typedef std::vector<MethodInfo> Methods;
185
183 struct ClassInfo 186 struct ClassInfo
184 { 187 {
185 TYPEID id; 188 TYPEID id;
186 TYPEID baseClass; 189 TYPEID baseClass;
187 std::string name; 190 std::string name;
188 std::vector<PropertyInfo> properties; 191 Properties properties;
189 std::vector<MethodInfo> methods; 192 Methods methods;
190 DifferentiatorInfo subclass_differentiator; 193 DifferentiatorInfo subclass_differentiator;
191 ptrdiff_t ref_counted_offset; 194 ptrdiff_t ref_counted_offset;
192 }; 195 };
193 196
197 struct NamespaceInfo
198 {
199 std::string name;
200 Properties properties;
201 Methods methods;
202 };
203
194 void register_class(const char* name, TYPEID classID, TYPEID baseClassID, 204 void register_class(const char* name, TYPEID classID, TYPEID baseClassID,
195 ptrdiff_t ref_counted_offset); 205 ptrdiff_t ref_counted_offset);
196 206
197 void register_property(TYPEID classID, const char* name, 207 void register_property(TYPEID classID, const char* name,
198 const FunctionInfo& getter, const FunctionInfo& setter, 208 const FunctionInfo& getter, const FunctionInfo& setter,
199 const char* jsValue = ""); 209 const char* jsValue = "");
200 210
201 void register_method(TYPEID classID, const char* name, 211 void register_method(TYPEID classID, const char* name,
202 const FunctionInfo& call); 212 const FunctionInfo& call);
203 213
204 void register_differentiator(TYPEID classID, size_t offset, 214 void register_differentiator(TYPEID classID, size_t offset,
205 std::vector<std::pair<int, std::string>>& mapping); 215 std::vector<std::pair<int, std::string>>& mapping);
206 216
217 void register_namespace(const char* name);
218
219 void register_namespace_property(const char* namespaceName, const char* name,
220 const FunctionInfo& getter, const FunctionInfo& setter);
221
222 void register_namespace_method(const char* namespaceName, const char* name,
223 const FunctionInfo& call);
224
207 std::string wrapCall(const FunctionInfo& call, bool isFunction = true); 225 std::string wrapCall(const FunctionInfo& call, bool isFunction = true);
208 } 226 }
209 227
210 template<typename ClassType, 228 template<typename ClassType,
211 typename BaseClass = bindings_internal::NoBaseClass, 229 typename BaseClass = bindings_internal::NoBaseClass,
212 typename std::enable_if<std::is_base_of<ref_counted, ClassType>::value>::typ e* = nullptr> 230 typename std::enable_if<std::is_base_of<ref_counted, ClassType>::value>::typ e* = nullptr>
213 class class_ 231 class class_
214 { 232 {
215 public: 233 public:
216 class_(const char* name) 234 class_(const char* name)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 std::vector<std::pair<int, std::string>> mapping; 299 std::vector<std::pair<int, std::string>> mapping;
282 for (const auto& item : list) 300 for (const auto& item : list)
283 mapping.emplace_back(item.first, item.second); 301 mapping.emplace_back(item.first, item.second);
284 302
285 bindings_internal::register_differentiator( 303 bindings_internal::register_differentiator(
286 bindings_internal::TypeInfo<ClassType>(), offset, mapping); 304 bindings_internal::TypeInfo<ClassType>(), offset, mapping);
287 return *this; 305 return *this;
288 } 306 }
289 }; 307 };
290 308
309 class namespace_
310 {
311 private:
312 const char* mName;
313
314 public:
315 namespace_(const char* name)
316 : mName(name)
317 {
318 bindings_internal::register_namespace(name);
319 }
320
321 template<typename FieldType>
322 namespace_& property(const char* name,
323 FieldType (*getter)(),
324 void (*setter)(FieldType) = nullptr)
325 {
326 bindings_internal::register_namespace_property(mName, name, getter,
327 setter);
328 return *this;
329 }
330
331 template<typename ReturnType, typename... Args>
332 namespace_& function(const char* name, ReturnType (*method)(Args...))
333 {
334 bindings_internal::register_namespace_method(mName, name, method);
335 return *this;
336 }
337 };
338
291 void printBindings(); 339 void printBindings();
OLDNEW
« no previous file with comments | « compiled/FilterNotifier.h ('k') | compiled/bindings/generator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld