From b925335bbbc97c4ffb3c329d1995cb34a3da1947 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 8 Sep 2023 12:04:21 +1000 Subject: [PATCH] Fix tests --- v3/internal/commands/icons_test.go | 12 +- v3/internal/commands/task_test.go | 39 - v3/internal/parser/bindings.go | 7 +- v3/internal/parser/bindings_test.go | 5 + v3/internal/parser/models_test.go | 12 +- v3/internal/parser/parser_test.go | 59 ++ .../bindings_main.js | 47 +- .../bindings_services.js | 28 +- .../struct_literal_multiple/bindings_main.js | 54 +- .../bindings_main.js | 54 +- .../bindings_main.js | 47 +- .../bindings_services.js | 28 +- .../struct_literal_single/bindings_main.js | 826 ++++++++---------- .../testdata/variable_single/bindings_main.js | 27 +- .../bindings_main.js | 27 +- .../bindings_main.js | 47 +- .../bindings_services.js | 28 +- v3/internal/templates/templates_test.go | 8 +- 18 files changed, 555 insertions(+), 800 deletions(-) delete mode 100644 v3/internal/commands/task_test.go diff --git a/v3/internal/commands/icons_test.go b/v3/internal/commands/icons_test.go index a41e1bd6c..f13e0d977 100644 --- a/v3/internal/commands/icons_test.go +++ b/v3/internal/commands/icons_test.go @@ -52,7 +52,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, WindowsFilename: "appicon.ico", @@ -94,7 +94,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, MacFilename: "appicon.icns", @@ -133,7 +133,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, Sizes: "16", @@ -181,7 +181,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, } @@ -195,7 +195,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, WindowsFilename: "appicon.ico", @@ -211,7 +211,7 @@ func TestGenerateIcon(t *testing.T) { _, thisFile, _, _ := runtime.Caller(1) localDir := filepath.Dir(thisFile) // Get the path to the example icon - exampleIcon := filepath.Join(localDir, "examples", "appicon.png") + exampleIcon := filepath.Join(localDir, "defaults", "appicon.png") return &IconsOptions{ Input: exampleIcon, WindowsFilename: "appicon.ico", diff --git a/v3/internal/commands/task_test.go b/v3/internal/commands/task_test.go deleted file mode 100644 index a88304272..000000000 --- a/v3/internal/commands/task_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package commands - -import "testing" - -func TestBuild(t *testing.T) { - type args struct { - options *RunTaskOptions - otherArgs []string - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "should error if task name not provided", - args: args{ - options: &RunTaskOptions{}, - }, - wantErr: true, - }, - { - name: "should work if task name provided", - args: args{ - options: &RunTaskOptions{ - Name: "build", - }, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := RunTask(tt.args.options, tt.args.otherArgs); (err != nil) != tt.wantErr { - t.Errorf("Run() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/v3/internal/parser/bindings.go b/v3/internal/parser/bindings.go index 53155d2d8..7c7d68bd4 100644 --- a/v3/internal/parser/bindings.go +++ b/v3/internal/parser/bindings.go @@ -18,7 +18,7 @@ const header = `// @ts-check const bindingTemplate = ` /** * {{structName}}.{{methodName}} - * Comments + *Comments * @param name {string} * @returns {Promise} **/ @@ -108,6 +108,9 @@ func GenerateBinding(structName string, method *BoundMethod) (string, []string) result = strings.ReplaceAll(result, "{{methodName}}", method.Name) result = strings.ReplaceAll(result, "{{ID}}", fmt.Sprintf("%v", method.ID)) comments := strings.TrimSpace(method.DocComment) + if comments != "" { + comments = " " + comments + } result = strings.ReplaceAll(result, "Comments", comments) var params string for _, input := range method.Inputs { @@ -238,7 +241,7 @@ window.go = window.go || {}; for _, method := range methods { thisBinding, models := GenerateBinding(structName, method) allModels = append(allModels, models...) - result[normalisedPackageNames[packageName]] += " " + thisBinding + result[normalisedPackageNames[packageName]] += thisBinding } result[normalisedPackageNames[packageName]] += " },\n" } diff --git a/v3/internal/parser/bindings_test.go b/v3/internal/parser/bindings_test.go index f6f309b10..1fb2a2c0b 100644 --- a/v3/internal/parser/bindings_test.go +++ b/v3/internal/parser/bindings_test.go @@ -110,6 +110,11 @@ func TestGenerateBindings(t *testing.T) { return } // compare the binding + + // convert all line endings to \n + binding = convertLineEndings(binding) + expected = convertLineEndings(expected) + if diff := cmp.Diff(expected, binding); diff != "" { err = os.WriteFile(tt.dir+"/bindings_"+name+".got.js", []byte(binding), 0644) if err != nil { diff --git a/v3/internal/parser/models_test.go b/v3/internal/parser/models_test.go index b2668511e..f91f0b291 100644 --- a/v3/internal/parser/models_test.go +++ b/v3/internal/parser/models_test.go @@ -4,6 +4,7 @@ import ( "github.com/google/go-cmp/cmp" "os" "path/filepath" + "strings" "testing" ) @@ -63,8 +64,10 @@ func TestGenerateModels(t *testing.T) { if err != nil { t.Fatalf("GenerateModels() error = %v", err) } - - if diff := cmp.Diff(tt.want, got); diff != "" { + // convert all line endings to \n + got = convertLineEndings(got) + want := convertLineEndings(tt.want) + if diff := cmp.Diff(want, got); diff != "" { err = os.WriteFile(filepath.Join(tt.dir, "models.got.ts"), []byte(got), 0644) if err != nil { t.Errorf("os.WriteFile() error = %v", err) @@ -75,3 +78,8 @@ func TestGenerateModels(t *testing.T) { }) } } + +func convertLineEndings(str string) string { + // replace all \r\n with \n + return strings.ReplaceAll(str, "\r\n", "\n") +} diff --git a/v3/internal/parser/parser_test.go b/v3/internal/parser/parser_test.go index ea1705daa..c68321913 100644 --- a/v3/internal/parser/parser_test.go +++ b/v3/internal/parser/parser_test.go @@ -40,6 +40,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, { Name: "NoInputsStringOut", @@ -53,6 +54,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1075577233, }, { Name: "StringArrayInputStringOut", @@ -72,6 +74,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1091960237, }, { Name: "StringArrayInputStringArrayOut", @@ -92,6 +95,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 383995060, }, { Name: "StringArrayInputNamedOutput", @@ -113,6 +117,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3678582682, }, { Name: "StringArrayInputNamedOutputs", @@ -140,6 +145,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 319259595, }, { Name: "IntPointerInputNamedOutputs", @@ -166,6 +172,7 @@ func TestParseDirectory(t *testing.T) { Name: "error", }}, }, + ID: 2718999663, }, { Name: "UIntPointerInAndOutput", @@ -186,6 +193,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1367187362, }, { Name: "UInt8PointerInAndOutput", @@ -206,6 +214,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 518250834, }, { Name: "UInt16PointerInAndOutput", @@ -226,6 +235,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1236957573, }, { Name: "UInt32PointerInAndOutput", @@ -246,6 +256,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1739300671, }, { Name: "UInt64PointerInAndOutput", @@ -266,6 +277,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1403757716, }, { Name: "IntPointerInAndOutput", @@ -286,6 +298,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1066151743, }, { Name: "Int8PointerInAndOutput", @@ -306,6 +319,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2189402897, }, { Name: "Int16PointerInAndOutput", @@ -326,6 +340,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1754277916, }, { Name: "Int32PointerInAndOutput", @@ -346,6 +361,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 4251088558, }, { Name: "Int64PointerInAndOutput", @@ -366,6 +382,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2205561041, }, { Name: "IntInIntOut", @@ -384,6 +401,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 642881729, }, { Name: "Int8InIntOut", @@ -402,6 +420,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 572240879, }, { Name: "Int16InIntOut", @@ -420,6 +439,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3306292566, }, { Name: "Int32InIntOut", @@ -438,6 +458,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1909469092, }, { Name: "Int64InIntOut", @@ -456,6 +477,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1343888303, }, { Name: "UIntInUIntOut", @@ -474,6 +496,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2836661285, }, { Name: "UInt8InUIntOut", @@ -492,6 +515,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2988345717, }, { Name: "UInt16InUIntOut", @@ -510,6 +534,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3401034892, }, { Name: "UInt32InUIntOut", @@ -528,6 +553,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1160383782, }, { Name: "UInt64InUIntOut", @@ -546,6 +572,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 793803239, }, { Name: "Float32InFloat32Out", @@ -564,6 +591,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3132595881, }, { Name: "Float64InFloat64Out", @@ -582,6 +610,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2182412247, }, { Name: "PointerFloat32InFloat32Out", @@ -602,6 +631,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 224675106, }, { Name: "PointerFloat64InFloat64Out", @@ -622,6 +652,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2124953624, }, { Name: "BoolInBoolOut", @@ -640,6 +671,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2424639793, }, { Name: "PointerBoolInBoolOut", @@ -660,6 +692,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3589606958, }, { Name: "PointerStringInStringOut", @@ -680,6 +713,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 229603958, }, { Name: "StructPointerInputErrorOutput", @@ -701,6 +735,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2447692557, }, { Name: "StructInputStructOutput", @@ -723,6 +758,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3835643147, }, { Name: "StructPointerInputStructPointerOutput", @@ -747,6 +783,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2943477349, }, { Name: "MapIntInt", @@ -764,6 +801,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2386486356, }, { Name: "PointerMapIntInt", @@ -782,6 +820,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3516977899, }, { Name: "MapIntPointerInt", @@ -800,6 +839,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 550413585, }, { Name: "MapIntSliceInt", @@ -818,6 +858,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 2900172572, }, { Name: "MapIntSliceIntInMapIntSliceIntOut", @@ -851,6 +892,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 881980169, }, { Name: "ArrayInt", @@ -863,6 +905,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 3862002418, }, }, }, @@ -956,11 +999,13 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, }, "OtherService": { { Name: "Hello", + ID: 4249972365, }, }, }, @@ -992,11 +1037,13 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, }, "OtherService": { { Name: "Hello", + ID: 4249972365, }, }, }, @@ -1029,6 +1076,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, { Name: "NewPerson", @@ -1052,6 +1100,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1661412647, }, }, }, @@ -1069,6 +1118,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 469445984, }, }, }, @@ -1149,6 +1199,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, }, }, @@ -1180,6 +1231,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, }, }, @@ -1211,6 +1263,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, { Name: "NewPerson", @@ -1234,6 +1287,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1661412647, }, }, }, @@ -1251,6 +1305,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 302702907, }, }, }, @@ -1331,6 +1386,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, }, }, @@ -1362,6 +1418,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1411160069, }, { Name: "NewPerson", @@ -1385,6 +1442,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 1661412647, }, }, }, @@ -1402,6 +1460,7 @@ func TestParseDirectory(t *testing.T) { }, }, }, + ID: 302702907, }, }, }, diff --git a/v3/internal/parser/testdata/function_from_imported_package/bindings_main.js b/v3/internal/parser/testdata/function_from_imported_package/bindings_main.js index 53a819885..2c02c7608 100644 --- a/v3/internal/parser/testdata/function_from_imported_package/bindings_main.js +++ b/v3/internal/parser/testdata/function_from_imported_package/bindings_main.js @@ -4,40 +4,25 @@ import {main} from './models'; -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * Greet does XYZ - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} - -/** - * GreetService.NewPerson - * NewPerson creates a new person - * @param name {string} - * @returns {Promise} - **/ -function NewPerson(name) { - return wails.Call(GreetService("NewPerson", name)); -} - window.go = window.go || {}; window.go.main = { GreetService: { - Greet, - NewPerson, + + /** + * GreetService.Greet + * Greet does XYZ + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.NewPerson + * NewPerson creates a new person + * @param name {string} + * @returns {Promise} + **/ + NewPerson: function(name) { wails.CallByID(1661412647, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/function_from_imported_package/bindings_services.js b/v3/internal/parser/testdata/function_from_imported_package/bindings_services.js index 48e7ed652..4e2578071 100644 --- a/v3/internal/parser/testdata/function_from_imported_package/bindings_services.js +++ b/v3/internal/parser/testdata/function_from_imported_package/bindings_services.js @@ -4,29 +4,17 @@ import {services} from './models'; -function OtherService(method) { - return { - packageName: "services", - serviceName: "OtherService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * OtherService.Yay - * - * - * @returns {Promise} - **/ -function Yay() { - return wails.Call(OtherService("Yay")); -} - window.go = window.go || {}; window.go.services = { OtherService: { - Yay, + + /** + * OtherService.Yay + * + * + * @returns {Promise} + **/ + Yay: function() { wails.CallByID(302702907, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/struct_literal_multiple/bindings_main.js b/v3/internal/parser/testdata/struct_literal_multiple/bindings_main.js index 277073941..edfdda68a 100644 --- a/v3/internal/parser/testdata/struct_literal_multiple/bindings_main.js +++ b/v3/internal/parser/testdata/struct_literal_multiple/bindings_main.js @@ -2,49 +2,27 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} -function OtherService(method) { - return { - packageName: "main", - serviceName: "OtherService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * OtherService.Hello - * - * - * @returns {Promise} - **/ -function Hello() { - return wails.Call(OtherService("Hello")); -} window.go = window.go || {}; window.go.main = { GreetService: { - Greet, + + /** + * GreetService.Greet + * + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, }, OtherService: { - Hello, + + /** + * OtherService.Hello + * + * + * @returns {Promise} + **/ + Hello: function() { wails.CallByID(4249972365, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/struct_literal_multiple_files/bindings_main.js b/v3/internal/parser/testdata/struct_literal_multiple_files/bindings_main.js index 277073941..edfdda68a 100644 --- a/v3/internal/parser/testdata/struct_literal_multiple_files/bindings_main.js +++ b/v3/internal/parser/testdata/struct_literal_multiple_files/bindings_main.js @@ -2,49 +2,27 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} -function OtherService(method) { - return { - packageName: "main", - serviceName: "OtherService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * OtherService.Hello - * - * - * @returns {Promise} - **/ -function Hello() { - return wails.Call(OtherService("Hello")); -} window.go = window.go || {}; window.go.main = { GreetService: { - Greet, + + /** + * GreetService.Greet + * + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, }, OtherService: { - Hello, + + /** + * OtherService.Hello + * + * + * @returns {Promise} + **/ + Hello: function() { wails.CallByID(4249972365, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_main.js b/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_main.js index 53a819885..2c02c7608 100644 --- a/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_main.js +++ b/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_main.js @@ -4,40 +4,25 @@ import {main} from './models'; -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * Greet does XYZ - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} - -/** - * GreetService.NewPerson - * NewPerson creates a new person - * @param name {string} - * @returns {Promise} - **/ -function NewPerson(name) { - return wails.Call(GreetService("NewPerson", name)); -} - window.go = window.go || {}; window.go.main = { GreetService: { - Greet, - NewPerson, + + /** + * GreetService.Greet + * Greet does XYZ + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.NewPerson + * NewPerson creates a new person + * @param name {string} + * @returns {Promise} + **/ + NewPerson: function(name) { wails.CallByID(1661412647, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_services.js b/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_services.js index 48e7ed652..ec6fb2aeb 100644 --- a/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_services.js +++ b/v3/internal/parser/testdata/struct_literal_multiple_other/bindings_services.js @@ -4,29 +4,17 @@ import {services} from './models'; -function OtherService(method) { - return { - packageName: "services", - serviceName: "OtherService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * OtherService.Yay - * - * - * @returns {Promise} - **/ -function Yay() { - return wails.Call(OtherService("Yay")); -} - window.go = window.go || {}; window.go.services = { OtherService: { - Yay, + + /** + * OtherService.Yay + * + * + * @returns {Promise} + **/ + Yay: function() { wails.CallByID(469445984, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/struct_literal_single/bindings_main.js b/v3/internal/parser/testdata/struct_literal_single/bindings_main.js index 5b3fcd587..893b066bc 100644 --- a/v3/internal/parser/testdata/struct_literal_single/bindings_main.js +++ b/v3/internal/parser/testdata/struct_literal_single/bindings_main.js @@ -4,491 +4,353 @@ import {main} from './models'; -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.ArrayInt - * - * @param _in {number[]} - * @returns {Promise} - **/ -function ArrayInt(_in) { - return wails.Call(GreetService("ArrayInt", _in)); -} - -/** - * GreetService.BoolInBoolOut - * - * @param _in {boolean} - * @returns {Promise} - **/ -function BoolInBoolOut(_in) { - return wails.Call(GreetService("BoolInBoolOut", _in)); -} - -/** - * GreetService.Float32InFloat32Out - * - * @param _in {number} - * @returns {Promise} - **/ -function Float32InFloat32Out(_in) { - return wails.Call(GreetService("Float32InFloat32Out", _in)); -} - -/** - * GreetService.Float64InFloat64Out - * - * @param _in {number} - * @returns {Promise} - **/ -function Float64InFloat64Out(_in) { - return wails.Call(GreetService("Float64InFloat64Out", _in)); -} - -/** - * GreetService.Greet - * Greet someone - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} - -/** - * GreetService.Int16InIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function Int16InIntOut(_in) { - return wails.Call(GreetService("Int16InIntOut", _in)); -} - -/** - * GreetService.Int16PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function Int16PointerInAndOutput(_in) { - return wails.Call(GreetService("Int16PointerInAndOutput", _in)); -} - -/** - * GreetService.Int32InIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function Int32InIntOut(_in) { - return wails.Call(GreetService("Int32InIntOut", _in)); -} - -/** - * GreetService.Int32PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function Int32PointerInAndOutput(_in) { - return wails.Call(GreetService("Int32PointerInAndOutput", _in)); -} - -/** - * GreetService.Int64InIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function Int64InIntOut(_in) { - return wails.Call(GreetService("Int64InIntOut", _in)); -} - -/** - * GreetService.Int64PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function Int64PointerInAndOutput(_in) { - return wails.Call(GreetService("Int64PointerInAndOutput", _in)); -} - -/** - * GreetService.Int8InIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function Int8InIntOut(_in) { - return wails.Call(GreetService("Int8InIntOut", _in)); -} - -/** - * GreetService.Int8PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function Int8PointerInAndOutput(_in) { - return wails.Call(GreetService("Int8PointerInAndOutput", _in)); -} - -/** - * GreetService.IntInIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function IntInIntOut(_in) { - return wails.Call(GreetService("IntInIntOut", _in)); -} - -/** - * GreetService.IntPointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function IntPointerInAndOutput(_in) { - return wails.Call(GreetService("IntPointerInAndOutput", _in)); -} - -/** - * GreetService.IntPointerInputNamedOutputs - * - * @param _in {number | null} - * @returns {Promise} - **/ -function IntPointerInputNamedOutputs(_in) { - return wails.Call(GreetService("IntPointerInputNamedOutputs", _in)); -} - -/** - * GreetService.MapIntInt - * - * @param _in {map} - * @returns {Promise} - **/ -function MapIntInt(_in) { - return wails.Call(GreetService("MapIntInt", _in)); -} - -/** - * GreetService.MapIntPointerInt - * - * @param _in {map} - * @returns {Promise} - **/ -function MapIntPointerInt(_in) { - return wails.Call(GreetService("MapIntPointerInt", _in)); -} - -/** - * GreetService.MapIntSliceInt - * - * @param _in {map} - * @returns {Promise} - **/ -function MapIntSliceInt(_in) { - return wails.Call(GreetService("MapIntSliceInt", _in)); -} - -/** - * GreetService.MapIntSliceIntInMapIntSliceIntOut - * - * @param _in {map} - * @returns {Promise} - **/ -function MapIntSliceIntInMapIntSliceIntOut(_in) { - return wails.Call(GreetService("MapIntSliceIntInMapIntSliceIntOut", _in)); -} - -/** - * GreetService.NoInputsStringOut - * - * - * @returns {Promise} - **/ -function NoInputsStringOut() { - return wails.Call(GreetService("NoInputsStringOut")); -} - -/** - * GreetService.PointerBoolInBoolOut - * - * @param _in {boolean | null} - * @returns {Promise} - **/ -function PointerBoolInBoolOut(_in) { - return wails.Call(GreetService("PointerBoolInBoolOut", _in)); -} - -/** - * GreetService.PointerFloat32InFloat32Out - * - * @param _in {number | null} - * @returns {Promise} - **/ -function PointerFloat32InFloat32Out(_in) { - return wails.Call(GreetService("PointerFloat32InFloat32Out", _in)); -} - -/** - * GreetService.PointerFloat64InFloat64Out - * - * @param _in {number | null} - * @returns {Promise} - **/ -function PointerFloat64InFloat64Out(_in) { - return wails.Call(GreetService("PointerFloat64InFloat64Out", _in)); -} - -/** - * GreetService.PointerMapIntInt - * - * @param _in {map | null} - * @returns {Promise} - **/ -function PointerMapIntInt(_in) { - return wails.Call(GreetService("PointerMapIntInt", _in)); -} - -/** - * GreetService.PointerStringInStringOut - * - * @param _in {string | null} - * @returns {Promise} - **/ -function PointerStringInStringOut(_in) { - return wails.Call(GreetService("PointerStringInStringOut", _in)); -} - -/** - * GreetService.StringArrayInputNamedOutput - * - * @param _in {string[]} - * @returns {Promise} - **/ -function StringArrayInputNamedOutput(_in) { - return wails.Call(GreetService("StringArrayInputNamedOutput", _in)); -} - -/** - * GreetService.StringArrayInputNamedOutputs - * - * @param _in {string[]} - * @returns {Promise} - **/ -function StringArrayInputNamedOutputs(_in) { - return wails.Call(GreetService("StringArrayInputNamedOutputs", _in)); -} - -/** - * GreetService.StringArrayInputStringArrayOut - * - * @param _in {string[]} - * @returns {Promise} - **/ -function StringArrayInputStringArrayOut(_in) { - return wails.Call(GreetService("StringArrayInputStringArrayOut", _in)); -} - -/** - * GreetService.StringArrayInputStringOut - * - * @param _in {string[]} - * @returns {Promise} - **/ -function StringArrayInputStringOut(_in) { - return wails.Call(GreetService("StringArrayInputStringOut", _in)); -} - -/** - * GreetService.StructInputStructOutput - * - * @param _in {main.Person} - * @returns {Promise} - **/ -function StructInputStructOutput(_in) { - return wails.Call(GreetService("StructInputStructOutput", _in)); -} - -/** - * GreetService.StructPointerInputErrorOutput - * - * @param _in {main.Person | null} - * @returns {Promise} - **/ -function StructPointerInputErrorOutput(_in) { - return wails.Call(GreetService("StructPointerInputErrorOutput", _in)); -} - -/** - * GreetService.StructPointerInputStructPointerOutput - * - * @param _in {main.Person | null} - * @returns {Promise} - **/ -function StructPointerInputStructPointerOutput(_in) { - return wails.Call(GreetService("StructPointerInputStructPointerOutput", _in)); -} - -/** - * GreetService.UInt16InUIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function UInt16InUIntOut(_in) { - return wails.Call(GreetService("UInt16InUIntOut", _in)); -} - -/** - * GreetService.UInt16PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function UInt16PointerInAndOutput(_in) { - return wails.Call(GreetService("UInt16PointerInAndOutput", _in)); -} - -/** - * GreetService.UInt32InUIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function UInt32InUIntOut(_in) { - return wails.Call(GreetService("UInt32InUIntOut", _in)); -} - -/** - * GreetService.UInt32PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function UInt32PointerInAndOutput(_in) { - return wails.Call(GreetService("UInt32PointerInAndOutput", _in)); -} - -/** - * GreetService.UInt64InUIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function UInt64InUIntOut(_in) { - return wails.Call(GreetService("UInt64InUIntOut", _in)); -} - -/** - * GreetService.UInt64PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function UInt64PointerInAndOutput(_in) { - return wails.Call(GreetService("UInt64PointerInAndOutput", _in)); -} - -/** - * GreetService.UInt8InUIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function UInt8InUIntOut(_in) { - return wails.Call(GreetService("UInt8InUIntOut", _in)); -} - -/** - * GreetService.UInt8PointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function UInt8PointerInAndOutput(_in) { - return wails.Call(GreetService("UInt8PointerInAndOutput", _in)); -} - -/** - * GreetService.UIntInUIntOut - * - * @param _in {number} - * @returns {Promise} - **/ -function UIntInUIntOut(_in) { - return wails.Call(GreetService("UIntInUIntOut", _in)); -} - -/** - * GreetService.UIntPointerInAndOutput - * - * @param _in {number | null} - * @returns {Promise} - **/ -function UIntPointerInAndOutput(_in) { - return wails.Call(GreetService("UIntPointerInAndOutput", _in)); -} - window.go = window.go || {}; window.go.main = { GreetService: { - ArrayInt, - BoolInBoolOut, - Float32InFloat32Out, - Float64InFloat64Out, - Greet, - Int16InIntOut, - Int16PointerInAndOutput, - Int32InIntOut, - Int32PointerInAndOutput, - Int64InIntOut, - Int64PointerInAndOutput, - Int8InIntOut, - Int8PointerInAndOutput, - IntInIntOut, - IntPointerInAndOutput, - IntPointerInputNamedOutputs, - MapIntInt, - MapIntPointerInt, - MapIntSliceInt, - MapIntSliceIntInMapIntSliceIntOut, - NoInputsStringOut, - PointerBoolInBoolOut, - PointerFloat32InFloat32Out, - PointerFloat64InFloat64Out, - PointerMapIntInt, - PointerStringInStringOut, - StringArrayInputNamedOutput, - StringArrayInputNamedOutputs, - StringArrayInputStringArrayOut, - StringArrayInputStringOut, - StructInputStructOutput, - StructPointerInputErrorOutput, - StructPointerInputStructPointerOutput, - UInt16InUIntOut, - UInt16PointerInAndOutput, - UInt32InUIntOut, - UInt32PointerInAndOutput, - UInt64InUIntOut, - UInt64PointerInAndOutput, - UInt8InUIntOut, - UInt8PointerInAndOutput, - UIntInUIntOut, - UIntPointerInAndOutput, + + /** + * GreetService.ArrayInt + * + * @param _in {number[]} + * @returns {Promise} + **/ + ArrayInt: function(_in) { wails.CallByID(3862002418, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.BoolInBoolOut + * + * @param _in {boolean} + * @returns {Promise} + **/ + BoolInBoolOut: function(_in) { wails.CallByID(2424639793, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Float32InFloat32Out + * + * @param _in {number} + * @returns {Promise} + **/ + Float32InFloat32Out: function(_in) { wails.CallByID(3132595881, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Float64InFloat64Out + * + * @param _in {number} + * @returns {Promise} + **/ + Float64InFloat64Out: function(_in) { wails.CallByID(2182412247, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Greet + * Greet someone + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int16InIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + Int16InIntOut: function(_in) { wails.CallByID(3306292566, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int16PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + Int16PointerInAndOutput: function(_in) { wails.CallByID(1754277916, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int32InIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + Int32InIntOut: function(_in) { wails.CallByID(1909469092, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int32PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + Int32PointerInAndOutput: function(_in) { wails.CallByID(4251088558, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int64InIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + Int64InIntOut: function(_in) { wails.CallByID(1343888303, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int64PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + Int64PointerInAndOutput: function(_in) { wails.CallByID(2205561041, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int8InIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + Int8InIntOut: function(_in) { wails.CallByID(572240879, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.Int8PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + Int8PointerInAndOutput: function(_in) { wails.CallByID(2189402897, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.IntInIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + IntInIntOut: function(_in) { wails.CallByID(642881729, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.IntPointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + IntPointerInAndOutput: function(_in) { wails.CallByID(1066151743, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.IntPointerInputNamedOutputs + * + * @param _in {number | null} + * @returns {Promise} + **/ + IntPointerInputNamedOutputs: function(_in) { wails.CallByID(2718999663, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.MapIntInt + * + * @param _in {map} + * @returns {Promise} + **/ + MapIntInt: function(_in) { wails.CallByID(2386486356, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.MapIntPointerInt + * + * @param _in {map} + * @returns {Promise} + **/ + MapIntPointerInt: function(_in) { wails.CallByID(550413585, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.MapIntSliceInt + * + * @param _in {map} + * @returns {Promise} + **/ + MapIntSliceInt: function(_in) { wails.CallByID(2900172572, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.MapIntSliceIntInMapIntSliceIntOut + * + * @param _in {map} + * @returns {Promise} + **/ + MapIntSliceIntInMapIntSliceIntOut: function(_in) { wails.CallByID(881980169, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.NoInputsStringOut + * + * + * @returns {Promise} + **/ + NoInputsStringOut: function() { wails.CallByID(1075577233, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.PointerBoolInBoolOut + * + * @param _in {boolean | null} + * @returns {Promise} + **/ + PointerBoolInBoolOut: function(_in) { wails.CallByID(3589606958, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.PointerFloat32InFloat32Out + * + * @param _in {number | null} + * @returns {Promise} + **/ + PointerFloat32InFloat32Out: function(_in) { wails.CallByID(224675106, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.PointerFloat64InFloat64Out + * + * @param _in {number | null} + * @returns {Promise} + **/ + PointerFloat64InFloat64Out: function(_in) { wails.CallByID(2124953624, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.PointerMapIntInt + * + * @param _in {map | null} + * @returns {Promise} + **/ + PointerMapIntInt: function(_in) { wails.CallByID(3516977899, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.PointerStringInStringOut + * + * @param _in {string | null} + * @returns {Promise} + **/ + PointerStringInStringOut: function(_in) { wails.CallByID(229603958, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StringArrayInputNamedOutput + * + * @param _in {string[]} + * @returns {Promise} + **/ + StringArrayInputNamedOutput: function(_in) { wails.CallByID(3678582682, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StringArrayInputNamedOutputs + * + * @param _in {string[]} + * @returns {Promise} + **/ + StringArrayInputNamedOutputs: function(_in) { wails.CallByID(319259595, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StringArrayInputStringArrayOut + * + * @param _in {string[]} + * @returns {Promise} + **/ + StringArrayInputStringArrayOut: function(_in) { wails.CallByID(383995060, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StringArrayInputStringOut + * + * @param _in {string[]} + * @returns {Promise} + **/ + StringArrayInputStringOut: function(_in) { wails.CallByID(1091960237, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StructInputStructOutput + * + * @param _in {main.Person} + * @returns {Promise} + **/ + StructInputStructOutput: function(_in) { wails.CallByID(3835643147, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StructPointerInputErrorOutput + * + * @param _in {main.Person | null} + * @returns {Promise} + **/ + StructPointerInputErrorOutput: function(_in) { wails.CallByID(2447692557, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.StructPointerInputStructPointerOutput + * + * @param _in {main.Person | null} + * @returns {Promise} + **/ + StructPointerInputStructPointerOutput: function(_in) { wails.CallByID(2943477349, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt16InUIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + UInt16InUIntOut: function(_in) { wails.CallByID(3401034892, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt16PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + UInt16PointerInAndOutput: function(_in) { wails.CallByID(1236957573, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt32InUIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + UInt32InUIntOut: function(_in) { wails.CallByID(1160383782, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt32PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + UInt32PointerInAndOutput: function(_in) { wails.CallByID(1739300671, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt64InUIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + UInt64InUIntOut: function(_in) { wails.CallByID(793803239, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt64PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + UInt64PointerInAndOutput: function(_in) { wails.CallByID(1403757716, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt8InUIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + UInt8InUIntOut: function(_in) { wails.CallByID(2988345717, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UInt8PointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + UInt8PointerInAndOutput: function(_in) { wails.CallByID(518250834, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UIntInUIntOut + * + * @param _in {number} + * @returns {Promise} + **/ + UIntInUIntOut: function(_in) { wails.CallByID(2836661285, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.UIntPointerInAndOutput + * + * @param _in {number | null} + * @returns {Promise} + **/ + UIntPointerInAndOutput: function(_in) { wails.CallByID(1367187362, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/variable_single/bindings_main.js b/v3/internal/parser/testdata/variable_single/bindings_main.js index 0a156d149..c9a4675b5 100644 --- a/v3/internal/parser/testdata/variable_single/bindings_main.js +++ b/v3/internal/parser/testdata/variable_single/bindings_main.js @@ -2,28 +2,17 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * Greet someone - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} window.go = window.go || {}; window.go.main = { GreetService: { - Greet, + + /** + * GreetService.Greet + * Greet someone + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/variable_single_from_function/bindings_main.js b/v3/internal/parser/testdata/variable_single_from_function/bindings_main.js index 0a156d149..c9a4675b5 100644 --- a/v3/internal/parser/testdata/variable_single_from_function/bindings_main.js +++ b/v3/internal/parser/testdata/variable_single_from_function/bindings_main.js @@ -2,28 +2,17 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * Greet someone - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} window.go = window.go || {}; window.go.main = { GreetService: { - Greet, + + /** + * GreetService.Greet + * Greet someone + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/variable_single_from_other_function/bindings_main.js b/v3/internal/parser/testdata/variable_single_from_other_function/bindings_main.js index 53a819885..2c02c7608 100644 --- a/v3/internal/parser/testdata/variable_single_from_other_function/bindings_main.js +++ b/v3/internal/parser/testdata/variable_single_from_other_function/bindings_main.js @@ -4,40 +4,25 @@ import {main} from './models'; -function GreetService(method) { - return { - packageName: "main", - serviceName: "GreetService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * GreetService.Greet - * Greet does XYZ - * @param name {string} - * @returns {Promise} - **/ -function Greet(name) { - return wails.Call(GreetService("Greet", name)); -} - -/** - * GreetService.NewPerson - * NewPerson creates a new person - * @param name {string} - * @returns {Promise} - **/ -function NewPerson(name) { - return wails.Call(GreetService("NewPerson", name)); -} - window.go = window.go || {}; window.go.main = { GreetService: { - Greet, - NewPerson, + + /** + * GreetService.Greet + * Greet does XYZ + * @param name {string} + * @returns {Promise} + **/ + Greet: function(name) { wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, + + /** + * GreetService.NewPerson + * NewPerson creates a new person + * @param name {string} + * @returns {Promise} + **/ + NewPerson: function(name) { wails.CallByID(1661412647, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/parser/testdata/variable_single_from_other_function/bindings_services.js b/v3/internal/parser/testdata/variable_single_from_other_function/bindings_services.js index 48e7ed652..4e2578071 100644 --- a/v3/internal/parser/testdata/variable_single_from_other_function/bindings_services.js +++ b/v3/internal/parser/testdata/variable_single_from_other_function/bindings_services.js @@ -4,29 +4,17 @@ import {services} from './models'; -function OtherService(method) { - return { - packageName: "services", - serviceName: "OtherService", - methodName: method, - args: Array.prototype.slice.call(arguments, 1), - }; -} - -/** - * OtherService.Yay - * - * - * @returns {Promise} - **/ -function Yay() { - return wails.Call(OtherService("Yay")); -} - window.go = window.go || {}; window.go.services = { OtherService: { - Yay, + + /** + * OtherService.Yay + * + * + * @returns {Promise} + **/ + Yay: function() { wails.CallByID(302702907, ...Array.prototype.slice.call(arguments, 0)); }, }, }; diff --git a/v3/internal/templates/templates_test.go b/v3/internal/templates/templates_test.go index 25fa790b5..25263106e 100644 --- a/v3/internal/templates/templates_test.go +++ b/v3/internal/templates/templates_test.go @@ -1,14 +1,14 @@ package templates import ( + "os" "testing" "github.com/wailsapp/wails/v3/internal/flags" ) func TestInstall(t *testing.T) { - type args struct { - } + tests := []struct { name string options *flags.Init @@ -25,6 +25,10 @@ func TestInstall(t *testing.T) { }, } for _, tt := range tests { + // Remove test directory if it exists + if _, err := os.Stat(tt.options.ProjectName); err == nil { + _ = os.RemoveAll(tt.options.ProjectName) + } t.Run(tt.name, func(t *testing.T) { if err := Install(tt.options); (err != nil) != tt.wantErr { t.Errorf("Install() error = %v, wantErr %v", err, tt.wantErr)