Skip to content

Commit

Permalink
part of implement xml tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Feb 10, 2025
1 parent dcb80d7 commit adb3445
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/ext.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Contact: [email protected]

include (${CMAKE_CURRENT_LIST_DIR}/image_coders/image.cmake)

include (${CMAKE_CURRENT_LIST_DIR}/svg/svg.cmake)
3 changes: 3 additions & 0 deletions ext/svg/psx_svg.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY psx_svg
EXPORTS
psx_svg_init
104 changes: 104 additions & 0 deletions ext/svg/psx_svg.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "windows.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// ����(�л����񹲺͹�) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""windows.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,8,0,1
PRODUCTVERSION 2,8,0,1
FILEFLAGSMASK 0x1fL
#ifdef _DEBUG
FILEFLAGS 0x9L
#else
FILEFLAGS 0x8L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "Comments", "Vector Graphic library"
VALUE "CompanyName", "picasso.inc"
VALUE "FileDescription", "picasso2 extentions ��̬���ӿ�"
VALUE "FileVersion", "2, 8, 0, 1"
VALUE "InternalName", "psx_svg"
VALUE "LegalCopyright", "Copyright (C) 2025"
VALUE "OriginalFilename", "psx_svg.dll"
VALUE "PrivateBuild", "2269"
VALUE "ProductName", "picasso2 extentions ��̬���ӿ�"
VALUE "ProductVersion", "2, 8, 0, 1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END

#endif // ����(�л����񹲺͹�) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

46 changes: 46 additions & 0 deletions ext/svg/psx_xml_token.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024, Zhang Ji Peng
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <ctype.h>
#include <string.h>

#include "psx_xml_token.h"

#ifdef __cplusplus
extern "C" {
#endif

#define TOKEN_LEN(t) ((t)->end - (t)->start)


bool psx_xml_tokenizer(const char* xml_data, uint32_t data_len, xml_token_process, void* data)
{
return false;
}

#ifdef __cplusplus
}
#endif
71 changes: 71 additions & 0 deletions ext/svg/psx_xml_token.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2024, Zhang Ji Peng
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _PSX_XML_TOKEN_H_
#define _PSX_XML_TOKEN_H_

#include "psx_common.h"
#include "psx_array.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
PSX_XML_BEGIN = 1,
PSX_XML_END = 2,
PSX_XML_CONTENT = 3,
} psx_xml_token_type_t;

typedef struct {
const char* name_start;
const char* name_end;
const char* value_start;
const char* value_end;
} psx_xml_token_attr_t;

enum {
PSX_XML_TOKEN_FLAT = 1,
};

typedef struct {
uint32_t flags;
const char* start;
const char* end;
psx_xml_token_type_t type;
psx_xml_token_attr_t* cur_attr;
psx_array_t attrs;
} psx_xml_token_t;

typedef bool (*xml_token_process)(void* context, const psx_xml_token_t* token);

bool psx_xml_tokenizer(const char* xml_data, uint32_t data_len, xml_token_process, void* data);

#ifdef __cplusplus
}
#endif

#endif /* _PSX_XML_TOKEN_H_ */
12 changes: 12 additions & 0 deletions ext/svg/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by psx_svg.rc
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
31 changes: 31 additions & 0 deletions ext/svg/svg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Picasso - a vector graphics library
#
# Copyright (C) 2024 Zhang Ji Peng
# Contact: [email protected]

set(PXSVG_DIR ${PROJECT_ROOT}/ext/svg)

set(PXSVG_SOURCES
${PXSVG_DIR}/psx_xml_token.h
${PXSVG_DIR}/psx_xml_token.cpp
)

set(LIBX_SVG psx_svg)

if (WIN32)
set(PXSVG_SOURCES
${PXSVG_SOURCES}
${PXSVG_DIR}/psx_svg.rc
${PXSVG_DIR}/psx_svg.def
${PXSVG_DIR}/resource.h
)
endif()

add_definitions(-DEXPORT)
add_library(${LIBX_SVG} ${PXSVG_SOURCES})
install(TARGETS ${LIBX_SVG} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
set_target_properties(${LIBX_SVG} PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)

include_directories(${PXSVG_DIR} ${PROJECT_ROOT}/ext/common ${PROJECT_ROOT}/include ${PROJECT_ROOT}/include/images ${PROJECT_ROOT}/include/svg)
target_link_libraries(${LIBX_SVG} PRIVATE ${LIB_NAME})

0 comments on commit adb3445

Please sign in to comment.