Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Commit

Permalink
Added more properties; Added serialization; #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lexborisov committed Oct 13, 2016
1 parent 084d4b7 commit 5c8ba3e
Show file tree
Hide file tree
Showing 71 changed files with 12,662 additions and 675 deletions.
22 changes: 0 additions & 22 deletions .gitignore

This file was deleted.

9 changes: 7 additions & 2 deletions examples/css_low_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ struct res_data load_data_file(const char* filename)
return res;
}

void serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
}

int main(int argc, const char * argv[])
{
const char* path;
Expand Down Expand Up @@ -94,8 +99,8 @@ int main(int argc, const char * argv[])

/* print result */
printf("Result:\n");
mycss_namespace_print_stylesheet(&entry->stylesheet->ns_stylesheet, stdout);
mycss_stylesheet_print(entry->stylesheet, stdout);
mycss_namespace_serialization_stylesheet(&entry->stylesheet->ns_stylesheet, serialization_callback, NULL);
mycss_stylesheet_serialization(entry->stylesheet, serialization_callback, NULL);
printf("\n");

// destroy all
Expand Down
7 changes: 6 additions & 1 deletion examples/declaration_low_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <mycss/mycss.h>
#include <mycss/declaration/init.h>

void serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
}

int main(int argc, const char * argv[])
{
const char *declaration = "width : 100%; height: 1.2em";
Expand All @@ -51,7 +56,7 @@ int main(int argc, const char * argv[])

/* print result */
printf("Result:\n\t");
mycss_declaration_entries_print(entry->declaration, dec_entry, stdout);
mycss_declaration_serialization_entries(entry, dec_entry, serialization_callback, NULL);
printf("\n");

// destroy all
Expand Down
7 changes: 6 additions & 1 deletion examples/selectors_low_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <mycss/mycss.h>
#include <mycss/selectors/init.h>

void serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
}

int main(int argc, const char * argv[])
{
const char *selector = "#hash.class >> [class ~= bebebe]:has( :not( p:last-child ):nth-child(2n+1))";
Expand All @@ -50,7 +55,7 @@ int main(int argc, const char * argv[])

/* print result */
printf("Result:\n\t");
mycss_selectors_print_list(entry->selectors, list, stdout);
mycss_selectors_serialization_list(entry->selectors, list, serialization_callback, NULL);
printf("\n");

// destroy all
Expand Down
9 changes: 7 additions & 2 deletions examples/stylesheet_low_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

#include <mycss/mycss.h>

void serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
}

int main(int argc, const char * argv[])
{
const char *css =
Expand Down Expand Up @@ -52,8 +57,8 @@ body > div[id*=mu i]:not(:nth-child(2n+1)) {width: 1.4%}";

/* print result */
printf("Result:\n");
mycss_namespace_print_stylesheet(&entry->stylesheet->ns_stylesheet, stdout);
mycss_stylesheet_print(entry->stylesheet, stdout);
mycss_namespace_serialization_stylesheet(&entry->stylesheet->ns_stylesheet, serialization_callback, NULL);
mycss_stylesheet_serialization(entry->stylesheet, serialization_callback, NULL);
printf("\n");

// destroy all
Expand Down
2 changes: 1 addition & 1 deletion include/mycss/an_plus_b.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_create(mycss_entry_t* entry);
void mycss_an_plus_b_entry_clean_all(mycss_an_plus_b_entry_t* anb_entry);
mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_destroy(mycss_entry_t* entry, mycss_an_plus_b_entry_t* anb_entry, bool self_destroy);

void mycss_an_plus_b_print(mycss_an_plus_b_entry_t* anb_entry, FILE* fh);
void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_callback_serialization_f callback, void* context);

void mycss_an_plus_b_parser_expectations_error(mycss_entry_t* entry);

Expand Down
14 changes: 3 additions & 11 deletions include/mycss/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
*/

#define MyCSS_VERSION_MAJOR 0
#define MyCSS_VERSION_MINOR 1
#define MyCSS_VERSION_PATCH 1
#define MyCSS_VERSION_MINOR 0
#define MyCSS_VERSION_PATCH 9

#include <myhtml/api.h>

Expand All @@ -52,15 +52,7 @@ extern "C" {
// base
/*
Very important!!!
for myhtml 0..00ffff; MyHTML_STATUS_OK == 0x000000
for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
for myrender 030000..03ffff; MyRENDER_STATUS_OK == 0x000000
for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
not occupied 070000..
see modest/myosi.h:modest_status_tv
*/
enum mycss_status {
MyCSS_STATUS_OK = 0x000000,
Expand Down
3 changes: 0 additions & 3 deletions include/mycss/declaration/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration,
void mycss_declaration_entry_remove(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);
mycss_declaration_entry_t * mycss_declaration_entry_delete(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);

void mycss_declaration_entry_print(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry, FILE* fh);
void mycss_declaration_entries_print(mycss_declaration_t* declaration, mycss_declaration_entry_t* first_dec_entry, FILE* fh);

#ifdef __cplusplus
} /* extern "C" */
#endif
Expand Down
48 changes: 48 additions & 0 deletions include/mycss/declaration/serialization.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: [email protected] (Alexander Borisov)
*/

#ifndef MyHTML_MyCSS_DECLARATION_SERIALIZATION_H
#define MyHTML_MyCSS_DECLARATION_SERIALIZATION_H
#pragma once

#include <mycss/declaration/myosi.h>
#include <mycss/values/values.h>
#include <mycss/property/init.h>
#include <mycss/property/serialization.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef bool (*mycss_declaration_serialization_f)(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
mycss_callback_serialization_f callback, void* context);

bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycss_callback_serialization_f callback, void* context);

bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_padding(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_padding_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* MyHTML_MyCSS_DECLARATION_SERIALIZATION_H */
Loading

0 comments on commit 5c8ba3e

Please sign in to comment.