-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from gjsify/shell-fragment-type
feat(shell): Add Cogl.SnippetHook support for Shell.GLSLEffect.add_glsl_snippet
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { IntrospectedNamespace } from "../gir/namespace.js"; | ||
import { TypeIdentifier, OrType, NullableType } from "../gir.js"; | ||
import { NSRegistry } from "../gir/registry.js"; | ||
|
||
const shellTemplate = (version: string) => ({ | ||
namespace: "Shell", | ||
version, | ||
modifier(namespace: IntrospectedNamespace, registry: NSRegistry) { | ||
// Get the GLSLEffect class which contains the add_glsl_snippet method | ||
const GLSLEffect = namespace.assertClass("GLSLEffect"); | ||
|
||
// Find the add_glsl_snippet method | ||
const addGlslSnippet = GLSLEffect.members.find(m => m.name === "add_glsl_snippet"); | ||
|
||
// Change | ||
// ```ts | ||
// add_glsl_snippet(hook: SnippetHook | null, declarations: string, code: string, is_replace: boolean): void; | ||
// ``` | ||
// to | ||
// ```ts | ||
// add_glsl_snippet(hook: SnippetHook | Cogl.SnippetHook | null, declarations: string, code: string, is_replace: boolean): void; | ||
// ``` | ||
|
||
if (addGlslSnippet) { | ||
// Create a new parameter with updated type using copy() | ||
const updatedParameter = addGlslSnippet.parameters[0].copy({ | ||
type: new NullableType( | ||
new OrType( | ||
new TypeIdentifier("SnippetHook", "Shell"), | ||
new TypeIdentifier("SnippetHook", "Cogl") | ||
) | ||
) | ||
}); | ||
|
||
// Replace the original parameter | ||
addGlslSnippet.parameters[0] = updatedParameter; | ||
} | ||
} | ||
}); | ||
|
||
/** Shell 14 was introduced with GNOME 45 */ | ||
export const shell14 = shellTemplate("14"); | ||
|
||
/** Shell 15 was introduced with GNOME 48 */ | ||
export const shell15 = shellTemplate("15"); |