Skip to content

Codex/fix swift bridge linkage - #454

Closed
SpectralDragon wants to merge 19 commits into
marcobambini:masterfrom
AdaEngine:codex/fix-swift-bridge-linkage
Closed

Codex/fix swift bridge linkage#454
SpectralDragon wants to merge 19 commits into
marcobambini:masterfrom
AdaEngine:codex/fix-swift-bridge-linkage

Conversation

@SpectralDragon

Copy link
Copy Markdown

No description provided.

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@SpectralDragon is attempting to deploy a commit to the sqlitecloud Team on Vercel.

A member of the Team first needs to authorize it.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T19:02:29.474943Z 794ec42 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SpectralDragon
SpectralDragon deleted the codex/fix-swift-bridge-linkage branch August 29, 2026 18:58
@SpectralDragon
SpectralDragon restored the codex/fix-swift-bridge-linkage branch August 29, 2026 19:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 794ec424ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// register objc.loadClass method
gravity_gc_setenabled(vm, false);

gravity_class_t *c = objc_class_load(vm, "NSAlert");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore registration of the ObjC bridge class

Registering NSAlert directly removes the global objc bridge and its loadClass/exec methods, so existing Gravity programs using objc.loadClass(...) can no longer dynamically expose any Objective-C class. It also makes objc_register fail outright on platforms where NSAlert is unavailable; restore the generic bridge registration rather than hard-coding this AppKit class.

Useful? React with 👍 / 👎.

// gravity_instance_setxdata(instance, (__bridge void *)(obj2));
// }
// RETURN_NOVALUE();
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Execute Objective-C initializers that take arguments

When a bridged Objective-C initializer has arguments (nargs > 1), this unconditional failure is now the only reachable path because the previous initializer invocation was commented out. Consequently, constructions such as SomeClass(value) always fail even when the selector and arguments are valid; retain the existing zero-argument handling while restoring the argument-bearing initialization path.

Useful? React with 👍 / 👎.

Comment on lines +174 to +175
if arguments.count > method.argsCount {
return GravityReturn.error("Passed more arguments, then expected. Method \(method.name) expected \(method.argsCount) arguments, but passed \(arguments.count) arguments.", vm: vm)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject calls with too few exported-method arguments

If Gravity calls an exported Swift method with fewer arguments than declared, this check succeeds and the generated MethodDescriptor wrapper immediately indexes missing elements such as args[0], trapping the host process instead of reporting a script error. Validate that arguments.count equals method.argsCount (the same issue also exists in the constructor path) before invoking the wrapper.

Useful? React with 👍 / 👎.

return delegate.virtalMachine(vm, didRequestCloneFor: value).xData
}

return objptr

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Retain bridged data when cloning an instance

For a bridged instance cloned through Gravity's clone() operation, returning the original objptr assigns the same retained _ValueBox pointer to both instances without adding an ownership retain. Each instance later invokes bridgeFree, so the first destruction releases the box and the second accesses/releases a dangling pointer; retain the shared box for the clone or create an independently owned clone.

Useful? React with 👍 / 👎.

rhsPtr: UnsafeMutableRawPointer?
) -> Bool {
guard let vm = GravityVirtualMachine.getVM(vmPointer) else { fatalError("Cannot found Virtual Machine") }
return vm.delegate.virtualMachineBridgeEquals(vm, lhsValue: GSValue(object: lhsPtr, in: vm), rhsValue: GSValue(object: lhsPtr, in: vm))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass the actual right-hand value to equality callbacks

Whenever two distinct bridged instances reach the delegate equality fallback, both callback arguments are constructed from lhsPtr, so the delegate never sees rhsPtr and comparisons can report equality for unrelated objects. Construct rhsValue from rhsPtr instead.

Useful? React with 👍 / 👎.

Comment on lines +33 to +35
sourcePtr,
source.count,
0, // fileId

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Measure compiler input in UTF-8 bytes

For source containing any multibyte Unicode character, String.count reports grapheme count while gravity_compiler_run expects the byte length of the UTF-8 buffer supplied by withCString; the compiler therefore receives a truncated source buffer and may produce syntax errors or omit trailing code. Pass source.utf8.count here, and likewise use UTF-8 byte counts in the other new length-taking C calls.

Useful? React with 👍 / 👎.

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.

1 participant