Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions float-pigment-css-macro/src/style_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,13 +894,13 @@ impl ToTokens for StyleSyntaxDefinition {
writeln!(&mut style_doc, "| ---- | ---- | ---- |").unwrap();
let table_list_a = supported_properties
.iter()
.filter(|x| !x.name.as_ref().unwrap().starts_with("-"));
.filter(|x| !x.name.as_ref().unwrap().starts_with('-'));
let table_list_b = supported_properties
.iter()
.filter(|x| x.name.as_ref().unwrap().starts_with("-"));
.filter(|x| x.name.as_ref().unwrap().starts_with('-'));
for x in table_list_a.chain(table_list_b) {
let name = x.name.as_ref().unwrap();
let non_standard = name.starts_with("-");
let non_standard = name.starts_with('-');
let name_col = if non_standard {
format!("*`{}`*", name)
} else {
Expand Down
208 changes: 116 additions & 92 deletions float-pigment-css/float_pigment_css.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ enum class ContainKeyword {
Paint,
};

enum class FfiErrorCode {
None,
ThisNullPointer,
PathNullPointer,
PrefixNullPointer,
SourceNullPointer,
BufferNullPointer,
ExprPtrNullPointer,
StrNullPointer,
InlineStyleTextNullPointer,
InlineRuleNullPointer,
StyleTextNullPointer,
SelectorTextNullPointer,
InvalidPath,
JsonNullPointer,
ArrayNullPointer,
SelectorNullPointer,
StyleSheetNullPointer,
MapNullPointer,
Unknown,
};

enum class FontDisplay {
Auto,
Block,
Expand Down Expand Up @@ -265,6 +287,14 @@ enum class WarningKind : uint32_t {
InvalidEnvDefaultValue,
};

using NullPtr = const void*;

template<typename T>
struct FfiResult {
T value;
FfiErrorCode err;
};

struct StrRef {
size_t offset;
size_t len;
Expand All @@ -286,10 +316,6 @@ struct Warning {
uint32_t end_col;
};

struct CParserHooksContext {
void *inner;
};

template<typename T>
struct Box {
T *ptr;
Expand Down Expand Up @@ -9007,143 +9033,141 @@ struct StyleSheet {
};
};

struct StyleSheetImportIndexPtr {
void *ptr;
void *map;
};
using RawMutPtr = void*;

struct StyleSheetResourcePtr {
void *ptr;
struct CParserHooksContext {
void *inner;
};

struct CParserHooks {
void (*parsed_property)(CParserHooksContext, Property*);
};

using CustomPropertyGetter = const char*(*)(void *map, const char *name);

using CustomPropertySetter = void(*)(void *map, const char *name, const char *value);


extern "C" {

void array_str_ref_free(Array<StrRef> *x);
FfiResult<NullPtr> FPArrayStrRefFree(Array<StrRef> *x);

void array_warning_free(Array<Warning> *warnings);
FfiResult<NullPtr> FPArrayWarningFree(Array<Warning> *warnings);

void buffer_free(uint8_t *buffer_ptr, size_t buffer_len);
FfiResult<NullPtr> FPBufferFree(uint8_t *buffer_ptr, size_t buffer_len);

StrRef *css_parser_version();
FfiResult<StrRef*> FPCssParserVersion();

void generate_warning(CParserHooksContext *self, const char *message);
FfiResult<NullPtr> FPInlineStyleFree(InlineRule *inline_rule);

void inline_style_free(InlineRule *inline_rule);
FfiResult<ColorValue> FPParseColorFromString(const char *source);

ColorValue parse_color_from_string(const char *source);
FfiResult<InlineRule*> FPParseInlineStyle(const char *inline_style_text_ptr,
Array<Warning> **warnings);

InlineRule *parse_inline_style(const char *inline_style_text_ptr, Array<Warning> **warnings);
FfiResult<Selector*> FPParseSelectorFromString(const char *selector_text_ptr);

Selector *parse_selector_from_string(const char *selector_text_ptr);
FfiResult<StyleSheet*> FPParseStyleSheetFromString(const char *style_text_ptr);

StyleSheet *parse_style_sheet_from_string(const char *style_text_ptr);
FfiResult<NullPtr> FPSelectorFree(Selector *selector);

void selector_free(Selector *selector);
FfiResult<NullPtr> FPStrFree(const char *ptr);

void str_free(const char *ptr);
FfiResult<StrRef*> FPStyleSheetBincodeVersion(uint8_t *buffer_ptr, size_t buffer_len);

size_t str_len(const StrRef *self);
FfiResult<NullPtr> FPStyleSheetFree(StyleSheet *style_sheet);

const uint8_t *str_ptr(const StrRef *self);
FfiResult<NullPtr> FPStyleSheetImportIndexAddBincode(RawMutPtr this_,
const char *path,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(RawMutPtr),
RawMutPtr drop_args,
Array<Warning> **warnings);

StrRef *style_sheet_bincode_version(uint8_t *buffer_ptr, size_t buffer_len);
FfiResult<RawMutPtr> FPStyleSheetImportIndexDeserializeBincode(uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(RawMutPtr),
RawMutPtr drop_args);

void style_sheet_free(StyleSheet *style_sheet);
FfiResult<RawMutPtr> FPStyleSheetImportIndexDeserializeJson(const char *json);

void style_sheet_import_index_add_bincode(StyleSheetImportIndexPtr *this_,
const char *path,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(void*),
void *drop_args,
Array<Warning> **warnings);
FfiResult<NullPtr> FPStyleSheetImportIndexFree(RawMutPtr this_);

StyleSheetImportIndexPtr style_sheet_import_index_deserialize_bincode(uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(void*),
void *drop_args);
FfiResult<StyleSheet*> FPStyleSheetImportIndexGetStyleSheet(RawMutPtr this_, const char *path);

StyleSheetImportIndexPtr style_sheet_import_index_deserialize_json(const char *json);
FfiResult<Array<StrRef>*> FPStyleSheetImportIndexListDependencies(RawMutPtr this_,
const char *path);

void style_sheet_import_index_free(StyleSheetImportIndexPtr *this_);
FfiResult<Array<StrRef>*> FPStyleSheetImportIndexListDependency(RawMutPtr this_, const char *path);

StyleSheet *style_sheet_import_index_get_style_sheet(StyleSheetImportIndexPtr *this_,
const StrRef *path);
FfiResult<NullPtr> FPStyleSheetImportIndexMergeBincode(RawMutPtr this_,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(void*),
void *drop_args);

Array<StrRef> *style_sheet_import_index_list_dependencies(StyleSheetImportIndexPtr *this_,
const char *path);
FfiResult<RawMutPtr> FPStyleSheetImportIndexNew();

Array<StrRef> *style_sheet_import_index_list_dependency(StyleSheetImportIndexPtr *this_,
const char *path);
FfiResult<Array<StrRef>*> FPStyleSheetImportIndexQueryAndMarkDependencies(RawMutPtr this_,
const char *path);

void style_sheet_import_index_merge_bincode(StyleSheetImportIndexPtr *this_,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(void*),
void *drop_args);
FfiResult<NullPtr> FPStyleSheetImportIndexRemoveBincode(RawMutPtr this_, const char *path);

StyleSheetImportIndexPtr style_sheet_import_index_new();
FfiResult<uint8_t*> FPStyleSheetImportIndexSerializeBincode(RawMutPtr this_,
size_t *ret_buffer_len);

Array<StrRef> *style_sheet_import_index_query_and_mark_dependencies(StyleSheetImportIndexPtr *this_,
const char *path);
FfiResult<uint8_t*> FPStyleSheetImportIndexSerializeJson(RawMutPtr this_, size_t *ret_buffer_len);

void style_sheet_import_index_remove_bincode(StyleSheetImportIndexPtr *this_, const char *path);
FfiResult<NullPtr> FPStyleSheetResourceAddBincode(RawMutPtr this_,
const char *path,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(RawMutPtr),
RawMutPtr drop_args,
Array<Warning> **warnings);

uint8_t *style_sheet_import_index_serialize_bincode(StyleSheetImportIndexPtr *this_,
size_t *ret_buffer_len);
FfiResult<NullPtr> FPStyleSheetResourceAddSource(RawMutPtr this_,
const char *path,
const char *source,
Array<Warning> **warnings);

uint8_t *style_sheet_import_index_serialize_json(StyleSheetImportIndexPtr *this_,
size_t *ret_buffer_len);
FfiResult<NullPtr> FPStyleSheetResourceAddSourceWithHooks(RawMutPtr this_,
CParserHooks hooks,
const char *path,
const char *source,
Array<Warning> **warnings);

void style_sheet_resource_add_bincode(StyleSheetResourcePtr *this_,
const char *path,
uint8_t *buffer_ptr,
size_t buffer_len,
void (*drop_fn)(void*),
void *drop_args,
Array<Warning> **warnings);
FfiResult<NullPtr> FPStyleSheetResourceAddTagNamePrefix(RawMutPtr this_,
const char *path,
const char *prefix);

void style_sheet_resource_add_source(StyleSheetResourcePtr *this_,
const char *path,
const char *source,
Array<Warning> **warnings);
FfiResult<Array<StrRef>*> FPStyleSheetResourceDirectDependencies(RawMutPtr this_, const char *path);

void style_sheet_resource_add_source_with_hooks(StyleSheetResourcePtr *this_,
CParserHooks hooks,
const char *path,
const char *source,
Array<Warning> **warnings);
FfiResult<NullPtr> FPStyleSheetResourceFree(RawMutPtr this_);

void style_sheet_resource_add_tag_name_prefix(StyleSheetResourcePtr *this_,
const char *path,
const char *prefix);
FfiResult<RawMutPtr> FPStyleSheetResourceGenerateImportIndex(RawMutPtr this_);

Array<StrRef> *style_sheet_resource_direct_dependencies(StyleSheetResourcePtr *this_,
const char *path);
FfiResult<RawMutPtr> FPStyleSheetResourceNew();

void style_sheet_resource_free(StyleSheetResourcePtr *this_);
FfiResult<uint8_t*> FPStyleSheetResourceSerializeBincode(RawMutPtr this_,
const char *path,
size_t *ret_buffer_len);

StyleSheetImportIndexPtr style_sheet_resource_generate_import_index(StyleSheetResourcePtr *this_);
FfiResult<uint8_t*> FPStyleSheetResourceSerializeJson(RawMutPtr this_,
const char *path,
size_t *ret_buffer_len);

StyleSheetResourcePtr style_sheet_resource_new();
FfiResult<const char*> FPSubstituteVariable(const char *expr_ptr,
RawMutPtr map,
CustomPropertyGetter getter,
CustomPropertySetter setter);

uint8_t *style_sheet_resource_serialize_bincode(StyleSheetResourcePtr *this_,
const char *path,
size_t *ret_buffer_len);
FfiResult<NullPtr> generate_warning(CParserHooksContext *self, const char *message);

uint8_t *style_sheet_resource_serialize_json(StyleSheetResourcePtr *this_,
const char *path,
size_t *ret_buffer_len);
size_t str_len(const StrRef *self);

const char *substitute_variable(const char *expr_ptr,
void *map,
CustomPropertyGetter getter,
CustomPropertySetter setter);
const uint8_t *str_ptr(const StrRef *self);

} // extern "C"

Expand Down
Loading