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

Remove const char* elements from cdef #126

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions cairocffi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
FORMAT_A1 = 3
FORMAT_RGB16_565 = 4
FORMAT_RGB30 = 5
FORMAT_RGB96F = 6
FORMAT_RGBA128F = 7

OPERATOR_CLEAR = 0
OPERATOR_SOURCE = 1
Expand Down Expand Up @@ -244,9 +246,6 @@
SVG_UNIT_PERCENT = 9

_CAIRO_HEADERS = r"""
const char* CAIRO_TAG_DEST = "cairo.dest";
const char* CAIRO_TAG_LINK = "Link";


int
cairo_version (void);
Expand Down Expand Up @@ -338,7 +337,9 @@
CAIRO_FORMAT_A8 = 2,
CAIRO_FORMAT_A1 = 3,
CAIRO_FORMAT_RGB16_565 = 4,
CAIRO_FORMAT_RGB30 = 5
CAIRO_FORMAT_RGB30 = 5,
CAIRO_FORMAT_RGB96F = 6,
CAIRO_FORMAT_RGBA128F = 7
} cairo_format_t;

typedef cairo_status_t (*cairo_write_func_t) (void *closure,
Expand Down Expand Up @@ -1907,8 +1908,8 @@
cairo_debug_reset_static_data (void);


const int CAIRO_PDF_OUTLINE_ROOT = 0;
const int CAIRO_PDF_OUTLINE_ROOT = 0;


typedef enum _cairo_pdf_version {
CAIRO_PDF_VERSION_1_4,
Expand Down
20 changes: 11 additions & 9 deletions utils/mkconstants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import sys
import textwrap

import pycparser.c_generator

Expand Down Expand Up @@ -54,15 +55,11 @@ def read_cairo_header(cairo_git_dir, suffix):

def generate(cairo_git_dir):
# Remove comments, preprocessor instructions and macros.
source = '''
const char* CAIRO_TAG_DEST = "cairo.dest";
const char* CAIRO_TAG_LINK = "Link";
'''
source += read_cairo_header(cairo_git_dir, '')
source = read_cairo_header(cairo_git_dir, '')

source += '''
source += textwrap.dedent('''
const int CAIRO_PDF_OUTLINE_ROOT = 0;
'''
''')
source += read_cairo_header(cairo_git_dir, '-pdf')

source += read_cairo_header(cairo_git_dir, '-ps')
Expand All @@ -84,8 +81,13 @@ def generate(cairo_git_dir):

ast = pycparser.CParser().parse(source)

print('# *** Do not edit this file ***')
print('# Generated by utils/mkconstants.py\n')
print(textwrap.dedent('''\
# *** Do not edit this file ***
# Generated by utils/mkconstants.py

TAG_DEST = b"cairo.dest"

TAG_LINK = b"Link"\n'''))
PrintEnumsVisitor().visit(ast)
print('_CAIRO_HEADERS = r"""%s"""' % source)

Expand Down