perl-ctypes:perl-ctypes.git
5 years agoUpdating Pointer pod
Ryan Jendoubi [Sat, 31 Mar 2012 00:50:58 +0000 (01:50 +0100)]
Updating Pointer pod

5 years agoFixed 'blank warning' in Array.t
Ryan Jendoubi [Wed, 22 Feb 2012 17:45:40 +0000 (17:45 +0000)]
Fixed 'blank warning' in Array.t

Array types could not sizecode(), so were failing
Ctypes::_check_invalid_types().

Also added Array::packcode().

modified:   lib/Ctypes/Type/Array.pm

5 years agoFixed C:T:Simple constructor arg coersion; Function.t passing
Ryan Jendoubi [Wed, 22 Feb 2012 14:53:23 +0000 (14:53 +0000)]
Fixed C:T:Simple constructor arg coersion; Function.t passing

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   t/002-Function.t

5 years agoCleaned up POD errors for pod.t
Ryan Jendoubi [Mon, 20 Feb 2012 20:18:24 +0000 (20:18 +0000)]
Cleaned up POD errors for pod.t

5 years agoSimple.t passing many more tests than before
Ryan Jendoubi [Mon, 20 Feb 2012 19:53:30 +0000 (19:53 +0000)]
Simple.t passing many more tests than before

Fixed bug introduced in chages to C:T:Simple.pm in commit 07bf5c708
(First version of class refactor). Misleading names for internally
used properties were probably responsible for the confusion.

Changes to _hook_fetch due to the fix have been documented in POD.

Key is in keeping the value as a property of $object->{_rawvalue}
and not in $object->{_value} directly. $object->{_value} can't be
trusted since $$x = <anything> will squash it in the course of
scalar overload. $object->{_rawvalue}->{VALUE} or ->[1]
is the only location which is checked on input and output.
In effect, $object->{_value} is just a placeholder which is
accessed to allow tie() to do its magic; it shouldn't be used
directly.

Of course, the way everything /should/ be done is to not
cache /anything/ Perl-side, and keep all values as native C
variables / data structures only. This would remove so much
messing about keeping track of values in multiple locations,
cascading changes around objects etc.

Python Ctypes keeps all values as native C. The only reason
I didn't do it that way to begin with is because I was less
comfortable in C and thought it would be too hard. In
retrospect, it would have saved a ton of work.

modified:   lib/Ctypes/Type/Simple.pm
modified:   t/Simple.t

5 years agoMaking Array.pm's FETCH more robust
Ryan Jendoubi [Mon, 20 Feb 2012 17:43:05 +0000 (17:43 +0000)]
Making Array.pm's FETCH more robust

5 years agoInconsequential changes in Simple.t
Ryan Jendoubi [Mon, 20 Feb 2012 16:56:32 +0000 (16:56 +0000)]
Inconsequential changes in Simple.t

5 years agoArray.t actually passing
Ryan Jendoubi [Mon, 20 Feb 2012 00:50:57 +0000 (00:50 +0000)]
Array.t actually passing

Dereferencing the FETCH'd value from C:T:Array's interal store.

modified:   lib/Ctypes/Type/Array.pm

5 years ago.gitignore MYMETA.json
Ryan Jendoubi [Mon, 20 Feb 2012 00:47:02 +0000 (00:47 +0000)]
.gitignore MYMETA.json

5 years agoArray.t passing
Ryan Jendoubi [Mon, 20 Feb 2012 00:38:11 +0000 (00:38 +0000)]
Array.t passing

modified:   lib/Ctypes/Type/Array.pm
modified:   t/Array.t

5 years agorevert chmod -x win32/libffi-5.dll
Reini Urban [Tue, 10 Jan 2012 01:58:24 +0000 (19:58 -0600)]
revert chmod -x win32/libffi-5.dll

6 years agoRemove executable bits. 1
Shlomi Fish [Mon, 7 Nov 2011 17:25:32 +0000 (19:25 +0200)]
Remove executable bits.

Made some files that should not be executable not executable.

6 years agofix pod. add gcov make target
Reini Urban [Wed, 10 Aug 2011 15:02:36 +0000 (17:02 +0200)]
fix pod. add gcov make target

6 years agofix pod coverage. fix byte max limit from 256 to 255
Reini Urban [Mon, 8 Aug 2011 18:22:05 +0000 (20:22 +0200)]
fix pod coverage. fix byte max limit from 256 to 255

6 years agorefactor Function + Pointer: size method. sizecode = packcode (libffi interface)
Reini Urban [Mon, 8 Aug 2011 15:00:42 +0000 (17:00 +0200)]
refactor Function + Pointer: size method. sizecode = packcode (libffi interface)

6 years agouse Ctypes::USE_PERLTYPES, use sizecode for ffi sizes
Reini Urban [Mon, 8 Aug 2011 14:58:25 +0000 (16:58 +0200)]
use Ctypes::USE_PERLTYPES, use sizecode for ffi sizes

6 years agoadd LONGLONG, indent #ifdef
Reini Urban [Mon, 8 Aug 2011 14:56:38 +0000 (16:56 +0200)]
add LONGLONG, indent #ifdef

6 years agoadd simple TODO per Audreys req
Reini Urban [Mon, 8 Aug 2011 14:49:39 +0000 (16:49 +0200)]
add simple TODO per Audreys req

6 years agodisallow STDCALL on non-windows systems classify
Reini Urban [Mon, 25 Apr 2011 13:43:23 +0000 (15:43 +0200)]
disallow STDCALL on non-windows systems

6 years agoSimple.pm: added c_int alias classes
Reini Urban [Sat, 12 Mar 2011 00:02:23 +0000 (01:02 +0100)]
Simple.pm: added c_int alias classes
types.t: TODO strict_input tests, all others pass

6 years agoimprove cygwin libffi build and accept spaces in cwd
Reini Urban [Fri, 11 Mar 2011 23:17:37 +0000 (00:17 +0100)]
improve cygwin libffi build and accept spaces in cwd

6 years agofix _hook_fetch for chars
Reini Urban [Fri, 11 Mar 2011 23:16:46 +0000 (00:16 +0100)]
fix _hook_fetch for chars

6 years agofixed _minmax and two types checks
Reini Urban [Fri, 11 Mar 2011 18:38:41 +0000 (19:38 +0100)]
fixed _minmax and two types checks

6 years agoindent comments
Reini Urban [Fri, 11 Mar 2011 17:50:14 +0000 (18:50 +0100)]
indent comments

6 years agoMerge branch 'classify' of gitorious.org:perl-ctypes/perl-ctypes into classify
Reini Urban [Fri, 11 Mar 2011 17:48:29 +0000 (18:48 +0100)]
Merge branch 'classify' of gitorious.org:perl-ctypes/perl-ctypes into classify

6 years agoMakefile.PL: fix LIBDIR INCDIR args
Reini Urban [Fri, 11 Mar 2011 15:53:49 +0000 (16:53 +0100)]
Makefile.PL: fix LIBDIR INCDIR args
  fix libffi building

6 years agoType/Simple.pm: rename _hook_in to _hook_store, _hook_out to _hook_fetch
Reini Urban [Fri, 11 Mar 2011 08:54:26 +0000 (09:54 +0100)]
Type/Simple.pm: rename _hook_in to _hook_store, _hook_out to _hook_fetch
.gitignore: add .provedb

6 years agoclassify part 2: fixed _minmax with constant, char hook_out int2chr wrong
Reini Urban [Thu, 10 Mar 2011 14:52:20 +0000 (15:52 +0100)]
classify part 2: fixed _minmax with constant, char hook_out int2chr wrong

6 years agoFinish writing down the Simple numeric classes with accessors and both hooks
Reini Urban [Sat, 26 Feb 2011 10:59:42 +0000 (11:59 +0100)]
Finish writing down the Simple numeric classes with accessors and both hooks
_hook_in valid => invalid
use new hook methods in Simple

6 years agoignore test results, .test-* files
Reini Urban [Thu, 24 Feb 2011 20:48:39 +0000 (21:48 +0100)]
ignore test results, .test-* files

6 years agoFirst version of class refactor, 20% finished, but most tests pass as before.
Reini Urban [Thu, 24 Feb 2011 20:38:55 +0000 (21:38 +0100)]
First version of class refactor, 20% finished, but most tests pass as before.
No need for the global _pytypes hash, with its unmanageble and duplicate subs,
  use classes instead.
Create global c_int,... packages to be able to say
  use Ctypes; my c_int $i = 1;
Remove duplicate value slots, the RAWVALUE tie reads/writes to the one
  and only _value slot
Do not store the Simple ref $object as hash, use a faster and
  shorter arrayref instead $self->[0]
Add more private stuff to .gitignore ( I use now git-prompt.sh )

