Commit Graph

133 Commits

Author SHA1 Message Date
Randall C. O'Reilly 49f82061f6 need to run files through format or goimports.. 2024-05-03 14:30:03 -07:00
Evan Oman f16e21bc0e Adds missing pointer reference for slices along with test 2024-04-22 21:39:40 -05:00
Noam Kleinburd e6a14f8cac Implement efficient copies of bytes. 2023-12-13 11:20:35 +02:00
Randall C. O'Reilly d2379001f2 reformat variadic 2022-11-15 02:28:05 -08:00
Noam Kleinburd 51cf93edab Test complex slices. 2022-11-13 16:46:50 +02:00
Randall C. O'Reilly 9c83d3f7c3 update support matrix, add setup.py example in README, gofmt files. 2022-06-19 01:58:22 -07:00
Nishant Sharma 4eeeffb2ca Interface test also passing. 2022-06-06 19:50:23 +05:30
Nishant Sharma 04688ca746 Variadic functions with variable number of struct inputs now working. 2022-06-06 19:42:36 +05:30
Nishant Sharma ece09eda60 One test case of variadic functions now passing. More to clear. 2022-06-06 11:20:23 +05:30
Randall C. O'Reilly 691b7e025e major fix: create an import alias for package name conflicts -- e.g., adding goplot font package conflicts with image/font.. added pkgconflict test case 2021-08-29 02:55:02 -07:00
Justin Israel 84915debe0 bind: WIP add checks for exception being set in wrapped python functions
This commit starts to address the issue of a non-NULL PyObject* being returned when an exception has been set by the wrapped C function. Adds a checking mechanism for PyErr_Occurred. Results in exceptions being propagated to python caller, but may introduce memory leaks for retval not being cleaned up during error.

Refs go-python/gopy #254
2021-04-05 07:55:27 +12:00
Justin Israel ac5c077a97
main,bind: extended gopy:name control, auto PEP8 naming, and property docstring support
This commit provides an option to automatically rename functions, methods, and properties to PEP-style snake_case when generating code.
2021-03-26 09:16:11 +01:00
Justin Israel 8ab2cac131
main,bind,_examples: use absolute package imports and make configurable
This CL fixes an issue with the way python import statements are generated using an realtive current directory approach that is no longer compatible with python3. The default behavior has been updated to default to a dot-relative absolute package import for "go" and compiled extension, and a configuration option has been exposed from the CLI flags down to the bind package.
A refactor of configuration options was added to avoid further expanding the number of arguments being passed through the system.

Fixes go-python/gopy#239
2021-03-17 22:02:07 +01:00
Justin Israel 7bd7360fdf
main,bind,_examples: fix tests for go 1.16
* main,bind,_examples: fix tests for go 1.16

This CL fixes a number of tests that are failing under go 1.16.
Modules behave a bit differently, the //comment directives now
need a space, generated version file needs go fmt, and there was a
mis-named symbol

* ci: Update travis and appveyor for recent Go and fix pypy download links

* ci: fix typo in travis script, and adjust go to max appveyor version

* ci: update appveyor PATH to pick up proper latest go version

* fix: Re-enable test cleanup

* ci: update appveyor to pin GOROOT

* ci: update appveyor to use latest windows image
2021-03-16 12:51:57 +01:00
Cosmos Nicolaou ac88620b22
_examples,bind: add a test for types.Named
This CL adds a test for #220.
2020-03-27 18:58:43 +01:00
Cosmos Nicolaou 299c7e9a43
gopy,bind: fix storage leaks due to C.Cstring allocations w/ pybindgen
As noted in #186 the use of C.Cstring in conjunction with pybindgen leads to storage leaks. This CL attempts at fixing those by patching the output of pybindgen to call free on the leaked strings.

NOTE, that I plan to look at pybindgen to add an option to it so that it can generate the correct code. In the meantime, I think this change is useful to have since it makes the generated code much more usable.

Fixes #186.
2020-02-19 09:31:07 +01:00
Cosmos Nicolaou 5266c83347
gopy,bind: improve error reporting for python-incompatible methods and funcs 2020-02-19 09:26:10 +01:00
Cosmos Nicolaou 35472c0b14
gopy,gopyh,bind: allow for deletion of handles from the map in gopyh
- add support for deleting gopyh handles
- add support for checking arguments' type

Fixes #217.
2020-02-18 22:59:10 +01:00
Sebastien Binet 7e6560ef62
bind: slice elem method auto-wraps the handle, also maps
* fixes issue #191 (slice elem method auto-wraps the handle, including extra tests in slices), and fixes py wrapper imports to include everything referenced.

* also wrap handles for map __getitem__

* also rm gopy exe

* update after previewing PR: remove gopy.gide, don't print extra py imports, undo one usage change.

* one more cmd-exe fix
2019-09-30 15:32:05 +02:00
Randall C. O'Reilly 780132b629 final update of goki -> go-python -- my pass should be complete here and now just awaiting final review for PR merge. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly ec3f125415 should be last fixes before switching over paths and pulling from PR etc: added osfile example test, which uses pkg and imports os -- needed some fixes to get os package to parse, including fixing error conversion from string, and dealing with func literals with no arg names. osfile doesn't actually work b/c python import only working after install -- not worth doing install for test. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly e28bf163ce added __contains__ for maps so std python "in" syntax works for checking keys. added to tests. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 4590bed3b4 add support for 1 return value of a basic type in callbacks: could support other types too with extra testing. also support for optional goRun arg which calls with "go" to run in a different goroutine. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 9e491ab3da most of PR review comments addressed -- few more to tackle tmrw. haven't changed import paths yet b/c still working out of my dir -- will do that as a last step. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly d39a3c49d4 added gopy:interface=handle doc directive to interpret interface{} args as handles instead of strings; fix go.nil to be a variable not a class; uncomment RemoveAll for main_test work dir; remove more stuff from maps test out to enable consistency; add tests for go.nil, new interface functionality. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly e381500a36 verified building on py2 and most tests work except for a few minor diffs in output -- calling it good enough for now. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 8d98f0953a all tests now passing except maps.. also need to test py2 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly ad11d2281e tried to support method callbacks but couldn't get it to work outside of small test case.. not sure what the issues are. updated readme 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 8c4f9979b4 added exe command mode -- builds an executable that has all the go packages built-in and can interpreter in non-main thread. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly a3e0c68e25 gi callbacks working -- needed GILState_Ensure etc. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 697577b7f4 python callback fully implemented -- one last thing is dealing with return values properly.. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 179e37fa2d basic proof-of-concept for arg passing, working for int case -- just need a type switch. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 0579b79b83 basic no-args callback function call works -- need more tricks to build arg values b/c key function requires var args. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 24e505f408 basic mechanics of multi-package working -- need to be able to import multiple packages easily in python -- look into install etc 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 5aa404702f more progress on slices, basic named types 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly e1b8e53da3 cleanup, start on slices etc. 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 0f4150ee20 added interface type -- now just need slices and maps and then done! 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly b1541e1795 variables and constants get / set functions, and more bind code cleanup 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly d81b4710eb generalized handle code beyond pointer -- working for full structs -- always need to convert back and forth to / from pointer for handle 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 7bbe20f501 field getters and setters 2019-08-24 10:31:16 +02:00
Randall C. O'Reilly 30c52c90d3 major progress: function execution all working with pointer args -- encodes type name along with counter and does type-safe checks so it won't fail on the conversion. bind command builds using pybindgen. 2019-08-24 10:31:16 +02:00
Sebastien Binet fbb477f2ae tests: fix exit code 2019-01-16 16:18:59 +01:00
Ondřej Herman cbb791395e gopy/bind: pass Go strings to Python as Unicode objects 2019-01-16 09:40:56 +01:00
Ondřej Herman 7712a09f47 gopy/bind: support both byte and Unicode strings as function parameters 2019-01-16 09:40:56 +01:00
Ondřej Herman b43954fc33 gopy/bind: enable subclassing of generated CPython objects 2019-01-15 18:02:29 +01:00
Ondřej Herman f9e088d468 gopy/bind: add CFFI converters for fixed width integer types 2018-11-29 02:00:51 +09:00
Ondřej Herman 5f71fa457c gopy/bind: support some instances of pointer-to-slice parameters
Adds support for pointers to slices as output parameters:

    type StrVector []string
    func Fill (out *StrVector) {
        *out = []string{A, B}
    }


Co-authored-by: Ondřej Herman <xherman1@fi.muni.cz>
Co-authored-by: Pavel Rychlý <pary@fi.muni.cz>
2018-06-14 09:12:34 +02:00
Ondřej Herman e50b2d5a63 gopy/bind: implement gopy:name renaming directive
Adds support for changing the names of methods and
functions in the generated Python library. For example,
the following function will be available as under the name
`hello`:

    //gopy:name hello
    func Hello() string { return Hello }


Co-authored-by: Ondřej Herman <xherman1@fi.muni.cz>
Co-authored-by: Pavel Rychlý <pary@fi.muni.cz>
2018-06-14 09:08:42 +02:00
Dong-hee Na c6fa07af03 cffi: Fix invalid syntax for slices in generated Python 2018-03-27 14:01:34 +02:00
Dong-hee Na b237d1d6c6 bind/cffi: support built-in maps
* Support built-in maps.
* Support maps as arguments of a function.
* Support python dictionary as function parameters.
* Add 'maps' test
2017-08-10 20:17:03 +02:00