Skip to content

Conversation

@jac3km4
Copy link
Contributor

@jac3km4 jac3km4 commented Jul 26, 2025

Enables mods to configure types that are mixedRef and neverRef for redscript 1.0.

Basically the compiler now has rules:

  • if class is @mixedRef
    • user writes ref<Class> = it is preserved as is
    • user writes Class = it is preserved as is
  • if class is @neverRef
    • user writes ref<Class> = error
    • user writes Class = it is preserved as is
  • if class is neither
    • user writes ref<Class> = it is preserved
    • user writes Class = it becomes ref<Class>

Copilot AI review requested due to automatic review settings July 26, 2025 19:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds configuration support for mixedRef and neverRef types in redscript 1.0. These type configurations allow mods to specify whether types can be used with or without the w/ref modifier.

  • Adds registration methods for neverRef and mixedRef types in the ScriptCompilationSystem
  • Integrates the type registration with the script compiler settings and compilation process
  • Updates the redscript dependency and adjusts the include path

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/dll/Systems/ScriptCompilationSystem.hpp Adds method declarations and member variables for storing neverRef and mixedRef types
src/dll/Systems/ScriptCompilationSystem.cpp Implements registration and getter methods for the new type configurations
src/dll/ScriptCompiler/ScriptCompilerSettings.hpp Adds method declarations and storage for type configurations in compiler settings
src/dll/ScriptCompiler/ScriptCompilerSettings.cpp Implements registration methods and integrates type configuration into compilation process
src/dll/Hooks/ExecuteProcess.cpp Adds calls to register the configured types during script compilation
deps/redscript Updates redscript submodule commit
cmake/ConfigureAndIncludeRedscript.cmake Updates include path for redscript headers

@alphanin9
Copy link
Contributor

Pull Request Overview

This PR adds configuration support for mixedRef and neverRef types in redscript 1.0. These type configurations allow mods to specify whether types can be used with or without the w/ref modifier.

  • Adds registration methods for neverRef and mixedRef types in the ScriptCompilationSystem
  • Integrates the type registration with the script compiler settings and compilation process
  • Updates the redscript dependency and adjusts the include path

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file

What the fuck

Copy link
Collaborator

@psiberx psiberx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to add this to SDK now and expose like here https://github.com/wopss/RED4ext/blob/master/src/dll/v0/Plugin.cpp#L53

@jac3km4 jac3km4 changed the title feat: never and mixed ref configuration feat: @neverRef and mixedRef configuration Jul 27, 2025
@wopss
Copy link
Owner

wopss commented Jul 27, 2025

Are there some classes we need to add these "tags" to? Like GameTime?

@wopss
Copy link
Owner

wopss commented Jul 27, 2025

The last case, is for CDPR mess?

* if class is neither
  * user writes `ref<Class>` = it is preserved
  * user writes `Class` = it becomes `ref<Class>`

@wopss
Copy link
Owner

wopss commented Jul 27, 2025

The names are a bit strange, but I can't come up with better ones.

The names I quickly brain stormed are:

  • mixedRef -> verbatim / asIsRef / autoRef
  • neverRef -> raw / unwrapped / simple / nonRefable

@psiberx
Copy link
Collaborator

psiberx commented Jul 27, 2025

The last case, is for CDPR mess?

* if class is neither
  * user writes `ref<Class>` = it is preserved
  * user writes `Class` = it becomes `ref<Class>`

On the opposite. It implies that Class is always used with ref. In original scripts they don't have explicit refs and Class always means ref<Class>, like we always expected them to be used. When we started to expose more types from RTTI to scripts, we found out there are classes that are sometimes used with ref and sometimes without ref. Some of them are even never used with ref and could've been simple structs.

@psiberx psiberx merged commit 2e4b29b into wopss:master Jul 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants