123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- #include "synctex_parser.h"
- #include "synctex_parser_utils.h"
- #ifndef __SYNCTEX_PARSER_PRIVATE__
- # define __SYNCTEX_PARSER_PRIVATE__
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- typedef synctex_node_p synctex_non_null_node_p;
-
-
-
- enum {
- synctex_shift_root,
- synctex_shift_no_root,
- synctex_shift_void,
- synctex_shift_no_void,
- synctex_shift_box,
- synctex_shift_no_box,
- synctex_shift_proxy,
- synctex_shift_no_proxy,
- synctex_shift_h,
- synctex_shift_v
- };
- enum {
- synctex_mask_root = 1,
- synctex_mask_no_root = synctex_mask_root<<1,
- synctex_mask_void = synctex_mask_no_root<<1,
- synctex_mask_no_void = synctex_mask_void<<1,
- synctex_mask_box = synctex_mask_no_void<<1,
- synctex_mask_no_box = synctex_mask_box<<1,
- synctex_mask_proxy = synctex_mask_no_box<<1,
- synctex_mask_no_proxy = synctex_mask_proxy<<1,
- synctex_mask_h = synctex_mask_no_proxy<<1,
- synctex_mask_v = synctex_mask_h<<1,
- };
- enum {
- synctex_mask_non_void_hbox = synctex_mask_no_void
- | synctex_mask_box
- | synctex_mask_h,
- synctex_mask_non_void_vbox = synctex_mask_no_void
- | synctex_mask_box
- | synctex_mask_v
- };
- typedef enum {
- synctex_node_mask_sf =
- synctex_mask_root
- |synctex_mask_no_void
- |synctex_mask_no_box
- |synctex_mask_no_proxy,
- synctex_node_mask_vbox =
- synctex_mask_no_root
- |synctex_mask_no_void
- |synctex_mask_box
- |synctex_mask_no_proxy
- |synctex_mask_v,
- synctex_node_mask_hbox =
- synctex_mask_no_root
- |synctex_mask_no_void
- |synctex_mask_box
- |synctex_mask_no_proxy
- |synctex_mask_h,
- synctex_node_mask_void_vbox =
- synctex_mask_no_root
- |synctex_mask_void
- |synctex_mask_box
- |synctex_mask_no_proxy
- |synctex_mask_v,
- synctex_node_mask_void_hbox =
- synctex_mask_no_root
- |synctex_mask_void
- |synctex_mask_box
- |synctex_mask_no_proxy
- |synctex_mask_h,
- synctex_node_mask_vbox_proxy =
- synctex_mask_no_root
- |synctex_mask_no_void
- |synctex_mask_box
- |synctex_mask_proxy
- |synctex_mask_v,
- synctex_node_mask_hbox_proxy =
- synctex_mask_no_root
- |synctex_mask_no_void
- |synctex_mask_box
- |synctex_mask_proxy
- |synctex_mask_h,
- synctex_node_mask_nvnn =
- synctex_mask_no_root
- |synctex_mask_void
- |synctex_mask_no_box
- |synctex_mask_no_proxy,
- synctex_node_mask_input =
- synctex_mask_root
- |synctex_mask_void
- |synctex_mask_no_box
- |synctex_mask_no_proxy,
- synctex_node_mask_proxy =
- synctex_mask_no_root
- |synctex_mask_void
- |synctex_mask_no_box
- |synctex_mask_proxy
- } synctex_node_mask_t;
- enum {
-
- synctex_tree_sibling_idx = 0,
- synctex_tree_s_input_max = 1,
-
- synctex_tree_s_parent_idx = 1,
- synctex_tree_sp_child_idx = 2,
- synctex_tree_spc_friend_idx = 3,
- synctex_tree_spcf_last_idx = 4,
- synctex_tree_spcfl_vbox_max = 5,
-
- synctex_tree_spcfl_next_hbox_idx = 5,
- synctex_tree_spcfln_hbox_max = 6,
-
- synctex_tree_spcfln_target_idx = 6,
- synctex_tree_spcflnt_proxy_hbox_max = 7,
-
- synctex_tree_spcfl_target_idx = 5,
- synctex_tree_spcflt_proxy_vbox_max = 6,
-
- synctex_tree_sp_friend_idx = 2,
- synctex_tree_spf_max = 3,
-
- synctex_tree_spf_arg_sibling_idx = 3,
- synctex_tree_spfa_max = 4,
-
- synctex_tree_spf_target_idx = 3,
- synctex_tree_spft_proxy_max = 4,
-
- synctex_tree_spfa_target_idx = 4,
- synctex_tree_spfat_proxy_last_max = 5,
-
- synctex_tree_s_child_idx = 1,
- synctex_tree_sc_next_hbox_idx = 2,
- synctex_tree_scn_sheet_max = 3,
-
- synctex_tree_sc_target_idx = 2,
- synctex_tree_sct_form_max = 3,
-
- synctex_tree_spc_target_idx = 3,
- synctex_tree_spct_handle_max = 4,
- };
-
- enum {
-
- synctex_data_input_tag_idx = 0,
- synctex_data_input_line_idx = 1,
- synctex_data_input_name_idx = 2,
- synctex_data_input_tln_max = 3,
-
- synctex_data_sheet_page_idx = 0,
- synctex_data_p_sheet_max = 1,
-
- synctex_data_form_tag_idx = 0,
- synctex_data_t_form_max = 1,
-
- synctex_data_tag_idx = 0,
- synctex_data_line_idx = 1,
- synctex_data_column_idx = 2,
- synctex_data_h_idx = 3,
- synctex_data_v_idx = 4,
- synctex_data_tlchv_max = 5,
-
- synctex_data_width_idx = 5,
- synctex_data_tlchvw_max = 6,
-
- synctex_data_height_idx = 6,
- synctex_data_depth_idx = 7,
- synctex_data_box_max = 8,
-
- synctex_data_mean_line_idx = 8,
- synctex_data_weight_idx = 9,
- synctex_data_h_V_idx = 10,
- synctex_data_v_V_idx = 11,
- synctex_data_width_V_idx = 12,
- synctex_data_height_V_idx = 13,
- synctex_data_depth_V_idx = 14,
- synctex_data_hbox_max = 15,
-
- synctex_data_ref_tag_idx = 0,
- synctex_data_ref_h_idx = 1,
- synctex_data_ref_v_idx = 2,
- synctex_data_ref_thv_max = 3,
-
- synctex_data_proxy_h_idx = 0,
- synctex_data_proxy_v_idx = 1,
- synctex_data_proxy_hv_max = 2,
-
- synctex_data_handle_w_idx = 0,
- synctex_data_handle_w_max = 1,
- };
-
- typedef struct synctex_class_t synctex_class_s;
- typedef synctex_class_s * synctex_class_p;
-
-
-
- typedef union {
- synctex_node_p as_node;
- int as_integer;
- char * as_string;
- void * as_pointer;
- } synctex_data_u;
- typedef synctex_data_u * synctex_data_p;
-
- # if defined(SYNCTEX_USE_CHARINDEX)
- typedef unsigned int synctex_charindex_t;
- synctex_charindex_t synctex_node_charindex(synctex_node_p node);
- typedef synctex_charindex_t synctex_lineindex_t;
- synctex_lineindex_t synctex_node_lineindex(synctex_node_p node);
- synctex_node_p synctex_scanner_handle(synctex_scanner_p scanner);
- # define SYNCTEX_DECLARE_CHARINDEX \
- synctex_charindex_t char_index;\
- synctex_lineindex_t line_index;
- # define SYNCTEX_DECLARE_CHAR_OFFSET \
- synctex_charindex_t charindex_offset;
- # else
- # define SYNCTEX_DECLARE_CHARINDEX
- # define SYNCTEX_DECLARE_CHAR_OFFSET
- # endif
- struct synctex_node_t {
- SYNCTEX_DECLARE_CHARINDEX
- synctex_class_p class_;
- #ifdef DEBUG
- synctex_data_u data[22];
- #else
- synctex_data_u data[1];
- #endif
- };
-
- typedef synctex_node_p * synctex_node_r;
-
- typedef struct {
- int h;
- int v;
- } synctex_point_s;
-
- typedef synctex_point_s * synctex_point_p;
-
- typedef struct {
- synctex_point_s min;
- synctex_point_s max;
- } synctex_box_s;
-
- typedef synctex_box_s * synctex_box_p;
-
- typedef enum {
- synctex_node_type_none = 0,
- synctex_node_type_input,
- synctex_node_type_sheet,
- synctex_node_type_form,
- synctex_node_type_ref,
- synctex_node_type_vbox,
- synctex_node_type_void_vbox,
- synctex_node_type_hbox,
- synctex_node_type_void_hbox,
- synctex_node_type_kern,
- synctex_node_type_glue,
- synctex_node_type_rule,
- synctex_node_type_math,
- synctex_node_type_boundary,
- synctex_node_type_box_bdry,
- synctex_node_type_proxy,
- synctex_node_type_proxy_last,
- synctex_node_type_proxy_vbox,
- synctex_node_type_proxy_hbox,
- synctex_node_type_handle,
- synctex_node_number_of_types
- } synctex_node_type_t;
-
- synctex_node_type_t synctex_node_type(synctex_node_p node);
- const char * synctex_node_isa(synctex_node_p node);
-
- synctex_node_type_t synctex_node_target_type(synctex_node_p node);
- synctex_node_type_t synctex_node_type(synctex_node_p node);
- const char * synctex_node_isa(synctex_node_p node);
-
- void synctex_node_log(synctex_node_p node);
- void synctex_node_display(synctex_node_p node);
-
-
- int synctex_node_form_tag(synctex_node_p node);
-
- int synctex_node_weight(synctex_node_p node);
- int synctex_node_child_count(synctex_node_p node);
-
- int synctex_node_h(synctex_node_p node);
- int synctex_node_v(synctex_node_p node);
- int synctex_node_width(synctex_node_p node);
-
- int synctex_node_box_h(synctex_node_p node);
- int synctex_node_box_v(synctex_node_p node);
- int synctex_node_box_width(synctex_node_p node);
- int synctex_node_box_height(synctex_node_p node);
- int synctex_node_box_depth(synctex_node_p node);
-
- int synctex_node_hbox_h(synctex_node_p node);
- int synctex_node_hbox_v(synctex_node_p node);
- int synctex_node_hbox_width(synctex_node_p node);
- int synctex_node_hbox_height(synctex_node_p node);
- int synctex_node_hbox_depth(synctex_node_p node);
-
- synctex_scanner_p synctex_scanner_new(void);
- synctex_node_p synctex_node_new(synctex_scanner_p scanner,synctex_node_type_t type);
-
- int synctex_scanner_display_switcher(synctex_scanner_p scanR);
- void synctex_scanner_set_display_switcher(synctex_scanner_p scanR, int switcher);
-
- typedef struct synctex_iterator_t synctex_iterator_s;
- typedef synctex_iterator_s * synctex_iterator_p;
-
- synctex_iterator_p synctex_iterator_new_display(synctex_scanner_p scanner,const char * name,int line,int column, int page_hint);
-
- synctex_iterator_p synctex_iterator_new_edit(synctex_scanner_p scanner,int page,float h,float v);
-
- void synctex_iterator_free(synctex_iterator_p iterator);
-
- synctex_bool_t synctex_iterator_has_next(synctex_iterator_p iterator);
-
- synctex_node_p synctex_iterator_next_result(synctex_iterator_p iterator);
-
- int synctex_iterator_reset(synctex_iterator_p iterator);
-
- int synctex_iterator_count(synctex_iterator_p iterator);
-
- synctex_node_p synctex_node_target(synctex_node_p node);
-
- #ifndef SYNCTEX_NO_UPDATER
-
- typedef struct synctex_updater_t synctex_updater_s;
- typedef synctex_updater_s * synctex_updater_p;
-
-
- synctex_updater_p synctex_updater_new_with_output_file(const char * output, const char * directory);
-
-
- void synctex_updater_append_magnification(synctex_updater_p updater, char * magnification);
- void synctex_updater_append_x_offset(synctex_updater_p updater, char * x_offset);
- void synctex_updater_append_y_offset(synctex_updater_p updater, char * y_offset);
-
-
- void synctex_updater_free(synctex_updater_p updater);
- #endif
-
- #if defined(SYNCTEX_DEBUG)
- # include "assert.h"
- # define SYNCTEX_ASSERT assert
- #else
- # define SYNCTEX_ASSERT(UNUSED)
- #endif
- #if defined(SYNCTEX_TESTING)
- #warning TESTING IS PROHIBITED
- #if __clang__
- #define __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wformat-extra-args\"")
-
- #define __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS _Pragma("clang diagnostic pop")
- #else
- #define __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS
- #define __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS
- #endif
-
- # define SYNCTEX_TEST_BODY(counter, condition, desc, ...) \
- do { \
- __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \
- if (!(condition)) { \
- ++counter; \
- printf("**** Test failed: %s\nfile %s\nfunction %s\nline %i\n",#condition,__FILE__,__FUNCTION__,__LINE__); \
- printf((desc), ##__VA_ARGS__); \
- } \
- __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \
- } while(0)
-
- # define SYNCTEX_TEST_PARAMETER(counter, condition) SYNCTEX_TEST_BODY(counter, (condition), "Invalid parameter not satisfying: %s", #condition)
-
- int synctex_test_input(synctex_scanner_p scanner);
- int synctex_test_proxy(synctex_scanner_p scanner);
- int synctex_test_tree(synctex_scanner_p scanner);
- int synctex_test_page(synctex_scanner_p scanner);
- int synctex_test_handle(synctex_scanner_p scanner);
- int synctex_test_display_query(synctex_scanner_p scanner);
- int synctex_test_charindex();
- int synctex_test_sheet_1();
- int synctex_test_sheet_2();
- int synctex_test_sheet_3();
- int synctex_test_form();
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|