-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6e8058
commit 57a1e37
Showing
10 changed files
with
1,041 additions
and
94 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
authors = ["Devon Govett <devongovett@gmail.com>"] | ||
name = "parcel_css_c_bindings" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
parcel_css = { path = "../", features = ["browserslist"] } | ||
parcel_sourcemap = { version = "2.1.0", features = ["json"] } | ||
browserslist-rs = { version = "0.7.0" } | ||
|
||
[build-dependencies] | ||
cbindgen = "0.24.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate cbindgen; | ||
|
||
use std::env; | ||
|
||
fn main() { | ||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
|
||
cbindgen::generate(crate_dir) | ||
.expect("Unable to generate bindings") | ||
.write_to_file("parcel_css.h"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language = "C" | ||
|
||
[parse] | ||
parse_deps = true | ||
include = ["parcel_css"] | ||
|
||
[export.rename] | ||
StyleSheetWrapper = "StyleSheet" | ||
|
||
[enum] | ||
prefix_with_name = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct CssError CssError; | ||
|
||
typedef struct StyleSheet StyleSheet; | ||
|
||
typedef struct Targets { | ||
uint32_t android; | ||
uint32_t chrome; | ||
uint32_t edge; | ||
uint32_t firefox; | ||
uint32_t ie; | ||
uint32_t ios_saf; | ||
uint32_t opera; | ||
uint32_t safari; | ||
uint32_t samsung; | ||
} Targets; | ||
|
||
typedef struct ParseOptions { | ||
const char *filename; | ||
bool nesting; | ||
bool custom_media; | ||
bool css_modules; | ||
const char *css_modules_pattern; | ||
bool css_modules_dashed_idents; | ||
bool error_recovery; | ||
} ParseOptions; | ||
|
||
typedef struct TransformOptions { | ||
struct Targets targets; | ||
char **unused_symbols; | ||
uintptr_t unused_symbols_len; | ||
} TransformOptions; | ||
|
||
typedef struct RawString { | ||
char *text; | ||
uintptr_t len; | ||
} RawString; | ||
|
||
typedef enum CssModuleReference_Tag { | ||
/** | ||
* A local reference. | ||
*/ | ||
CssModuleReference_Local, | ||
/** | ||
* A global reference. | ||
*/ | ||
CssModuleReference_Global, | ||
/** | ||
* A reference to an export in a different file. | ||
*/ | ||
CssModuleReference_Dependency, | ||
} CssModuleReference_Tag; | ||
|
||
typedef struct CssModuleReference_Local_Body { | ||
/** | ||
* The local (compiled) name for the reference. | ||
*/ | ||
struct RawString name; | ||
} CssModuleReference_Local_Body; | ||
|
||
typedef struct CssModuleReference_Global_Body { | ||
/** | ||
* The referenced global name. | ||
*/ | ||
struct RawString name; | ||
} CssModuleReference_Global_Body; | ||
|
||
typedef struct CssModuleReference_Dependency_Body { | ||
/** | ||
* The name to reference within the dependency. | ||
*/ | ||
struct RawString name; | ||
/** | ||
* The dependency specifier for the referenced file. | ||
*/ | ||
struct RawString specifier; | ||
} CssModuleReference_Dependency_Body; | ||
|
||
typedef struct CssModuleReference { | ||
CssModuleReference_Tag tag; | ||
union { | ||
CssModuleReference_Local_Body local; | ||
CssModuleReference_Global_Body global; | ||
CssModuleReference_Dependency_Body dependency; | ||
}; | ||
} CssModuleReference; | ||
|
||
typedef struct CssModuleExport { | ||
struct RawString exported; | ||
struct RawString local; | ||
bool is_referenced; | ||
struct CssModuleReference *composes; | ||
uintptr_t composes_len; | ||
} CssModuleExport; | ||
|
||
typedef struct CssModulePlaceholder { | ||
struct RawString placeholder; | ||
struct CssModuleReference reference; | ||
} CssModulePlaceholder; | ||
|
||
typedef struct ToCssResult { | ||
struct RawString code; | ||
struct RawString map; | ||
struct CssModuleExport *exports; | ||
uintptr_t exports_len; | ||
struct CssModulePlaceholder *references; | ||
uintptr_t references_len; | ||
} ToCssResult; | ||
|
||
typedef struct PseudoClasses { | ||
const char *hover; | ||
const char *active; | ||
const char *focus; | ||
const char *focus_visible; | ||
const char *focus_within; | ||
} PseudoClasses; | ||
|
||
typedef struct ToCssOptions { | ||
bool minify; | ||
bool source_map; | ||
const char *input_source_map; | ||
uintptr_t input_source_map_len; | ||
struct Targets targets; | ||
bool analyze_dependencies; | ||
struct PseudoClasses pseudo_classes; | ||
} ToCssOptions; | ||
|
||
bool parcel_css_browserslist_to_targets(const char *query, | ||
struct Targets *targets, | ||
struct CssError **error); | ||
|
||
struct StyleSheet *parcel_css_stylesheet_parse(const char *source, | ||
uintptr_t len, | ||
struct ParseOptions options, | ||
struct CssError **error); | ||
|
||
bool parcel_css_stylesheet_transform(struct StyleSheet *stylesheet, | ||
struct TransformOptions options, | ||
struct CssError **error); | ||
|
||
struct ToCssResult parcel_css_stylesheet_to_css(struct StyleSheet *stylesheet, | ||
struct ToCssOptions options, | ||
struct CssError **error); | ||
|
||
void parcel_css_stylesheet_free(struct StyleSheet *stylesheet); | ||
|
||
void parcel_css_to_css_result_free(struct ToCssResult result); | ||
|
||
const char *parcel_css_error_message(struct CssError *error); | ||
|
||
void parcel_css_error_free(struct CssError *error); | ||
|
||
uintptr_t parcel_css_stylesheet_get_warning_count(struct StyleSheet *stylesheet); | ||
|
||
const char *parcel_css_stylesheet_get_warning(struct StyleSheet *stylesheet, uintptr_t index); |
Oops, something went wrong.