| Policies

Even thought Pyste can identify various elements in the C++ code, like virtual methods, attributes, and so on, one thing that it can't do is to guess the semantics of functions that return pointers or references. In this case, the user must manually specify the policy. Policies are explained in the tutorial.

The policies in Pyste are named exactly as in Boost.Python, only the syntax is slightly different. For instance, this policy:

`

        return_internal_reference<1, with_custodian_and_ward<1, 2> >()

`

becomes in Pyste:

`

        return_internal_reference(1, with_custodian_and_ward(1, 2))

`

The user can specify policies for functions and methods with the `set_policy` function:

`

        set_policy(f, return_internal_reference())
        set_policy(C.foo, return_value_policy(manage_new_object))

`

What if a function or method needs a policy and the user doesn't set one? If a function/method needs a policy and one was not set, Pyste will issue a error. The user should then go in the interface file and set the policy for it, otherwise the generated cpp won't compile.

Copyright © 2003 Bruno da Silva de Oliveira
Copyright © 2002-2003 Joel de Guzman
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.