common: update bluelib api usage
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/object/string.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <ivy/selector.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -25,12 +25,12 @@ void ivy_selector_destroy(struct ivy_selector *sel)
|
||||
free(sel->sel_name);
|
||||
}
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_iterator_begin(&sel->sel_args, &it);
|
||||
while (b_queue_iterator_is_valid(&it)) {
|
||||
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||
while (entry) {
|
||||
struct ivy_selector_arg *arg
|
||||
= b_unbox(struct ivy_selector_arg, it.entry, arg_entry);
|
||||
b_queue_iterator_erase(&it);
|
||||
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&sel->sel_args, entry);
|
||||
|
||||
if (arg->arg_label) {
|
||||
free(arg->arg_label);
|
||||
@@ -41,6 +41,8 @@ void ivy_selector_destroy(struct ivy_selector *sel)
|
||||
}
|
||||
|
||||
free(arg);
|
||||
|
||||
entry = next;
|
||||
}
|
||||
|
||||
free(sel);
|
||||
@@ -93,39 +95,43 @@ enum ivy_status ivy_selector_add_arg(
|
||||
|
||||
size_t ivy_selector_to_string(const struct ivy_selector *sel, char *out, size_t max)
|
||||
{
|
||||
b_stringstream str;
|
||||
b_stringstream_begin(&str, out, max);
|
||||
b_stringstream *str = b_stringstream_create_with_buffer(out, max);
|
||||
|
||||
switch (sel->sel_recipient) {
|
||||
case IVY_SEL_OBJECT:
|
||||
b_stringstream_add(&str, "-");
|
||||
b_stream_write_char(str, '-');
|
||||
break;
|
||||
case IVY_SEL_CLASS:
|
||||
b_stringstream_add(&str, "+");
|
||||
b_stream_write_char(str, '+');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sel->sel_name) {
|
||||
b_stringstream_add(&str, sel->sel_name);
|
||||
b_stream_write_string(str, sel->sel_name, NULL);
|
||||
}
|
||||
|
||||
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) {
|
||||
b_stringstream_add(&str, "(");
|
||||
b_stream_write_char(str, '(');
|
||||
}
|
||||
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &sel->sel_args) {
|
||||
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||
while (entry) {
|
||||
struct ivy_selector_arg *arg
|
||||
= b_unbox(struct ivy_selector_arg, it.entry, arg_entry);
|
||||
b_stringstream_addf(
|
||||
&str, "%s:", arg->arg_label ? arg->arg_label : "_");
|
||||
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
b_stream_write_fmt(
|
||||
str, NULL, "%s:", arg->arg_label ? arg->arg_label : "_");
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) {
|
||||
b_stringstream_add(&str, ")");
|
||||
b_stream_write_char(str, ')');
|
||||
}
|
||||
|
||||
return b_stringstream_get_length(&str);
|
||||
size_t len = b_stringstream_get_length(str);
|
||||
b_stringstream_unref(str);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user