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

Commit

Permalink
Big update. Changed architecture. Added Declaration, Property, Values
Browse files Browse the repository at this point in the history
  • Loading branch information
lexborisov committed Aug 10, 2016
1 parent 91c2946 commit 33cedeb
Show file tree
Hide file tree
Showing 119 changed files with 6,584 additions and 3,152 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ clone: create
cp $(SRCDIR)/*.h include/mycss
cp $(SRCDIR)/selectors/*.h include/mycss/selectors
cp $(SRCDIR)/namespace/*.h include/mycss/namespace
cp $(SRCDIR)/rules/*.h include/mycss/rules
cp $(SRCDIR)/media/*.h include/mycss/media
cp $(SRCDIR)/property/*.h include/mycss/property
cp $(SRCDIR)/values/*.h include/mycss/values
cp $(SRCDIR)/declaration/*.h include/mycss/declaration
find include -name "*.h" -exec sed -i '.bak' -E 's/^[ \t]*#[ \t]*include[ \t]*"([^"]+)"/#include <\1>/g' {} \;
find include -name "*.h.bak" -exec rm -f {} \;

create:
mkdir -p bin lib include/mycss
mkdir -p bin lib include/mycss/selectors
mkdir -p bin lib include/mycss/namespace
mkdir -p bin lib include/mycss/rules
mkdir -p bin lib include/mycss/media
mkdir -p bin lib include/mycss/property
mkdir -p bin lib include/mycss/values
mkdir -p bin lib include/mycss/declaration

.PHONY:all clean test
23 changes: 13 additions & 10 deletions include/mycss/an_plus_b.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ extern "C" {
#include <mycss/entry.h>
#include <mycss/selectors/list.h>

#define mycss_an_plus_b_current_entry(entry) (*entry->anb->entry)

struct mycss_an_plus_b {
mycss_an_plus_b_entry_t* anb_entry;
mycss_an_plus_b_entry_t** entry;
};

struct mycss_an_plus_b_entry {
Expand All @@ -47,19 +49,20 @@ mycss_status_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb
mycss_status_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb);
mycss_an_plus_b_t * mycss_an_plus_b_destroy(mycss_an_plus_b_t* anb, bool self_destroy);

bool mycss_an_plus_b_state_token_all(mycss_entry_t* entry, mycss_token_t* token);
bool mycss_an_plus_b_state_token_skip_whitespace(mycss_entry_t* entry, mycss_token_t* token);
bool mycss_an_plus_b_state_skip_all(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
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_parser_expectations_error(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
void mycss_an_plus_b_parser_expectations_error(mycss_entry_t* entry);

bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
bool mycss_an_plus_b_state_anb_plus(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
bool mycss_an_plus_b_state_anb_plus_n_hyphen(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
bool mycss_an_plus_b_state_anb_plus_n(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
bool mycss_an_plus_b_state_anb_plus_n_plus(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
bool mycss_an_plus_b_state_anb_begin(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_an_plus_b_state_anb_plus(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_an_plus_b_state_anb_plus_n_hyphen(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_an_plus_b_state_anb_plus_n(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_an_plus_b_state_anb_plus_n_plus(mycss_entry_t* entry, mycss_token_t* token, bool last_response);

#ifdef __cplusplus
} /* extern "C" */
Expand Down
16 changes: 13 additions & 3 deletions include/mycss/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,25 @@ enum mycss_status {
MyCSS_STATUS_ERROR_SELECTORS_ENTRIES_CREATE = 0x010101,
MyCSS_STATUS_ERROR_SELECTORS_ENTRIES_INIT = 0x010102,
MyCSS_STATUS_ERROR_SELECTORS_ENTRIES_NODE_ADD = 0x010103,
MyCSS_STATUS_ERROR_SELECTORS_LIST_CREATE = 0x010104,
MyCSS_STATUS_ERROR_SELECTORS_LIST_INIT = 0x010105,
MyCSS_STATUS_ERROR_SELECTORS_LIST_ADD_NODE = 0x010106,
MyCSS_STATUS_ERROR_NAMESPACE_CREATE = 0x010200,
MyCSS_STATUS_ERROR_NAMESPACE_INIT = 0x010201,
MyCSS_STATUS_ERROR_NAMESPACE_ENTRIES_CREATE = 0x010202,
MyCSS_STATUS_ERROR_NAMESPACE_ENTRIES_INIT = 0x010203,
MyCSS_STATUS_ERROR_NAMESPACE_NODE_ADD = 0x010204,
MyCSS_STATUS_ERROR_RULES_CREATE = 0x010400,
MyCSS_STATUS_ERROR_MEDIA_CREATE = 0x010404,
MyCSS_STATUS_ERROR_STRING_CREATE = 0x010501,
MyCSS_STATUS_ERROR_STRING_INIT = 0x010502,
MyCSS_STATUS_ERROR_STRING_NODE_INIT = 0x010503,
MyCSS_STATUS_ERROR_AN_PLUS_B_CREATE = 0x010600,
MyCSS_STATUS_ERROR_AN_PLUS_B_INIT = 0x010601
MyCSS_STATUS_ERROR_AN_PLUS_B_INIT = 0x010601,
MyCSS_STATUS_ERROR_DECLARATION_CREATE = 0x010700,
MyCSS_STATUS_ERROR_DECLARATION_INIT = 0x010701,
MyCSS_STATUS_ERROR_DECLARATION_ENTRY_CREATE = 0x010702,
MyCSS_STATUS_ERROR_DECLARATION_ENTRY_INIT = 0x010703,
MyCSS_STATUS_ERROR_PARSER_LIST_CREATE = 0x010800
}
typedef mycss_status_t;

