Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/share/swig4.0/typemaps/ |
Upload File : |
/* ----------------------------------------------------------------------------- * cpointer.swg * * This library file contains macros that can be used to manipulate simple * pointer objects. * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { NAME() { return %new_instance(TYPE); } ~NAME() { if ($self) %delete($self); } } %extend NAME { void assign(TYPE value) { *$self = value; } TYPE value() { return *$self; } TYPE * cast() { return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { return %new_instance(TYPE); } static TYPE *copy_##NAME(TYPE value) { return %new_copy(value, TYPE); } static void delete_##NAME(TYPE *obj) { if (obj) %delete(obj); } static void NAME ##_assign(TYPE *obj, TYPE value) { *obj = value; } static TYPE NAME ##_value(TYPE *obj) { return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *obj); void NAME##_assign(TYPE *obj, TYPE value); TYPE NAME##_value(TYPE *obj); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return %static_cast(x, TYPE2); } %} %enddef