6 years agolibffi 3.0.10rc3
Reini Urban [Tue, 15 Feb 2011 23:28:33 +0000 (00:28 +0100)]
libffi 3.0.10rc3
msys fixes
pod formatting
s/allow_overflow/strict_input/g
fix Type init
  force _update_ and validate data
  set VALUE slot
  call hook_in

6 years agoomit more default sizecodes
Reini Urban [Mon, 17 Jan 2011 18:51:24 +0000 (19:51 +0100)]
omit more default sizecodes

6 years agoCtypes::Type::_new simplification: allow init hashref for default values
Reini Urban [Mon, 17 Jan 2011 18:46:23 +0000 (19:46 +0100)]
Ctypes::Type::_new simplification: allow init hashref for default values
derived types: use it
Simple: use sizecode, packcode and validate defaults (sparse $_types)

6 years agoCtypes.xs simplification: sizeof already gets the perl-style sizecode type
Reini Urban [Mon, 17 Jan 2011 18:45:53 +0000 (19:45 +0100)]
Ctypes.xs simplification: sizeof already gets the perl-style sizecode type

6 years agobetter util.c error messages: cry less and more context
Reini Urban [Mon, 17 Jan 2011 17:30:38 +0000 (18:30 +0100)]
better util.c error messages: cry less and more context

6 years agoadd helper .c files to xs deps
Reini Urban [Mon, 17 Jan 2011 17:28:49 +0000 (18:28 +0100)]
add helper .c files to xs deps

6 years agoMore docs
Reini Urban [Thu, 13 Jan 2011 17:38:15 +0000 (18:38 +0100)]
More docs
more $Debug style fixes

6 years agofixed Struct.t accessor
Reini Urban [Thu, 13 Jan 2011 11:38:46 +0000 (12:38 +0100)]
fixed Struct.t accessor

6 years agorurban libffi and Debug cleanup:
Reini Urban [Thu, 13 Jan 2011 08:57:32 +0000 (09:57 +0100)]
rurban libffi and Debug cleanup:
- layout changes: *.c, *.h to root
- check Debug print in Type modules
- if no libffi lib exists, unpack our prepackaged and install it locally
- rm conflicting ffi headers. use either installed or new.
- add libffi.tar.gz, version 3.0.10rc0 from git
- add precompiled win32 libffi (mingw32 gcc-4.5), no win64 yet
- fix MANIFEST

lots of multi-char warnings in the Type tests
Files=28, Tests=356, 47 wallclock secs ( 0.19 usr  0.17 sys + 38.24 cusr  4.19 csys = 42.78 CPU)
Result: FAIL
Failed 19/28 test programs. 29/356 subtests failed.

6 years agoMerge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes v0.002
Reini Urban [Tue, 11 Jan 2011 17:39:43 +0000 (18:39 +0100)]
Merge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes

6 years agoConsolidating Simple type tests into t/Simple.t
Ryan Jendoubi [Wed, 29 Dec 2010 05:41:54 +0000 (05:41 +0000)]
Consolidating Simple type tests into t/Simple.t

Will have cmd line options: --all, --c_short, --c_int etc.
rurban tells me pack() is knowingly deviates from C overflow
behaviour. One less thing to worry about getting 100% right now.

modified:   lib/Ctypes/Type.pm
new file:   t/Simple.t
deleted:    t/limits_test.t
deleted:    t/pack_overflow.t

6 years agoPlodding on with tests
Ryan Jendoubi [Tue, 28 Dec 2010 02:25:50 +0000 (02:25 +0000)]
Plodding on with tests

Unsigned integer wrap-around by pack() appears irregular. Looking
into it.

Also, since hook_out performs chr() on a c_char's value, ++ might
need overloaded... but I'm not sure how to make it a special
overload just for that type.

modified:   Makefile.PL
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   t/Simple_int.t
new file:   t/Simple_long.t
modified:   t/Simple_short.t
new file:   t/Simple_uint.t
new file:   t/Simple_ulong.t
modified:   t/Simple_ushort.t
new file:   t/limits_test.t
new file:   t/pack_overflow.t

7 years agoNew tests, new testing function perl_data_validation
Ryan Jendoubi [Mon, 15 Nov 2010 13:17:43 +0000 (13:17 +0000)]
New tests, new testing function

Complete tests for [u]byte, [u]char, [u]short.

Large range of [u]int required writing Ctypes::Util::create_range
to easily make ranges of testing values.

Will also require CTYPES_TEST_FULL env arg for tests to really
test full value range of variables, or whatever standard release
testing flag is.

7 years agoTests for c_uchar
Ryan Jendoubi [Sun, 31 Oct 2010 02:39:19 +0000 (02:39 +0000)]
Tests for c_uchar

modified:   lib/Ctypes/Type.pm
modified:   t/Simple_char.t
new file:   t/Simple_uchar.t

7 years agoMore new tests (c_byte, c_ubyte)
Ryan Jendoubi [Sun, 17 Oct 2010 08:51:32 +0000 (09:51 +0100)]
More new tests (c_byte, c_ubyte)

New XS function (Ctypes::Test::is_a_number) which simply checks
the SvIOK($arg) || SvNOK($arg). Will probably encounter the
same problem later about the values returned by Ctypes objects
not having the public flags set, but that's a problem with the
output so should be fixed at that point.

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   t/Simple_byte.t
new file:   t/Simple_char.t
new file:   t/Simple_ubyte.t

7 years agohook_* proof-of-concept working for type c_byte
Ryan Jendoubi [Tue, 12 Oct 2010 23:21:27 +0000 (00:21 +0100)]
hook_* proof-of-concept working for type c_byte

. All $_types now have sizecodes and packcodes, since these can
  be different from their typecodes. Since our range of Types
  don't reflect only those in C or Python's Ctypes, typecodes
  are really only for use within Ctypes identify them.

. All $_types need an anonymous sub under the hash key 'hook_in'.
  This takes one argument, the value passed to be STOREd, and
  performs whatever validations necessary. It returns a list of
  two scalars: an indicator of invalidity (must be undef if arg
  was valid) and a 'sanitized' form of the arg - basically, do
  whatever can be done to make the input valid for the type.
  This will be STOREd instead of the original input. The original
  input is stored in $object->{_input} though, for use later by
  hook_out if needs be.

. $_types /can/ have a hook_out, but it's not compulsory. This
  can take two arguments: the STOREd $val, and the $object itself.
  The latter can be used to ascertain information which might
  affect whether anything special needs to be done to the value
  before output (e.g., whether the {_input} was numeric or string).

. Type::Simple objects now have size(), sizecode(), packcode() and
  validate() methods (can you believe they didn't implement size()
  before?? @_@). The validate() is the same as used by STORE. It
  can be used if you happen to need to know if certain input is
  invalid for a given type without squashing its current contents.

Now all the rest of the types need their hooks and test written.
Onward!

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   t/Simple_byte.t

7 years agoMoving development to new branch
Ryan Jendoubi [Mon, 11 Oct 2010 15:24:23 +0000 (16:24 +0100)]
Moving development to new branch

7 years agoUse of qw(...) as parentheses is deprecated at inc/Devel/CheckLib.pm line 164
Reini Urban [Fri, 8 Oct 2010 07:50:56 +0000 (09:50 +0200)]
Use of qw(...) as parentheses is deprecated at inc/Devel/CheckLib.pm line 164

7 years agoMerge branch 'master' of http://git.gitorious.org/perl-ctypes/perl-ctypes
Reini Urban [Fri, 8 Oct 2010 06:55:40 +0000 (08:55 +0200)]
Merge branch 'master' of git.gitorious.org/perl-ctypes/perl-ctypes

7 years agoFinish Unions
Ryan Jendoubi [Thu, 16 Sep 2010 09:54:56 +0000 (10:54 +0100)]
Finish Unions

Also changed Union.t & Struct.t to show real number of tests (not
mostly in subtests anymore).

modified:   lib/Ctypes/Type/Union.pm
modified:   t/Struct.t
modified:   t/Union.t

7 years agoMerge branch 'unions'
Ryan Jendoubi [Mon, 6 Sep 2010 20:11:10 +0000 (21:11 +0100)]
Merge branch 'unions'

7 years agoUnions work, improvements in Simple, Struct, Field
Ryan Jendoubi [Mon, 6 Sep 2010 20:09:46 +0000 (21:09 +0100)]
Unions work, improvements in Simple, Struct, Field

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   lib/Ctypes/Type/Union.pm
modified:   t/Struct.t
modified:   t/Union.t
modified:   t/types.t
modified:   t/win-proto.t

7 years agoMerge changes to Array, Pointer from branch unions
Ryan Jendoubi [Sun, 5 Sep 2010 16:57:08 +0000 (17:57 +0100)]
Merge changes to Array, Pointer from branch unions

modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Pointer.pm

7 years agoFix ->copy method for Arrays, Pointers need tests
Ryan Jendoubi [Sun, 5 Sep 2010 16:50:49 +0000 (17:50 +0100)]
Fix ->copy method for Arrays, Pointers need tests

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   lib/Ctypes/Type/Union.pm
modified:   t/Array.t
modified:   t/Union.t

7 years agoRe-add t/Union.t
Ryan Jendoubi [Sun, 5 Sep 2010 14:28:10 +0000 (15:28 +0100)]
Re-add t/Union.t

new file:   t/Union.t

7 years agoMerge branch 'master' into unions
Ryan Jendoubi [Sun, 5 Sep 2010 14:19:23 +0000 (15:19 +0100)]
Merge branch 'master' into unions

Conflicts:
lib/Ctypes/Type.pm
lib/Ctypes/Type/Union.pm

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Array.t
modified:   t/Pointer.t
modified:   t/Struct.t
deleted:    t/Struct.t_pyguides
deleted:    t/Union.t
modified:   t/pod-coverage.t
modified:   t/t_POINT.pm
modified:   t/types.t

7 years agoFinished basic Struct implementation, tests, docs
Ryan Jendoubi [Sun, 5 Sep 2010 12:41:49 +0000 (13:41 +0100)]
Finished basic Struct implementation, tests, docs

TODO:
  add/remove/splice fields methods
  alignment of parts of structs
  endianness.....

7 years agoLots more work on structs, think it's good now struct_api_change
Ryan Jendoubi [Wed, 1 Sep 2010 12:49:13 +0000 (13:49 +0100)]
Lots more work on structs, think it's good now

General setup now allows assignment and returning of values as
well as returning information about fields.

Next issue is error in alignment I think.

7 years agoWork on Structs
Ryan Jendoubi [Tue, 31 Aug 2010 10:18:59 +0000 (11:18 +0100)]
Work on Structs

Implemented copy() method for all Types (as Structs need their
own copy() of the contents of subclasses' $_fields_).

No good way of using method-style access for Struct members (always
some Perl method names which could hypothetically limit field names
so must use hash-style access ($$struct->{field}).

Now looking at how to return info about fields, so that fields
can know their own name within the struct. Removed tied Field
objects, may reintroduce them in a different way.

7 years agoTests for new Struct API
Ryan Jendoubi [Mon, 23 Aug 2010 23:28:44 +0000 (00:28 +0100)]
Tests for new Struct API

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t
new file:   t/Struct.t_old
modified:   t/t_POINT.pm

7 years agoMore pod for Pointer.pm
Ryan Jendoubi [Sat, 21 Aug 2010 10:58:30 +0000 (11:58 +0100)]
More pod for Pointer.pm

modified:   lib/Ctypes/Type/Pointer.pm
modified:   t/Pointer.t
modified:   t/pod-coverage.t
modified:   t/types.t

7 years agoMore docs, plus fixed rounding error for integers
Ryan Jendoubi [Mon, 16 Aug 2010 18:39:08 +0000 (19:39 +0100)]
More docs, plus fixed rounding error for integers

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   lib/Ctypes/Type/Simple.pm
modified:   t/Array.t
modified:   t/Pointer.t
modified:   t/Struct.t
modified:   t/pod-coverage.t
modified:   t/types.t

7 years agoRemoved unfinished unions from master
Ryan Jendoubi [Mon, 16 Aug 2010 16:44:07 +0000 (17:44 +0100)]
Removed unfinished unions from master

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
deleted:    lib/Ctypes/Type/Union.pm
deleted:    t/Union.t

7 years agoInitial commit for branch unions unions
Ryan Jendoubi [Mon, 16 Aug 2010 16:40:59 +0000 (17:40 +0100)]
Initial commit for branch unions

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Union.pm

7 years agoMany changes
Ryan Jendoubi [Mon, 16 Aug 2010 16:32:30 +0000 (17:32 +0100)]
Many changes

Moved Type::Simple to new file, work on Unions (unfinished)

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Pointer.pm
new file:   lib/Ctypes/Type/Simple.pm
modified:   lib/Ctypes/Type/Struct.pm
new file:   lib/Ctypes/Type/Union.pm
modified:   t/Array.t
modified:   t/Pointer.t
modified:   t/Struct.t
new file:   t/Union.t
modified:   t/pod-coverage.t
modified:   t/types.t

7 years agoMerge http://git.gitorious.org/perl-ctypes/perl-ctypes
Reini Urban [Mon, 16 Aug 2010 10:16:33 +0000 (12:16 +0200)]
Merge git.gitorious.org/perl-ctypes/perl-ctypes

7 years agoStruct indirection working
Ryan Jendoubi [Sun, 15 Aug 2010 11:50:57 +0000 (12:50 +0100)]
Struct indirection working

modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t

7 years agoMore tightening and tests for Structs
Ryan Jendoubi [Sun, 15 Aug 2010 05:58:16 +0000 (06:58 +0100)]
More tightening and tests for Structs

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t

7 years agoMore interface trials
Ryan Jendoubi [Sat, 14 Aug 2010 23:17:22 +0000 (00:17 +0100)]
More interface trials

modified:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t

7 years agoMore work Struct interface
Ryan Jendoubi [Sat, 14 Aug 2010 22:04:12 +0000 (23:04 +0100)]
More work Struct interface

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
new file:   lib/Ctypes/Type/Field.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t
renamed:    t/Struct.t -> t/Struct.t_pyguides
modified:   t/t_Daffodil.pm
modified:   t/t_Flower.pm
modified:   t/t_POINT.pm

7 years agoSome progress on Structs, instantiation interface
Ryan Jendoubi [Fri, 13 Aug 2010 16:48:28 +0000 (17:48 +0100)]
Some progress on Structs, instantiation interface

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Struct.pm
modified:   t/Struct.t
deleted:    t/Struct.t_
deleted:    t/pod-coverage.t_
new file:   t/t_Daffodil.pm
new file:   t/t_Flower.pm
new file:   t/t_POINT.pm

7 years agoCompleted update of data ownership chaining
Ryan Jendoubi [Fri, 13 Aug 2010 00:02:31 +0000 (01:02 +0100)]
Completed update of data ownership chaining

Today's work was important for moving on to Structs.

The main principle was the same as used in the Python version, of
objects having an _owner attribute set when they become part of a
bigger data structure, like an Array or Struct. When an object
becomes owned by another, the owner will set two attributes in
the owned object:
1) {_owner}, set to the owner object (is undef on instantiation,
   although most tests on it check for truth rather than definedness)
2) {_index}, set to the offset of the owned object's data inside
   the owner object's data, *in bytes*. It is Not an array or
   pseudohash index. It is used in substr operations, so that owned
   objects can check in the owner's data if their data has been
   modified, instead of owners having to repopulate Every owned
   object with data when it is updated (although this is sometimes
   necessary, when an owner's data is updated without an index
   indicating what has changed).

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   t/Array.t
modified:   t/Pointer.t
new file:   t/Struct.t

7 years agoMerge branch 'master' of http://git.gitorious.org/perl-ctypes/perl-ctypes
Reini Urban [Thu, 12 Aug 2010 14:07:48 +0000 (16:07 +0200)]
Merge branch 'master' of git.gitorious.org/perl-ctypes/perl-ctypes

7 years agoAdd Devel::CheckLib
Reini Urban [Thu, 12 Aug 2010 14:07:23 +0000 (16:07 +0200)]
Add Devel::CheckLib

7 years agoStarting reorganisation for C::B::C
Ryan Jendoubi [Thu, 12 Aug 2010 10:24:48 +0000 (11:24 +0100)]
Starting reorganisation for C::B::C

Now using Ctypes::Type ABC to track 'owner' objects, data fields

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Pointer.pm
new file:   lib/Ctypes/Type/Struct.pm
new file:   t/Struct.t_

7 years agoFixes and added tests for Pointers
Ryan Jendoubi [Wed, 11 Aug 2010 11:43:07 +0000 (12:43 +0100)]
Fixes and added tests for Pointers

Earstwhile bug in reading from end of data now fixed (I think), but
not sure how to test for it. Also, Test::More's diag() is showing
up strange behaviour; see Pointer.t.

modified:   lib/Ctypes/Type/Pointer.pm
modified:   t/Pointer.t

7 years agoReintroduced enhanced error message
Ryan Jendoubi [Wed, 11 Aug 2010 02:48:55 +0000 (03:48 +0100)]
Reintroduced enhanced error message

modified:   lib/Ctypes/Type/Pointer.pm

7 years agoFixed multiple indirection on Pointers / Arrays
Ryan Jendoubi [Wed, 11 Aug 2010 02:41:40 +0000 (03:41 +0100)]
Fixed multiple indirection on Pointers / Arrays

