Skip to content

Commit 9527fef

Browse files
authored
feat: add libvips version comment in generated code (#41)
* feat: add libvips version comment in generated code * build: update generated vips package
1 parent 5477537 commit 9527fef

28 files changed

+371
-363
lines changed

cmd/vipsgen/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func main() {
5858
// Create operation manager for C-based introspection
5959
vipsIntrospection := introspection.NewIntrospection(*isDebug)
6060

61+
// Get libvips version from introspection
62+
libvipsVersion := vipsIntrospection.GetLibvipsVersion()
63+
6164
// Extract image types from operations
6265
imageTypes := vipsIntrospection.DiscoverImageTypes()
6366

@@ -70,7 +73,7 @@ func main() {
7073
log.Printf("Discovered %d enum types\n", len(enumTypes))
7174

7275
// Create unified template data
73-
templateData := generator.NewTemplateData(operations, enumTypes, imageTypes)
76+
templateData := generator.NewTemplateData(libvipsVersion, operations, enumTypes, imageTypes)
7477

7578
// Generate all code using the unified template data approach
7679
if err := generator.Generate(loader, templateData, outputDir); err != nil {

internal/generator/templatedata.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ import (
66

77
// TemplateData holds all data needed by any template
88
type TemplateData struct {
9-
Operations []introspection.Operation
10-
EnumTypes []introspection.EnumTypeInfo
11-
ImageTypes []introspection.ImageTypeInfo
9+
VipsVersion string
10+
Operations []introspection.Operation
11+
EnumTypes []introspection.EnumTypeInfo
12+
ImageTypes []introspection.ImageTypeInfo
1213
}
1314

1415
// NewTemplateData creates a new TemplateData structure with all needed information
1516
func NewTemplateData(
17+
vipsVersion string,
1618
operations []introspection.Operation,
1719
enumTypes []introspection.EnumTypeInfo,
1820
imageTypes []introspection.ImageTypeInfo,
1921
) *TemplateData {
2022
return &TemplateData{
21-
Operations: operations,
22-
EnumTypes: enumTypes,
23-
ImageTypes: imageTypes,
23+
VipsVersion: vipsVersion,
24+
Operations: operations,
25+
EnumTypes: enumTypes,
26+
ImageTypes: imageTypes,
2427
}
2528
}

internal/generator/templatefunc.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ func generateImageArgumentsComment(op introspection.Operation) string {
10211021
// Ensure description starts with lowercase and ends with period
10221022
if len(cleanDesc) > 0 {
10231023
cleanDesc = strings.ToLower(string(cleanDesc[0])) + cleanDesc[1:]
1024-
if !strings.HasSuffix(cleanDesc, ".") {
1025-
cleanDesc += "."
1026-
}
10271024
}
10281025
result.WriteString(fmt.Sprintf("\n// The %s specifies %s", arg.GoName, cleanDesc))
10291026
}

internal/introspection/introspection.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ func NewIntrospection(isDebug bool) *Introspection {
3232
isDebug: isDebug,
3333
}
3434
}
35+
36+
// GetLibvipsVersion returns the libvips version string
37+
func (v *Introspection) GetLibvipsVersion() string {
38+
return C.GoString(C.vips_version_string())
39+
}

internal/templates/callback.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
package vips
44

internal/templates/connection.c.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
#include "connection.h"
44

internal/templates/connection.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
package vips
44

internal/templates/connection.h.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
#include <stdlib.h>
44
#include <vips/vips.h>

internal/templates/image.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
package vips
44

internal/templates/types.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by github.com/cshum/vipsgen. DO NOT EDIT.
1+
// Code generated by github.com/cshum/vipsgen from libvips {{.VipsVersion}}. DO NOT EDIT.
22

33
package vips
44

0 commit comments

Comments
 (0)