Text Editor: Add GLSL support language #116793

Closed
Gangneron wants to merge 68 commits from Gangneron/blender:Add_GLSL into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 20 additions and 25 deletions
Showing only changes of commit 9ac768dfd3 - Show all commits

View File

@ -114,9 +114,9 @@ static const char *text_format_glsl_literals_builtinfunc_data[] = {
"while"
/* clang-format on */
};
static const Span<const char *> text_format_glsl_literals_builtinfunc(
text_format_glsl_literals_builtinfunc_data, ARRAY_SIZE(text_format_glsl_literals_builtinfunc_data));
text_format_glsl_literals_builtinfunc_data,
fclem marked this conversation as resolved Outdated

I don't know how to handle that, but preprocessor directive can be nested and not glued to the # symbol. That's the usual usecase for defined.

I don't know how to handle that, but preprocessor directive can be nested and not glued to the `#` symbol. That's the usual usecase for `defined`.

i fix problem but maybe I could put that in the text_format_glsl_find_preprocessor function

i fix problem but maybe I could put that in the text_format_glsl_find_preprocessor function

@ideasman42 what do you think of my idea of creating a function?

@ideasman42 what do you think of my idea of creating a function?
ARRAY_SIZE(text_format_glsl_literals_builtinfunc_data));
static const char *text_format_glsl_literals_reserved_data[] = {
/* Force single column, sorted list. */
@ -322,7 +322,7 @@ static const char *text_format_glsl_literals_specialvar_data[] = {
/* clang-format on */
};
static const Span<const char*> text_format_glsl_literals_specialvar(
text_format_glsl_literals_specialvar_data, ARRAY_SIZE(*text_format_glsl_literals_specialvar_data));
*text_format_glsl_literals_specialvar_data, ARRAY_SIZE(*text_format_glsl_literals_specialvar_data));
static const char *text_format_glsl_literals_preprocessor[] = {
@ -338,13 +338,10 @@ static const char *text_format_glsl_literals_preprocessor[] = {
"version"
};
static const Span<const char *>text_format_glsl_literals_preprocessor(
text_format_glsl_literals_preprocessor, ARRAY_SIZE(text_format_glsl_literals_preprocessor));
/** \} */
/* -------------------------------------------------------------------- */
/** \name Local Functions (for #TextFormatType::format_line)
* \{ */
text_format_glsl_literals_preprocessor, ARRAY_SIZE(text_format_glsl_literals_preprocessor));
/*---------------------------------------------------------------------*/
/* name local functions
*/
static int txtfmt_glsl_find_builtinfunc(const char *string)
{
@ -406,12 +403,9 @@ static char txtfmt_glsl_format_identifier(const char *str)
return fmt;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Format Line Implementation (#TextFormatType::format_line)
* \{ */
/*-----------------------------------------------------------------*/
/* name format line implementation
*/
static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool do_next)
fclem marked this conversation as resolved Outdated

empty character constant

empty character constant

I don't see what I need to change

I don't see what I need to change

c'est un code identique à text_format_osl

c'est un code identique à text_format_osl

What is the value of prev expected to be? Two single quotes without spaces doesn't define a character. OSL for example sets prev = ' '.

What is the value of prev expected to be? Two single quotes without spaces doesn't define a character. OSL for example sets `prev = ' '`.
{
FlattenString fs;
@ -420,19 +414,20 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool d
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line. */
/* Get original continuation from this line */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@ -448,7 +443,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool d
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char. */
/* Handle escape sequences by skipping both \ and next char */
if (*str == '\\') {
*fmt = prev;
fmt++;
@ -512,7 +507,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool d
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits). */
/* Numbers (digits not part of an identifier and periods followed by digits) */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
@ -566,9 +561,9 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool d
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line. */
/* If continuation has changed and we're allowed, process the next line */
if (cont != cont_orig && do_next && line->next) {
txtfmt_glsl_format_line(st, line->next, do_next);
txtfmt_osl_format_line(st, line->next, do_next);
}
flatten_string_free(&fs);
@ -576,8 +571,8 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine * line, const bool d
/** \} */
/* -------------------------------------------------------------------- */
/** \name Registration
/*-----------------------------------------------------------------*/
/** \name registration
* \{ */
void ED_text_format_register_glsl()