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

Generated SDK does not compile #59

Closed
Cre3per opened this issue Jul 27, 2024 · 4 comments · Fixed by #62
Closed

Generated SDK does not compile #59

Cre3per opened this issue Jul 27, 2024 · 4 comments · Fixed by #62
Labels
enhancement New feature or request

Comments

@Cre3per
Copy link

Cre3per commented Jul 27, 2024

To make testing and using the generated SDK easier, source2gen could

  • (1) Add dummies for missing types that aren't registered in the schema system, e.g. CHandle, CUtlVector, and many more.
  • (1) Add a dummy interfaces namespace used to access static fields
  • -(2) Take into account template arguments when sorting class definitions- we're no longer sorting types
  • Fully qualify template argument names and include required modules (Assumes Dump types per module #58 is merged)
  • Translate built-in template argument names to C++ types, e.g. CUtlVector<int32> -> CUtlVector<std::int32_t>
  • Don't forward declare nested types, because that doesn't work in C++
  • Rename nested types to use underscores
  • Generate static_assertions to make sure the generated types have the layout we expected
  • Use large integer types for consecutive bitfields with entries crossing byte borders (e.g. char a: 7; char b: 2)
  • Detect misaligned fields and types and replace them with dummies
  • Replace template types with non-type template parameters with dummies (e.g. CUtlLeanVectorFixedGrowable) (because those parameters are not included in the sdk)

This list grows as more issues surface

(1) The user can replace the dummies with real implementations if they want to access the affected types. To compile the SDK, dummies are enough
(2) This requires an update to the ordering algorithm to detect indirect cyclic dependencies, e.g. player->entity->world->player

@Cre3per
Copy link
Author

Cre3per commented Jul 27, 2024

I'd like to work on this

@Cre3per
Copy link
Author

Cre3per commented Aug 7, 2024

I am at a point where the generated SDK compiles.
Putting in a little more work to generate static_assertions and making them pass so that the SDK is guaranteed to work in user projects.
Most of the offset/size mismatches so far were caused by wrong padding size. Currently working on respecting field alignment when generating pads.

@es3n1n es3n1n added the enhancement New feature or request label Aug 20, 2024
@Cre3per
Copy link
Author

Cre3per commented Aug 23, 2024

The SDK now compiles and all generated assertions for type sizes and field offsets are passing.
Will clean up the code before filing a PR.

@Cre3per
Copy link
Author

Cre3per commented Aug 23, 2024

Open non-blocking worries

  • All fields with template types are replaced with dummies
    • because we cannot detect if a type has non-type template parameters
    • we could add a whitelist of known-good template types, but that'd be manual work
  • There are no more private fields, even pads are public, to have standard-layout-classes

There are also new limitations, some types/fields get commented out, see README.md. They don't make source2gen worse though, as previously source2gen simply generated broken types for affected classes.

@Cre3per Cre3per mentioned this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants