Language Bindings
From Libvisual wiki
Contents |
[edit]
libvisual-cpp
[edit]
Release Status
libvisual-cpp is still in development. A stable release is expected to be available by the end of this year.
In the meantime, you may download libvisual-cpp from CVS.
[edit]
Developers
- Chong Kai Xiong 'descender' (descender AT phreaker DOT net)
[edit]
Goals
In no particular order:
- Greater ease-of-use
- OOP with C++ class constructs
- Compile-time type safety
- Work well with the standard library and Boost
- Low overhead
- Little additional memory requirement
- Little additional function call overhead.
[edit]
Design and Implementation
Guiding Principles:
- no naked pointers
- references instead of pointers where possible
- const-correctness
[edit]
Naming
- All identifiers are placed under the Lv namespace.
- Overloading and templates are used to exclude type names from the C original function identifiers and facilitate generic programming.
[edit]
Enums
- All enums will have their own types
- All 6 bitwise operators (^, &, |, ^=, &=, |=) are overloaded for enum types that represent flags.
[edit]
Strings
- All C null-terminated string arguments will be wrapped using std::string.
[edit]
Functions
- Function call overhead of trivial function wrappers is avoided by inlining.
[edit]
Callbacks
- Callback function parameters are wrapped with functors so that any of the 2 types of functions may be passed:
- non-static member functions
- static member functions, free functions
- For convenience, arguments and return values may be bound to functors.
- Functor adaptors for accepting extra arguments that underlying function do not use or know.
[edit]
Error Handling
- Wrap all(?) errors in C++ exception classes.
- Exception classes derived from appropriate standard exceptions i.e. std::runtime_error for run-time errors, std::invalid_argument for invalid arguments and so on.
- Macro to switch between error handling options based on a #define. Options include:
- Throwing exceptions
- Returning error values
- Terminate
[edit]
Reference Counting
- Reference counting is automatically performed using copy constructors, assignment operators and destructors.
[edit]
OOP
- Mirror VisObject object hierarchy with equivalent C++ class hierarchy.
[edit]
Collections
- VisCollection-based types will be created with:
- Template specialization: typedef Lv::Collection<MyObject> MyObjectCollection;
- Subclassing i.e. deriving from Lv::AbstractCollection.
- Ditto for VisList or VisHashMap based types.
- std::list<>-style interface for VisList
- std::tr1::unordered_map<>-style interface for VisHashMap.
- std::list<>, std::tr1::unordered_map<> combined style interface for VisHashlist.
[edit]
Multithreading
- Helper objects to acquire and release lock when scope is exited.
- Helper object to log lock acquisition and release.

