Skip to content
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

Expose the extensions module header file #59

Open
wants to merge 15 commits into
base: gfm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
properly mark all exported functions as exported
rdar://108675358
  • Loading branch information
QuietMisdreavus committed May 3, 2023
commit 79688d4ab6df0e37609e545b86b38c3b985e9d12
3 changes: 1 addition & 2 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (CMARK_SHARED)

set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
DEFINE_SYMBOL "cmark-gfm"
DEFINE_SYMBOL "libcmark_gfm_EXPORTS"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})

Expand All @@ -47,7 +47,6 @@ if (CMARK_STATIC)

set_target_properties(${STATICLIBRARY} PROPERTIES
COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE"
DEFINE_SYMBOL "cmark-gfm"
POSITION_INDEPENDENT_CODE ON)

if (MSVC)
Expand Down
1 change: 1 addition & 0 deletions extensions/core-extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static void register_plugins(void) {
cmark_register_plugin(core_extensions_registration);
}

CMARK_GFM_EXPORT
void cmark_gfm_core_extensions_ensure_registered(void) {
CMARK_RUN_ONCE(registered, register_plugins);
}
12 changes: 11 additions & 1 deletion extensions/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
if (!marker_row) {
return parent_container;
}

assert(marker_row);

cmark_arena_push();
Expand Down Expand Up @@ -1029,30 +1029,35 @@ cmark_syntax_extension *create_table_extension(void) {
return self;
}

CMARK_GFM_EXPORT
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

return ((node_table *)node->as.opaque)->n_columns;
}

CMARK_GFM_EXPORT
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

return ((node_table *)node->as.opaque)->alignments;
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns) {
return set_n_table_columns(node, n_columns);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments) {
uint8_t *a = (uint8_t *)cmark_node_mem(node)->calloc(1, ncols);
memcpy(a, alignments, ncols);
return set_table_alignments(node, a);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
Expand All @@ -1061,6 +1066,7 @@ int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node)
return ((node_table_row *)node->as.opaque)->is_header;
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
Expand All @@ -1070,21 +1076,25 @@ int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header
return 1;
}

CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_colspan(cmark_node *node)
{
return get_cell_colspan(node);
}

CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_rowspan(cmark_node *node)
{
return get_cell_rowspan(node);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_colspan(cmark_node *node, unsigned colspan)
{
return set_cell_colspan(node, colspan);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_rowspan(cmark_node *node, unsigned rowspan)
{
return set_cell_rowspan(node, rowspan);
Expand Down
2 changes: 2 additions & 0 deletions extensions/tasklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const char *get_type_string(cmark_syntax_extension *extension, cmark_node


// Return 1 if state was set, 0 otherwise
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked) {
// The node has to exist, and be an extension, and actually be the right type in order to get the value.
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
Expand All @@ -27,6 +28,7 @@ int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_che
return 1;
}

CMARK_GFM_EXPORT
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node) {
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
return false;
Expand Down