Expand Down Expand Up @@ -127,7 +135,9 @@ enum mycss_token_type {
MyCSS_TOKEN_TYPE_RIGHT_CURLY_BRACKET = 0x001d,
MyCSS_TOKEN_TYPE_BAD_URL = 0x001e,
MyCSS_TOKEN_TYPE_COMMENT = 0x001f,
MyCSS_TOKEN_TYPE_UNICODE_RANGE = 0x0020
MyCSS_TOKEN_TYPE_UNICODE_RANGE = 0x0020,
MyCSS_TOKEN_TYPE_EOF = 0x0021,
MyCSS_TOKEN_TYPE_LAST_ENTRY = 0x0022
}
typedef mycss_token_type_t;

Expand Down
53 changes: 53 additions & 0 deletions include/mycss/declaration/entry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
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_ENTRY_H
#define MyHTML_MyCSS_DECLARATION_ENTRY_H
#pragma once

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

#ifdef __cplusplus
extern "C" {
#endif

mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_destroy(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);

mycss_declaration_entry_t * mycss_declaration_entry(mycss_declaration_t* declaration);
mycss_declaration_entry_t * mycss_declaration_entry_last(mycss_declaration_t* declaration);

void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);
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

#endif /* MyHTML_MyCSS_DECLARATION_ENTRY_H */

55 changes: 55 additions & 0 deletions include/mycss/declaration/init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
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_INIT_H
#define MyHTML_MyCSS_DECLARATION_INIT_H
#pragma once

#include <mycss/declaration/myosi.h>
#include <mycss/entry.h>

#ifdef __cplusplus
extern "C" {
#endif

mycss_declaration_t * mycss_declaration_create(void);
mycss_status_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration);
void mycss_declaration_clean_all(mycss_declaration_t* declaration);
void mycss_declaration_clean(mycss_declaration_t* declaration);
mycss_declaration_t * mycss_declaration_destroy(mycss_declaration_t* declaration, bool self_destroy);

mycss_declaration_entry_t * mycss_declaration_entry(mycss_declaration_t* declaration);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);

mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);

mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);

mycss_token_type_t mycss_declaration_ending_token_type(mycss_declaration_t* declaration);
void mycss_declaration_ending_token_type_set(mycss_declaration_t* declaration, mycss_token_type_t ending_token_type);

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

#endif /* MyHTML_MyCSS_DECLARATION_INIT_H */

75 changes: 75 additions & 0 deletions include/mycss/declaration/myosi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
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_MYOSI_H
#define MyHTML_MyCSS_DECLARATION_MYOSI_H
#pragma once

#include <mycss/myosi.h>
#include <mycss/values/units.h>
#include <mycss/property/myosi.h>
#include <myhtml/utils/mcobject.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct mycss_declaration_entry mycss_declaration_entry_t;
typedef struct mycss_declaration mycss_declaration_t;

typedef void (*mycss_callback_declaration_destroy_f)(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry);

enum mycss_declaration_flags {
MyCSS_DECLARATION_FLAGS_UNDEF = 0x00,
MyCSS_DECLARATION_FLAGS_BAD = 0x01
}
typedef mycss_declaration_flags_t;

struct mycss_declaration {
mycss_entry_t* ref_entry;

mycss_declaration_entry_t** entry;
mycss_declaration_entry_t* entry_last;

mycss_token_type_t ending_token;

mcobject_t* mcobject_entries; /* for a dec entries */
mcobject_t* mcobject_list; /* for a dec list */
};

struct mycss_declaration_entry {
mycss_property_type_t type;

unsigned int value_type;
void* value;

bool is_important;
mycss_declaration_flags_t flags;

mycss_declaration_entry_t* next;
mycss_declaration_entry_t* prev;
};


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

#endif /* MyHTML_MyCSS_DECLARATION_MYOSI_H */
19 changes: 10 additions & 9 deletions source/mycss/rules/init.h → include/mycss/declaration/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@
Author: [email protected] (Alexander Borisov)
*/

#ifndef MyHTML_MyCSS_RULES_INIT_H
#define MyHTML_MyCSS_RULES_INIT_H
#ifndef MyHTML_MyCSS_DECLARATION_PARSER_H
#define MyHTML_MyCSS_DECLARATION_PARSER_H
#pragma once

#include "mycss/rules/myosi.h"

#ifdef __cplusplus
extern "C" {
#endif

mycss_rules_t * mycss_rules_create(void);
mycss_status_t mycss_rules_init(mycss_entry_t* entry, mycss_rules_t* rules);
mycss_status_t mycss_rules_clean_all(mycss_rules_t* rules);
mycss_rules_t * mycss_rules_destroy(mycss_rules_t* rules, bool self_destroy);
#include <mycss/entry.h>
#include <mycss/property/init.h>
#include <mycss/declaration/entry.h>

void mycss_declaration_parser_begin(mycss_entry_t* entry, mycss_token_t* token);
void mycss_declaration_parser_ident(mycss_entry_t* entry, mycss_token_t* token);


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

#endif /* MyHTML_MyCSS_RULES_INIT_H */
#endif /* MyHTML_MyCSS_DECLARATION_PARSER_H */
47 changes: 47 additions & 0 deletions include/mycss/declaration/state.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
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_DECLARATION_H
#define MyHTML_MyCSS_DECLARATION_DECLARATION_H
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <mycss/entry.h>
#include <mycss/declaration/parser.h>

bool mycss_declaration_state_begin(mycss_entry_t* entry, mycss_token_t* token, bool last_response);

bool mycss_declaration_state_data(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_ident(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_colon_before_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_colon_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_colon_delim_after_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_find_ending(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_parse_error(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_declaration_state_drop_component_value(mycss_entry_t* entry, mycss_token_t* token, bool last_response);

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

#endif /* MyHTML_MyCSS_DECLARATION_DECLARATION_H */
Loading

0 comments on commit 33cedeb

Please sign in to comment.