You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@apache.org> on 2018/03/13 14:44:08 UTC
Updating swig-py bindings
Troy (or others), I want to use swig-py bindings for my new shelving API
(in svn_client.h) so I am trying to update them. I started by looking at
the 'Missing argout typemap' warnings for svn_client.h.
As well as svn_shelf_* functions, also the svn_client_conflict_* set of
functions currently lack bindings so I thought I might as well try to do
those at the same time.
First some easy bits:
[[[
Index: subversion/bindings/swig/include/svn_containers.swg
===================================================================
--- subversion/bindings/swig/include/svn_containers.swg (revision 1826621)
+++ subversion/bindings/swig/include/svn_containers.swg (working copy)
@@ -527,7 +527,10 @@
apr_array_header_t **logfiles,
apr_array_header_t **names_p,
apr_array_header_t **targets_p,
- apr_array_header_t **args_p
+ apr_array_header_t **args_p,
+ apr_array_header_t **possible_moved_to_repos_relpaths,
+ apr_array_header_t **possible_moved_to_abspaths,
+ apr_array_header_t **props_conflicted
};
/* -----------------------------------------------------------------------
Index: subversion/bindings/swig/include/svn_types.swg
===================================================================
--- subversion/bindings/swig/include/svn_types.swg (revision 1826621)
+++ subversion/bindings/swig/include/svn_types.swg (working copy)
@@ -119,6 +119,11 @@
svn_client_commit_info_t **,
svn_client_ctx_t **,
const svn_client_commit_item3_t **,
+ svn_client_conflict_t **,
+ svn_client_conflict_option_t **,
+ svn_client_shelf_t **,
+ svn_client_shelf_version_t **,
+ svn_client_shelf_info_t **,
/* svn_delta */
const svn_delta_editor_t **,
svn_txdelta_stream_t **,
]]]
Now the harder ones.
subversion/include/svn_client.h:4793: Warning 900: FIXME: Missing argout
typemap
subversion/include/svn_client.h:4806: Warning 900: FIXME: Missing argout
typemap
subversion/include/svn_client.h:4823: Warning 900: FIXME: Missing argout
typemap
These three all look like:
svn_client_conflict_text_get_resolution_options(
apr_array_header_t **options,
an array of pointer to svn_client_conflict_option_t which is an opaque
object.
I can see an "%opaque_proxy(svn_client_conflict_t);" declaration has
already been produced in 'proxy/svn_client_h.swg'. What more is needed?
subversion/include/svn_client.h:7028: Warning 900: FIXME: Missing argout
typemap
svn_client_shelf_get_all_versions(apr_array_header_t **versions_p,
an array of pointer to svn_client_shelf_version_t which is a public
non-opaque struct.
subversion/include/svn_client.h:7079: Warning 900: FIXME: Missing argout
typemap
subversion/include/svn_client.h:7176: Warning 900: FIXME: Missing argout
typemap
subversion/include/svn_client.h:7201: Warning 900: FIXME: Missing argout
typemap
And so on.
Any help would be appreciated!
Thanks,
- Julian
Re: Updating swig-py bindings
Posted by Julian Foad <ju...@apache.org>.
Branko Čibej wrote:
> For anyone who wants to work on updating the bindings: note that we have
> a lot of language-specific stuff in there that's a consequence of Swig 1
> not knowing any better back in the day. Most of those typemaps can be
> made language-independent (thus reducing the size of the Swig files)
> with features from Swig 2 and especially 3, which introduced built-in
> constructs for handling various kinds of data structures that we're
> currently mapping separately for each target language.
Hooray! I was hoping that might be the case.
Another thought. Some comments and code in the current bindings seem
to indicate that a few of our C APIs are written in a way that makes
it harder to bind in a 'natural' way. We could consider changing those
C APIs to use idioms that bind better.
Here is something that at first seemed a very trivial update: adding
'const' to apr_array_header_t input parameters. I added 'const' across
all instances in our C API many years ago (and I see just one that lacks
it now: svn_repos_freeze()), so we can update the typemaps and remove
the obsolete comment seen in the following patch:
[[[
Index: subversion/bindings/swig/include/svn_containers.swg
===================================================================
--- subversion/bindings/swig/include/svn_containers.swg (revision 1826615)
+++ subversion/bindings/swig/include/svn_containers.swg (working copy)
@@ -639,26 +639,18 @@
}
#endif
-/* svn_delta_path_driver() mutates its 'paths' argument (by sorting it),
- despite the fact that it is notionally an input parameter - hence, the
- lack of 'const' in that one case.
-
- svn_wc_get_update_editor3() and svn_wc_get_switch_editor3() aren't changing
- their 'preserved_exts' argument, but it is forwarded to
- svn_cstring_match_glob_list which also doesn't modify it, but does not have
- const in its prototype. */
%apply const apr_array_header_t *STRINGLIST {
const apr_array_header_t *args,
const apr_array_header_t *diff_options,
- apr_array_header_t *paths,
- apr_array_header_t *revprops,
+ const apr_array_header_t *paths,
+ const apr_array_header_t *revprops,
const apr_array_header_t *targets,
- apr_array_header_t *preserved_exts
+ const apr_array_header_t *preserved_exts
};
#if defined(SWIGPERL) || defined(SWIGRUBY)
%apply const apr_array_header_t *STRINGLIST_MAY_BE_NULL {
- apr_array_header_t *revprops
+ const apr_array_header_t *revprops
};
#endif
]]]
But then I went on through that file doing the same thing until I came to
one where both input and output typemaps are applied to the same pattern
(in Ruby):
[[[
#ifdef SWIGRUBY
%typemap(in) apr_array_header_t *PROP_LIST
{
VALUE rb_pool;
apr_pool_t *pool;
svn_swig_rb_get_pool(argc, argv, self, &rb_pool, &pool);
$1 = svn_swig_rb_to_apr_array_prop($input, pool);
}
%typemap(out) apr_array_header_t *PROP_LIST
{
%append_output(svn_swig_rb_prop_apr_array_to_hash_prop($1));
}
[...]
%apply apr_array_header_t *PROP_LIST {
apr_array_header_t *wcprop_changes,
apr_array_header_t *propchanges
};
]]]
Now, a 'wcprop_changes' identifier appears not only as function arguments
(with 'const') but also as a field in 'svn_client_commit_item2_t' (without).
At this point I am for the time being out of my depth -- I don't know enough
to know where to add 'const' and where not.
I'll try to learn more Swig, sooner or later.
- Julian
Re: Updating swig-py bindings
Posted by Branko Čibej <br...@apache.org>.
On 14.03.2018 04:24, Troy Curtis Jr wrote:
> On Tue, Mar 13, 2018 at 9:44 AM Julian Foad <ju...@apache.org> wrote:
>
>> Troy (or others), I want to use swig-py bindings for my new shelving API
>> (in svn_client.h) so I am trying to update them. I started by looking at
>> the 'Missing argout typemap' warnings for svn_client.h.
>>
>> As well as svn_shelf_* functions, also the svn_client_conflict_* set of
>> functions currently lack bindings so I thought I might as well try to do
>> those at the same time.
>>
>> First some easy bits:
>>
>> [[[
>> Index: subversion/bindings/swig/include/svn_containers.swg
>> ===================================================================
>> --- subversion/bindings/swig/include/svn_containers.swg (revision 1826621)
>> +++ subversion/bindings/swig/include/svn_containers.swg (working copy)
>> @@ -527,7 +527,10 @@
>> apr_array_header_t **logfiles,
>> apr_array_header_t **names_p,
>> apr_array_header_t **targets_p,
>> - apr_array_header_t **args_p
>> + apr_array_header_t **args_p,
>> + apr_array_header_t **possible_moved_to_repos_relpaths,
>> + apr_array_header_t **possible_moved_to_abspaths,
>> + apr_array_header_t **props_conflicted
>> };
>>
>> /*
>> -----------------------------------------------------------------------
>> Index: subversion/bindings/swig/include/svn_types.swg
>> ===================================================================
>> --- subversion/bindings/swig/include/svn_types.swg (revision 1826621)
>> +++ subversion/bindings/swig/include/svn_types.swg (working copy)
>> @@ -119,6 +119,11 @@
>> svn_client_commit_info_t **,
>> svn_client_ctx_t **,
>> const svn_client_commit_item3_t **,
>> + svn_client_conflict_t **,
>> + svn_client_conflict_option_t **,
>> + svn_client_shelf_t **,
>> + svn_client_shelf_version_t **,
>> + svn_client_shelf_info_t **,
>> /* svn_delta */
>> const svn_delta_editor_t **,
>> svn_txdelta_stream_t **,
>> ]]]
>>
>> Now the harder ones.
>>
>> subversion/include/svn_client.h:4793: Warning 900: FIXME: Missing argout
>> typemap
>> subversion/include/svn_client.h:4806: Warning 900: FIXME: Missing argout
>> typemap
>> subversion/include/svn_client.h:4823: Warning 900: FIXME: Missing argout
>> typemap
>>
>> These three all look like:
>>
>> svn_client_conflict_text_get_resolution_options(
>> apr_array_header_t **options,
>>
>> an array of pointer to svn_client_conflict_option_t which is an opaque
>> object.
>>
>> I can see an "%opaque_proxy(svn_client_conflict_t);" declaration has
>> already been produced in 'proxy/svn_client_h.swg'. What more is needed?
>>
>> subversion/include/svn_client.h:7028: Warning 900: FIXME: Missing argout
>> typemap
>>
>> svn_client_shelf_get_all_versions(apr_array_header_t **versions_p,
>>
>> an array of pointer to svn_client_shelf_version_t which is a public
>> non-opaque struct.
>>
>> subversion/include/svn_client.h:7079: Warning 900: FIXME: Missing argout
>> typemap
>> subversion/include/svn_client.h:7176: Warning 900: FIXME: Missing argout
>> typemap
>> subversion/include/svn_client.h:7201: Warning 900: FIXME: Missing argout
>> typemap
>>
>> And so on.
>>
>> Any help would be appreciated!
>>
>>
> Updating the bindings for some of the newer APIs has been something I've
> been wanting to get to. I'm not proficient enough in swig-ese to just
> rattle it off the top of my head yet, but I'd be interested in helping
> out. I may actually have some time to poke at Friday depending on how life
> goes :) So if you or someone else hasn't figured it out by then I'll plan
> on taking a look.
For anyone who wants to work on updating the bindings: note that we have
a lot of language-specific stuff in there that's a consequence of Swig 1
not knowing any better back in the day. Most of those typemaps can be
made language-independent (thus reducing the size of the Swig files)
with features from Swig 2 and especially 3, which introduced built-in
constructs for handling various kinds of data structures that we're
currently mapping separately for each target language.
-- Brane
Re: Updating swig-py bindings
Posted by Troy Curtis Jr <tr...@gmail.com>.
On Tue, Mar 13, 2018 at 9:44 AM Julian Foad <ju...@apache.org> wrote:
> Troy (or others), I want to use swig-py bindings for my new shelving API
> (in svn_client.h) so I am trying to update them. I started by looking at
> the 'Missing argout typemap' warnings for svn_client.h.
>
> As well as svn_shelf_* functions, also the svn_client_conflict_* set of
> functions currently lack bindings so I thought I might as well try to do
> those at the same time.
>
> First some easy bits:
>
> [[[
> Index: subversion/bindings/swig/include/svn_containers.swg
> ===================================================================
> --- subversion/bindings/swig/include/svn_containers.swg (revision 1826621)
> +++ subversion/bindings/swig/include/svn_containers.swg (working copy)
> @@ -527,7 +527,10 @@
> apr_array_header_t **logfiles,
> apr_array_header_t **names_p,
> apr_array_header_t **targets_p,
> - apr_array_header_t **args_p
> + apr_array_header_t **args_p,
> + apr_array_header_t **possible_moved_to_repos_relpaths,
> + apr_array_header_t **possible_moved_to_abspaths,
> + apr_array_header_t **props_conflicted
> };
>
> /*
> -----------------------------------------------------------------------
> Index: subversion/bindings/swig/include/svn_types.swg
> ===================================================================
> --- subversion/bindings/swig/include/svn_types.swg (revision 1826621)
> +++ subversion/bindings/swig/include/svn_types.swg (working copy)
> @@ -119,6 +119,11 @@
> svn_client_commit_info_t **,
> svn_client_ctx_t **,
> const svn_client_commit_item3_t **,
> + svn_client_conflict_t **,
> + svn_client_conflict_option_t **,
> + svn_client_shelf_t **,
> + svn_client_shelf_version_t **,
> + svn_client_shelf_info_t **,
> /* svn_delta */
> const svn_delta_editor_t **,
> svn_txdelta_stream_t **,
> ]]]
>
> Now the harder ones.
>
> subversion/include/svn_client.h:4793: Warning 900: FIXME: Missing argout
> typemap
> subversion/include/svn_client.h:4806: Warning 900: FIXME: Missing argout
> typemap
> subversion/include/svn_client.h:4823: Warning 900: FIXME: Missing argout
> typemap
>
> These three all look like:
>
> svn_client_conflict_text_get_resolution_options(
> apr_array_header_t **options,
>
> an array of pointer to svn_client_conflict_option_t which is an opaque
> object.
>
> I can see an "%opaque_proxy(svn_client_conflict_t);" declaration has
> already been produced in 'proxy/svn_client_h.swg'. What more is needed?
>
> subversion/include/svn_client.h:7028: Warning 900: FIXME: Missing argout
> typemap
>
> svn_client_shelf_get_all_versions(apr_array_header_t **versions_p,
>
> an array of pointer to svn_client_shelf_version_t which is a public
> non-opaque struct.
>
> subversion/include/svn_client.h:7079: Warning 900: FIXME: Missing argout
> typemap
> subversion/include/svn_client.h:7176: Warning 900: FIXME: Missing argout
> typemap
> subversion/include/svn_client.h:7201: Warning 900: FIXME: Missing argout
> typemap
>
> And so on.
>
> Any help would be appreciated!
>
>
Updating the bindings for some of the newer APIs has been something I've
been wanting to get to. I'm not proficient enough in swig-ese to just
rattle it off the top of my head yet, but I'd be interested in helping
out. I may actually have some time to poke at Friday depending on how life
goes :) So if you or someone else hasn't figured it out by then I'll plan
on taking a look.
Troy
> Thanks,
> - Julian
>