Index: compiled/bindings/generator.h |
=================================================================== |
--- a/compiled/bindings/generator.h |
+++ b/compiled/bindings/generator.h |
@@ -175,40 +175,58 @@ namespace bindings_internal |
}; |
struct DifferentiatorInfo |
{ |
size_t offset; |
std::vector<std::pair<int, std::string>> mapping; |
}; |
+ typedef std::vector<PropertyInfo> PropertyList; |
sergei
2017/05/08 10:54:39
It's usually a bad practice to call something like
Wladimir Palant
2017/05/08 12:55:41
Done.
|
+ typedef std::vector<MethodInfo> MethodList; |
+ |
struct ClassInfo |
{ |
TYPEID id; |
TYPEID baseClass; |
std::string name; |
- std::vector<PropertyInfo> properties; |
- std::vector<MethodInfo> methods; |
+ PropertyList properties; |
+ MethodList methods; |
DifferentiatorInfo subclass_differentiator; |
ptrdiff_t ref_counted_offset; |
}; |
+ struct NamespaceInfo |
+ { |
+ std::string name; |
+ PropertyList properties; |
+ MethodList methods; |
+ }; |
+ |
void register_class(const char* name, TYPEID classID, TYPEID baseClassID, |
ptrdiff_t ref_counted_offset); |
void register_property(TYPEID classID, const char* name, |
const FunctionInfo& getter, const FunctionInfo& setter, |
const char* jsValue = ""); |
void register_method(TYPEID classID, const char* name, |
const FunctionInfo& call); |
void register_differentiator(TYPEID classID, size_t offset, |
std::vector<std::pair<int, std::string>>& mapping); |
+ void register_namespace(const char* name); |
+ |
+ void register_namespace_property(const char* namespaceName, const char* name, |
+ const FunctionInfo& getter, const FunctionInfo& setter); |
+ |
+ void register_namespace_method(const char* namespaceName, const char* name, |
+ const FunctionInfo& call); |
+ |
std::string generateCall(const FunctionInfo& call, |
std::vector<std::string>& params); |
std::string wrapCall(const FunctionInfo& call, bool isFunction = true); |
void printHelpers(); |
void printClass(const ClassInfo& cls); |
@@ -290,9 +308,39 @@ public: |
mapping.emplace_back(item.first, item.second); |
bindings_internal::register_differentiator( |
bindings_internal::TypeInfo<ClassType>(), offset, mapping); |
return *this; |
} |
}; |
+class namespace_ |
+{ |
+private: |
+ const char* mName; |
+ |
+public: |
+ namespace_(const char* name) |
+ : mName(name) |
+ { |
+ bindings_internal::register_namespace(name); |
+ } |
+ |
+ template<typename FieldType> |
+ namespace_& property(const char* name, |
+ FieldType (*getter)(), |
+ void (*setter)(FieldType) = nullptr) |
+ { |
+ bindings_internal::register_namespace_property(mName, name, getter, |
+ setter); |
+ return *this; |
+ } |
+ |
+ template<typename ReturnType, typename... Args> |
+ namespace_& function(const char* name, ReturnType (*method)(Args...)) |
+ { |
+ bindings_internal::register_namespace_method(mName, name, method); |
+ return *this; |
+ } |
+}; |
+ |
void printBindings(); |