At the minute, the object that was finally passed must either be
explicitly ->_update_'d, or must be the first used after the
call returns (in which case it updates itself automatically).

This should be made automatic using paramflags.

Alternatively, _as_param_ could take an argument of a reference
to the requesting object, or the place the data will be stored and
worked upon. Then data could be 'chased up' the object chain to
ensure freshness.
Interface should probably be through _update_, with objects free
to use their own internal mechanism to know whether their own
data is fresh (i.e. has it been stored again since it was given
out?).

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   lib/Ctypes/Type/Pointer.pm
modified:   t/Array.t
modified:   t/Pointer.t

7 years agoPointer objects
Ryan Jendoubi [Tue, 10 Aug 2010 22:06:36 +0000 (23:06 +0100)]
Pointer objects

See t/Pointers.t for usage.

In general, '$ptr' for methods on the object and '$$ptr' for using
the pointer behaviour, e.g.

$$ptr[0] = 5;

The notable exception is that pointer arithmetic is done to the
object:

$ptr++;
$ptr->offset(6);

If you do $$ptr++ Ctypes attempts to construct a new pointer to
the numeric representation of the address of the object (I think);
there's a decent error message for this.

modified:   MANIFEST
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
new file:   lib/Ctypes/Type/Pointer.pm
modified:   t/Array.t
new file:   t/Pointer.t

7 years agoLittle modifications
Ryan Jendoubi [Tue, 10 Aug 2010 12:28:30 +0000 (13:28 +0100)]
Little modifications

$simpleType->typecode method now called ->_typecode_, more
  consistent.

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   t/Array.t
modified:   t/types.t

7 years agoMultidimensional arrays
Ryan Jendoubi [Tue, 10 Aug 2010 02:28:40 +0000 (03:28 +0100)]
Multidimensional arrays

Implementing this involved a lot of backtracking and fleshing out
ideas half-implemented before, like the _as_param_ method thing.
All types including arrays must now have an _as_param_ method,
an _update_ method, and a _typecode_. In Ctypes types these are
woven in with FETCH and STORE, but using this standard we *should*
be able to work with user-defined types in calling Functions, etc.

Full write up to follow: API description in docs, technical detail
in blog post.

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   t/Array.t
modified:   t/types.t

7 years agoSubstanitally simplified Types, a la Arrays
Ryan Jendoubi [Mon, 9 Aug 2010 03:54:23 +0000 (04:54 +0100)]
Substanitally simplified Types, a la Arrays

