Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for templates in genwxbind.lua #82

Closed
solemnwarning opened this issue Dec 14, 2020 · 1 comment
Closed

Support for templates in genwxbind.lua #82

solemnwarning opened this issue Dec 14, 2020 · 1 comment
Assignees

Comments

@solemnwarning
Copy link
Contributor

I've been prototyping plugin support for one of my projects with wxlua, and I want to use it to generate bindings for the application's classes so they can be exposed to the plugins, but genwxbind.lua doesn't appear to have any kind of template support, and my project uses them extensively both in the form of STL containers and my own template classes.

I haven't really looked into the code, this might be too big of a feature to do without drastic rework, but it would be nice since my only other ideas are to manually roll bindings for each different instantiation of the templates (not sure if this will work) or make some horrible combination of wxlua and some other binding library like LuaBridge.

Below are excerpts from some of the classes that I need to create bindings for:

class Document: public wxEvtHandler {
		struct Comment
		{
			std::shared_ptr<const wxString> text;
			
			Comment(const wxString &text);
			
			bool operator==(const Comment &rhs) const
			{
				return *text == *(rhs.text);
			}
			
			wxString menu_preview() const;
		};
		
		const NestedOffsetLengthMap<Comment> &get_comments() const;
		bool set_comment(off_t offset, off_t length, const Comment &comment);
		bool erase_comment(off_t offset, off_t length);
		
		const NestedOffsetLengthMap<int> &get_highlights() const;
		bool set_highlight(off_t off, off_t length, int highlight_colour_idx);
		bool erase_highlight(off_t off, off_t length);
		
		const ByteRangeMap<std::string> &get_data_types() const;
		bool set_data_type(off_t offset, off_t length, const std::string &type);
}
template<typename T> class ByteRangeMap
{
	struct Range
	{
		off_t offset;
		off_t length;
		
		Range(off_t offset, off_t length);
		
		bool operator<(const Range &rhs) const;
		bool operator==(const Range &rhs) const;
	};
	
	typedef typename std::vector< std::pair<Range, T> >::iterator iterator;
	typedef typename std::vector< std::pair<Range, T> >::const_iterator const_iterator;
	
	ByteRangeMap(const T &default_value = T());
	
	ByteRangeMap(const ByteRangeMap &src);
	
	bool operator==(const ByteRangeMap<T> &rhs) const;
	bool operator!=(const ByteRangeMap<T> &rhs) const;
	
	const_iterator get_range(off_t offset) const;
	
	void set_range(off_t offset, off_t length, const T &value);
	
	const std::vector< std::pair<Range, T> > &get_ranges() const;
	
	const_iterator begin() const;
	const_iterator end() const;
};

For a more complete view of the classes:

https://github.com/solemnwarning/rehex/blob/master/src/document.hpp
https://github.com/solemnwarning/rehex/blob/master/src/ByteRangeMap.hpp

@pkulchenko pkulchenko self-assigned this Dec 15, 2020
@pkulchenko
Copy link
Owner

I think this would be an interesting feature, but I checked the genwxbind.lua code and don't see a straightforward way to integrate this into the bindings unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants