You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The actual structs will no longer be exposed. This has the following advantages:
It allows the internal structures to be modified, or fields added to them, without breaking the source or binary API.
It makes the API clearer about which fields are read only, and enforces this.
It (arguably) will allow for easier implementation of bindings to other languages, since there is no more dealing with C structs, just plain functions that take ordinary data types (int, char*)
While we're at it, I really don't like the method of using a single colon-separated string for the include_paths (especially given that one has to detect if the platform is windows and use a semi-colon instead). I think instead of this:
I realize that these changes will break existing code that uses libsass, but I believe that these changes would be a clear improvement, and better sooner than later, while libsass is still relatively young. Plus, this encapsulation will allow for future improvements and additions to the API without breaking code.
I am willing to write the code for these changes and submit a pull request.
The text was updated successfully, but these errors were encountered:
Sounds like a good idea in general ... just give me a few days to think about some of the specifics. It might be good to continue to make original C struct available (but mark it as deprecated) so that users don't have to change anything, and the API functions can either use a new struct type, or access the C++ classes directly.
How do you free the context with the new interface? The code says that the old interface already does this, so.... should I include both interfaces to use this feature?
I had to rename the free functions to delete to avoid name clashes with the old interface. To free the context you simply need to call sass_delete_file_context or sass_delete_data_context. You actually should never use both interfaces at the same time, since the data structures are not compatible.
I propose to encapsulate the structs in
sass_interface.h
behind an interface of getter and setter functions.For example, instead of doing:
One would instead do:
The actual structs will no longer be exposed. This has the following advantages:
While we're at it, I really don't like the method of using a single colon-separated string for the
include_paths
(especially given that one has to detect if the platform is windows and use a semi-colon instead). I think instead of this:The following is a lot cleaner:
I realize that these changes will break existing code that uses
libsass
, but I believe that these changes would be a clear improvement, and better sooner than later, whilelibsass
is still relatively young. Plus, this encapsulation will allow for future improvements and additions to the API without breaking code.I am willing to write the code for these changes and submit a pull request.
The text was updated successfully, but these errors were encountered: