[GSoC 2017] Coding period Week2 with gopy@CERN-HSF

GSoC2017 Hi, guys! This post is about what I did on the 2nd week of the coding period for Google Summer of Code 2017.

This week I worked for supporting vars and consts by CFFI backend engine. Go has the concept of const and vars, but since Python does not have a 1: 1 equivalent concept so gopy provides a Get / Set function to make it available. If you want to know more about them. Please read this link.

Anyway, to provide this features by CFFI engine, I wrote codes to generate get/set functions by using CFFI. Also, I added the unit test codes for checking these features are working well. Here is a list of unit tests which are supported by CFFI engine.

Finally, I submitted the pull request. Sebastien requested me to add doc strings for the Get/Set functions, So I added them. And then, my PR was merged into the code base. :)

Now you can use consts and vars concepts on the PyPy and Python3. Here is the example.

[PyPy 5.1.2 with GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import vars
>>>> dir(vars)
['GetKind1', 'GetKind2', 'GetV1', 'GetV2', 'GetV3', 'GetV4', 'GetV5', 'GetV6', 'GetV7', 'SetKind1', 
'SetKind2', 'SetV1', 'SetV2', 'SetV3', 'SetV4', 'SetV5', 'SetV6', 'SetV7', '__builtins__', '__cached__', '__doc
__', '__file__', '__name__', '__package__', '_cffi_backend', '_cffi_helper', 'ffi', 'os']
>>>> v1 = vars.GetV1()
>>>> v1
'v1'
>>>> vars.SetV1("new v1")
>>>> v1 = vars.GetV1()
>>>> v1
'new v1'

On the week3, I worked on gencffi: Detect functions returning a Go error. I will talk about it in the next post. Thank you.

Happy hacking

Written on June 17, 2017