No more $type->val; now it's just $$type (overloaded scalar deref)
Removed code deref, as well as hash (Ctypes users should know what
 they're doing, can blow sh*t up if they want).

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   t/Array.t
modified:   t/types.t

7 years agoFixed bug with short values in callbacks
Ryan Jendoubi [Sun, 8 Aug 2010 15:30:16 +0000 (16:30 +0100)]
Fixed bug with short values in callbacks

modified:   Ctypes.xs
modified:   t/Array.t
modified:   t/callbacks.t

7 years agoArrays now work as function args (*NB)
Ryan Jendoubi [Sun, 8 Aug 2010 14:18:12 +0000 (15:18 +0100)]
Arrays now work as function args (*NB)

NB: _as_param_ funcs need to return references to the attributes
    containing C data (e.g. {_as_param_}, {_data}, whatever). I
    guess this was obvious but never had to use them before. In
    any case, clients of _as_param_() methods need to be aware
    of that.
Need to find somewhere in the docs for general info on the
  'Ctypes object protocol': _as_param_, _typecode_ and how to
  use them.

modified:   Ctypes.xs
modified:   MANIFEST
modified:   lib/Ctypes/Type/Array.pm
modified:   src/obj_util.c
modified:   t/Array.t

7 years agoBasic Fetch/Store working for Arrays
Ryan Jendoubi [Sun, 8 Aug 2010 11:32:05 +0000 (12:32 +0100)]
Basic Fetch/Store working for Arrays

Passing them into function calls squashes them, however. Need to
revisit Function.pm

modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type/Array.pm
modified:   t/Array.t

7 years agoFirst crack at Array objects
Ryan Jendoubi [Sat, 7 Aug 2010 20:30:31 +0000 (21:30 +0100)]
First crack at Array objects

modified:   MANIFEST
modified:   Makefile.PL
modified:   const-xs.inc
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Type.pm
new file:   lib/Ctypes/Type/Array.pm
new file:   t/Array.t
modified:   t/types.t

7 years agoFixed limits for float, double & long double types
Ryan Jendoubi [Sat, 7 Aug 2010 17:29:54 +0000 (18:29 +0100)]
Fixed limits for float, double & long double types

Apparently C's < and > operators aren't fullproof. _validate_for_type
was thinking that 0 was smaller than DBL_MIN. Fixed along the lines
of if( (a - b) > DBL_EPSILON ).

modified:   Ctypes.xs

7 years agoMake all attrs unsettable apart from allow_overflo
Ryan Jendoubi [Fri, 6 Aug 2010 18:45:12 +0000 (19:45 +0100)]
Make all attrs unsettable apart from allow_overflo

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm
modified:   t/types.t

7 years agoHandle numeric casting of utf8 chars
Ryan Jendoubi [Fri, 6 Aug 2010 13:31:00 +0000 (14:31 +0100)]
Handle numeric casting of utf8 chars

Only done for c_int, other numeric types are TODO.
Relies on SvUTF8, which seems only to be set when when 'use utf8'
  in user script. Can't see another way around that...

modified:   Ctypes.xs
modified:   t/types.t

7 years agoMerge branch 'types_obj'
Ryan Jendoubi [Fri, 6 Aug 2010 12:00:28 +0000 (13:00 +0100)]
Merge branch 'types_obj'

7 years agoMake _cast for 'c' and 'C' more robust
Ryan Jendoubi [Fri, 6 Aug 2010 10:36:51 +0000 (11:36 +0100)]
Make _cast for 'c' and 'C' more robust

Still confused about "Argument 'Y' isn't numeric in pack" error
for these types. Should we be using 'A'?

modified:   Ctypes.xs

7 years agoTest fix: change checking access for Type attrs
Ryan Jendoubi [Fri, 6 Aug 2010 08:38:05 +0000 (09:38 +0100)]
Test fix: change checking access for Type attrs

Necessary after moving _make_arrayref and _check_invalid_types
to Ctypes.pm

modified:   lib/Ctypes/Type.pm
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm

7 years agoSeparated out _make_types_arrayref
Ryan Jendoubi [Thu, 5 Aug 2010 19:27:08 +0000 (20:27 +0100)]
Separated out _make_types_arrayref

Needed _make_arrayref logic for Ctypes::Array()
Other func is _check_invalid_types (named that way for a reason)

modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm

7 years agoFixed _valid_for_type for s and S types
Ryan Jendoubi [Thu, 5 Aug 2010 08:25:53 +0000 (09:25 +0100)]
Fixed _valid_for_type for s and S types

modified:   Ctypes.xs

7 years agoAdd _valid_for_type for c_void, Ct::Type::_types()
Ryan Jendoubi [Thu, 5 Aug 2010 08:07:48 +0000 (09:07 +0100)]
Add _valid_for_type for c_void, Ct::Type::_types()

_types() simply returns $_types hashref (_perltypes or _pytypes)

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm

7 years agoWe can haz Types.
Ryan Jendoubi [Thu, 5 Aug 2010 07:51:35 +0000 (08:51 +0100)]
We can haz Types.

All current tests passing. More to come.

modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm
modified:   t/002-Function.t

7 years agoTypes parameterised, allllmost finished
Ryan Jendoubi [Thu, 5 Aug 2010 06:07:41 +0000 (07:07 +0100)]
Types parameterised, allllmost finished

. $type->name doesn't seem to work
. Warning about packed value not numeric for char type
. Need lots more tests for the various types

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm
modified:   src/obj_util.c
modified:   t/002-Function.t
modified:   t/types.t
modified:   t/win-proto.t

7 years agoFixed Ctypes::Type::value broken last commit
Ryan Jendoubi [Wed, 4 Aug 2010 15:20:10 +0000 (16:20 +0100)]
Fixed Ctypes::Type::value broken last commit

Also progress on _cast, _valid_for_type.

...Yea, that's right, segfaults are progress. "Wanna fight about it?"

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm

7 years agoFilled out Ctypes::_cast, not yet tested
Ryan Jendoubi [Wed, 4 Aug 2010 13:13:46 +0000 (14:13 +0100)]
Filled out Ctypes::_cast, not yet tested

Need to finish _valid_for_type first, and parameterize generation
of types to have different type objects to test with.

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm