-
Notifications
You must be signed in to change notification settings - Fork 464
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
Refactor C API for more robust ABI #635
Conversation
I haven't taken a proper look at the new API yet, but I just built lua-sass against this branch (still using the old API) and it builds and passes the tests fine. |
bind("function " + c->name(), params, args, ctx, &new_env, this); | ||
} else { | ||
String_Constant *str = new (ctx.mem) String_Constant(c->path(), c->position(), c->name()); | ||
*args << new (ctx.mem) Argument(c->path(), c->position(), str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the function name ends up as the last argument, right? Could you create a new Arguments
with the function name and +=
the original arguments? (I'm assuming you really wanted the function name first from your other comment.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really tried, but I couldn't figure out how I could do it. Underlying it is a Vectorized Object and only the <<
operator seems overloaded. I tried to access the vector directly to insert it, but there is too much magick going on there. IMO it would feel more natural to prepend the original function name, but adding it to the end is also working (just feels a bit bad). Maybe I'll give it a shot again later!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but I don't see the <<
being overloaded by the Arguments
class. I do see <<
in Vectorized
, but there's also +=
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguments extends Vectorized which overloads <<
On 10 Nov 2014 12:38, "Elliott Sales de Andrade" [email protected]
wrote:
In eval.cpp:
@@ -381,8 +407,13 @@ namespace Sass {
}
// else if it's a user-defined c function
else if (c_func) {
if (full_name != "*[f]") {
bind("function " + c->name(), params, args, ctx, &new_env, this);
} else {
String_Constant *str = new (ctx.mem) String_Constant(c->path(), c->position(), c->name());
*args << new (ctx.mem) Argument(c->path(), c->position(), str);
Maybe I'm missing something, but I don't see the << being overloaded by
the Arguments class. I do see << in Vectorized, but there's also +=.—
Reply to this email directly or view it on GitHub
https://github.com/sass/libsass/pull/635/files#r20064005.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, figured it out, I did not find a way to prepend to an existing Arguments list, but I was able to create a new one with first adding the name and then appending the rest of the arguments:
Arguments* new_args = new (ctx.mem) Arguments(c->path(), c->position());
*new_args << new (ctx.mem) Argument(c->path(), c->position(), str);
*new_args += args;
args = new_args;
Thanks @craigbarnes for trying it out. Good news it is still working with the old interface! |
fa1d4c2
to
44bac1c
Compare
By the way, the commit with the custom import overloading also slipped through. |
{ | ||
while (descrs->signature && descrs->function) { | ||
while (descrs && (*descrs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parens are unnecessary, BTW. *
is nearly highest priority, and &&
is practically the lowest.
d885fcb
to
6cb2122
Compare
Had some time to merge and clean-up the commit history! |
By the way, I've updated |
b1e6442
to
208d085
Compare
Seems like there is always something than can be further improved :) |
650f68b
to
c96db76
Compare
d0d37d8
to
12e523b
Compare
This allows to query include files before the compile step!
We do not want to force implementers to need json parsing functionality, just to get the extended error information.
We may not know how long these strings will live, therefore we pay to price to create copies of them. We only let users pass potentially very big char arrays directly to libsass!
1ca88d0
to
bcbfe20
Compare
Remove sass_interface header from libtool (use context.h)
Since nobody spoke up, I guess I can merge this, in about one hour!? |
Refactor C API for more robust ABI
NOOOO!!!!! (just kidding) |
This is awesome! @mgreter have a beer on me @changetip |
Hi mgreter, drewwells sent you a Bitcoin tip worth a beer (9,332 bits/$3.49), and I'm here to deliver it ➔ collect your tip at ChangeTip.com. |
latest libsass, fixing x64 problem
@mgreter, unrelated question: does it throw segfault if we pass non-existing files path as |
No, of course it will not segfault under that condition. And it should do exactly the same thing as with normal imports if you pass it only a file path. It will not try to load it if you also pass some content with it, then it is IMO only used for source-map path generating. |
I mean with the normal For example with my node-sass master branch (with doesn't have importer code), this code: require("./").render({
file: "C:/temp/alpha/index2.scss",
success: function (css,map) { console.log("css: " + css); console.log("map: " + map) },
error: function (err) { console.log("err: " + JSON.stringify(err)) },
}) terminates the node console, because |
Hmm, seems like you found the first bug in the new API since I merged it. |
Impressive! Thanks for the quick fix!! 😄 👍 I will try it later, right now I am working on a different computer. |
@mgreter, with node-sass' However, this is still debatable; whether or not it should prioritize data over file in case of sass_file_context (as its ctor takes input_path). From one view-point, In my opinion, we should just have one context, which may tolerate
Where enum sass_context_input_method
{
FILE,
DATA,
}; Or maybe, for sake of brevity; just use a c99 bool: Thoughts? |
Hmm, in case of |
My bad: actually it is our script which is doing things. We have three methods: renderSync, renderFileSync and renderFile, which makes to file and data contexts. We will be making a lot of breaking changes for node.js v2. Given the current state of matters, having two separate classes doesn't make much sense, since the new API is now streamlined. I think file vs. data can be unified and more configuration options can be introduced later. :) |
The C Interace was never really well defined or documented!
There is a very long standing issue open for libsass to improve this.
sass_context.h
Sass_C_Function
,Sass_Value
andSass_Context
in their own code files. This means we also have more (system) header files than before, but IMO that doesn't really matter.sass_interface.h
for the old;sass_context.h
for the newsass2scss.h
Sass_Value
andSass_C_Function
Sass_C_Function_List
andSass_C_Function_Callback
Added a documentation wiki page to my local repo!
Since the introduction of autotools build we also can create a
libtool
system library!There are also three other features implemented in this PR:
*
)@warn
) (Way to capture Warnings #539)I know these should probably go in their own PR, but hadn't had time to do it.
If this is a problem I can remove the commits from this PR!
Since it is a pretty big change, I really would like to see some thumbs up before merging it!