Blender  V3.3
Macros | Functions
text_format_py.c File Reference
#include <string.h>
#include "BLI_blenlib.h"
#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "BKE_text.h"
#include "text_format.h"

Go to the source code of this file.

Macros

#define TXTFMT_PY_NUMERAL_STRING_COUNT_IMPL(txtfmt_py_numeral_char_is_fn)
 

Functions

static int txtfmt_py_find_builtinfunc (const char *string)
 
static int txtfmt_py_find_specialvar (const char *string)
 
static int txtfmt_py_find_decorator (const char *string)
 
static int txtfmt_py_find_bool (const char *string)
 
static bool txtfmt_py_numeral_char_is_binary (const char c)
 
static uint txtfmt_py_numeral_string_count_binary (const char *string)
 
static bool txtfmt_py_numeral_char_is_octal (const char c)
 
static uint txtfmt_py_numeral_string_count_octal (const char *string)
 
static bool txtfmt_py_numeral_char_is_decimal (const char c)
 
static uint txtfmt_py_numeral_string_count_decimal (const char *string)
 
static bool txtfmt_py_numeral_char_is_hexadecimal (const char c)
 
static uint txtfmt_py_numeral_string_count_hexadecimal (const char *string)
 
static bool txtfmt_py_numeral_char_is_zero (const char c)
 
static uint txtfmt_py_numeral_string_count_zeros (const char *string)
 
static int txtfmt_py_find_numeral_inner (const char *string)
 
static int txtfmt_py_literal_numeral (const char *string, char prev_fmt)
 
static char txtfmt_py_format_identifier (const char *str)
 
static void txtfmt_py_format_line (SpaceText *st, TextLine *line, const bool do_next)
 
void ED_text_format_register_py (void)
 

Macro Definition Documentation

◆ TXTFMT_PY_NUMERAL_STRING_COUNT_IMPL

#define TXTFMT_PY_NUMERAL_STRING_COUNT_IMPL (   txtfmt_py_numeral_char_is_fn)
Value:
{ \
uint count = 0; \
for (; txtfmt_py_numeral_char_is_fn(*string); string += 1) { \
count += 1; \
} \
return count; \
} \
((void)0)
SyclQueue void void size_t num_bytes void
int count

Definition at line 176 of file text_format_py.c.

Function Documentation

◆ ED_text_format_register_py()

void ED_text_format_register_py ( void  )

◆ txtfmt_py_find_bool()

static int txtfmt_py_find_bool ( const char *  string)
static

Definition at line 153 of file text_format_py.c.

References len, STR_LITERAL_STARTSWITH, and text_check_identifier().

Referenced by txtfmt_py_format_line().

◆ txtfmt_py_find_builtinfunc()

static int txtfmt_py_find_builtinfunc ( const char *  string)
static

Checks the specified source string for a Python built-in function name. This name must start at the beginning of the source string and must be followed by a non-identifier (see text_check_identifier(char)) or null character.

If a built-in function is found, the length of the matching name is returned. Otherwise, -1 is returned.

See: http://docs.python.org/py3k/reference/lexical_analysis.html#keywords

The following items are derived from this list:

", ".join(['"%s"' % kw
for kw in sorted(__import__("keyword").kwlist + __import__("keyword").softkwlist)
if kw not in {"False", "None", "True", "def", "class", "_"}])

The code below can be re-generated using:

import keyword
ignore = {"False", "None", "True", "def", "class", "_"}
keywords = sorted(set(keyword.kwlist + keyword.softkwlist) - ignore)
longest = max(len(kw) for kw in keywords)
first = 'if (STR_LITERAL_STARTSWITH(string, "%s",%s len)) { i = len;'
middle = '} else if (STR_LITERAL_STARTSWITH(string, "%s",%s len)) { i = len;'
last = '} else %s { i = 0;'
print("\n".join([(first if i==0 else middle) % (kw, ' '*(longest - len(kw)))
for (i, kw) in enumerate(keywords)]) + "\n" +
last % (' '*(longest-2)) + "\n" +
"}")
int len
Definition: draw_manager.c:108
float max

Definition at line 31 of file text_format_py.c.

References len, STR_LITERAL_STARTSWITH, and text_check_identifier().

Referenced by txtfmt_py_format_identifier(), and txtfmt_py_format_line().

◆ txtfmt_py_find_decorator()

static int txtfmt_py_find_decorator ( const char *  string)
static

◆ txtfmt_py_find_numeral_inner()

static int txtfmt_py_find_numeral_inner ( const char *  string)
static

◆ txtfmt_py_find_specialvar()

static int txtfmt_py_find_specialvar ( const char *  string)
static

◆ txtfmt_py_format_identifier()

static char txtfmt_py_format_identifier ( const char *  str)
static

◆ txtfmt_py_format_line()

static void txtfmt_py_format_line ( SpaceText st,
TextLine line,
const bool  do_next 
)
static

◆ txtfmt_py_literal_numeral()

static int txtfmt_py_literal_numeral ( const char *  string,
char  prev_fmt 
)
static

◆ txtfmt_py_numeral_char_is_binary()

static bool txtfmt_py_numeral_char_is_binary ( const char  c)
static

Definition at line 187 of file text_format_py.c.

References Freestyle::c, and ELEM.

Referenced by txtfmt_py_numeral_string_count_binary().

◆ txtfmt_py_numeral_char_is_decimal()

static bool txtfmt_py_numeral_char_is_decimal ( const char  c)
static

Definition at line 207 of file text_format_py.c.

References Freestyle::c.

Referenced by txtfmt_py_numeral_string_count_decimal().

◆ txtfmt_py_numeral_char_is_hexadecimal()

static bool txtfmt_py_numeral_char_is_hexadecimal ( const char  c)
static

Definition at line 217 of file text_format_py.c.

References Freestyle::c.

Referenced by txtfmt_py_numeral_string_count_hexadecimal().

◆ txtfmt_py_numeral_char_is_octal()

static bool txtfmt_py_numeral_char_is_octal ( const char  c)
static

Definition at line 197 of file text_format_py.c.

References Freestyle::c.

Referenced by txtfmt_py_numeral_string_count_octal().

◆ txtfmt_py_numeral_char_is_zero()

static bool txtfmt_py_numeral_char_is_zero ( const char  c)
static

Definition at line 227 of file text_format_py.c.

References Freestyle::c, and ELEM.

Referenced by txtfmt_py_numeral_string_count_zeros().

◆ txtfmt_py_numeral_string_count_binary()

static uint txtfmt_py_numeral_string_count_binary ( const char *  string)
static

◆ txtfmt_py_numeral_string_count_decimal()

static uint txtfmt_py_numeral_string_count_decimal ( const char *  string)
static

◆ txtfmt_py_numeral_string_count_hexadecimal()

static uint txtfmt_py_numeral_string_count_hexadecimal ( const char *  string)
static

◆ txtfmt_py_numeral_string_count_octal()

static uint txtfmt_py_numeral_string_count_octal ( const char *  string)
static

◆ txtfmt_py_numeral_string_count_zeros()

static uint txtfmt_py_numeral_string_count_zeros ( const char *  string)
static