perl-ctypes:perl-ctypes.git
12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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_

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 years agoAdd tests for ->typecode and ->_data accessors
Ryan Jendoubi [Tue, 3 Aug 2010 17:42:19 +0000 (18:42 +0100)]
Add tests for ->typecode and ->_data accessors

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

12 years agoMerge branch 'callbacks'
Ryan Jendoubi [Tue, 3 Aug 2010 17:24:00 +0000 (18:24 +0100)]
Merge branch 'callbacks'

12 years agoFixed $typeobj++ and --, plus tests
Ryan Jendoubi [Tue, 3 Aug 2010 17:18:27 +0000 (18:18 +0100)]
Fixed $typeobj++ and --, plus tests

Tests before weren't showing up that mutator operators weren't
working. How embarassing~

Also made Type object attributes inaccessible from outside the
Ctypes package - users must use the approved accessors.

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

12 years ago$typeobj->val works as lvalue, updated tests
Ryan Jendoubi [Tue, 3 Aug 2010 13:08:52 +0000 (14:08 +0100)]
$typeobj->val works as lvalue, updated tests

Done by tie'ing $self->{val}.

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

12 years agoType object attribute name changes
Ryan Jendoubi [Sun, 1 Aug 2010 17:03:36 +0000 (18:03 +0100)]
Type object attribute name changes

data->_as_param_, typecode->_typecode_

Simplifies code by allowing Type objects to be queried the same
way as user-defined types/objects (see _make_types_arrayref, esp.
l450+)

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

12 years agoargtypes allow objs, no longer convert->typecodes
Ryan Jendoubi [Sun, 1 Aug 2010 16:42:43 +0000 (17:42 +0100)]
argtypes allow objs, no longer convert->typecodes

Renamed Type overload functions to be consistent with Function.

* Overloaded Types may make internal functions involving argtypes
  more tricky.

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

12 years agot/types.t passes as much as with old call logic
Ryan Jendoubi [Sun, 1 Aug 2010 10:39:17 +0000 (11:39 +0100)]
t/types.t passes as much as with old call logic

Now back to working on Types!

modified:   Ctypes.xs
modified:   src/obj_util.c

12 years agot/callbacks.t passing with new call code
Ryan Jendoubi [Sun, 1 Aug 2010 10:00:18 +0000 (11:00 +0100)]
t/callbacks.t passing with new call code

modified:   lib/Ctypes/Function.pm

12 years agoBasic tests passing with new call logic
Ryan Jendoubi [Sun, 1 Aug 2010 09:46:18 +0000 (10:46 +0100)]
Basic tests passing with new call logic

Failing: callbacks, types

modified:   Ctypes.xs
modified:   lib/Ctypes/Function.pm
modified:   src/obj_util.c

12 years agoFix more mistakes, now C actually compiles
Ryan Jendoubi [Thu, 29 Jul 2010 21:35:29 +0000 (22:35 +0100)]
Fix more mistakes, now C actually compiles

modified:   Ctypes.xs
modified:   src/obj_util.c
modified:   src/util.c

12 years agoFixed lots of silly mistakes
Ryan Jendoubi [Thu, 29 Jul 2010 07:56:24 +0000 (08:56 +0100)]
Fixed lots of silly mistakes

Sometimes one forgets to check things when finishing up around 5am.

modified:   Ctypes.xs
modified:   MANIFEST
modified:   src/obj_util.c

12 years agoFinished new _call (can't test yet)
Ryan Jendoubi [Wed, 28 Jul 2010 04:30:04 +0000 (05:30 +0100)]
Finished new _call (can't test yet)

Need more work in Perl space first, e.g. _CallProc (now removed
from C)

modified:   Ctypes.xs

12 years agoFinish ConvArg, rename things
Ryan Jendoubi [Wed, 28 Jul 2010 04:01:24 +0000 (05:01 +0100)]
Finish ConvArg, rename things

"pack-style", "pack codes" -> type-codes
  This is to reduce the change of users assuming all the
  type-codes are exactly the same as in pack / FFI.pm.
  Updated naming in code and textual references to the term
  pack and pack-style in POD.

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
modified:   lib/Ctypes/Type.pm
renamed:    src/py_funcs.c -> src/obj_util.c

12 years agoGoing down a wrong route with _CallProc
Ryan Jendoubi [Tue, 27 Jul 2010 15:39:50 +0000 (16:39 +0100)]
Going down a wrong route with _CallProc

Should be doing that in Perl.
About to start on new _call function which takes type objects.
Old _call to be renamed_call_raw

modified:   Ctypes.xs

12 years agoFinished some Py func equivalents
Ryan Jendoubi [Tue, 27 Jul 2010 06:04:02 +0000 (07:04 +0100)]
Finished some Py func equivalents

Back to working in _CallProc now.

modified:   Ctypes.xs
modified:   include/Ctypes.h
modified:   src/py_funcs.c

12 years agoSubstantial restructure of C code, add Licenses
Ryan Jendoubi [Tue, 27 Jul 2010 01:05:04 +0000 (02:05 +0100)]
Substantial restructure of C code, add Licenses

Prompted by basically translating Python's _CallPoc into Perl C.
Very annoying that .c files have to be #included instead of just
specified to MakeMaker in some way.

modified:   Ctypes.xs
new file:   LICENSES
modified:   MANIFEST
modified:   Makefile.PL
modified:   README
new file:   include/Ctypes.h
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Function.pm
new file:   src/py_funcs.c
new file:   src/util.c

12 years agoAbout 1/2 way through Py style calling
Ryan Jendoubi [Sun, 25 Jul 2010 21:59:17 +0000 (22:59 +0100)]
About 1/2 way through Py style calling

See the following:

http://svn.python.org/projects/external/ctypes/source/callproc.c
(21-60), (417-442)

http://svn.python.org/projects/external/ctypes/source/ctypes.h
(193-258)

http://docs.python.org/library/ctypes.html
Particularly 15.16.2 (Reference section)

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

12 years agoCall c_int::new without initializer
Ryan Jendoubi [Sat, 24 Jul 2010 19:09:15 +0000 (20:09 +0100)]
Call c_int::new without initializer

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

12 years agoCleaning up leftover old code in _cast_value
Ryan Jendoubi [Fri, 23 Jul 2010 05:24:24 +0000 (06:24 +0100)]
Cleaning up leftover old code in _cast_value

modified:   Ctypes.xs

12 years agoClean up, use std C macros for type range checks
Ryan Jendoubi [Fri, 23 Jul 2010 05:08:22 +0000 (06:08 +0100)]
Clean up, use std C macros for type range checks

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

12 years agoVery faulty logic in _cast_value
Ryan Jendoubi [Thu, 22 Jul 2010 22:50:16 +0000 (23:50 +0100)]
Very faulty logic in _cast_value

Just wanted to make a note of it before changing

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

12 years agoRemoved extraneous tie'ing of $self->{val}
Ryan Jendoubi [Thu, 22 Jul 2010 00:46:20 +0000 (01:46 +0100)]
Removed extraneous tie'ing of $self->{val}

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

12 years agoSubtest for setting new val, fixed $DEBUG value
Ryan Jendoubi [Wed, 21 Jul 2010 13:44:16 +0000 (14:44 +0100)]
Subtest for setting new val, fixed $DEBUG value

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

12 years agoMade ->(num) work for changing value of Type obj
Ryan Jendoubi [Mon, 19 Jul 2010 00:52:20 +0000 (01:52 +0100)]
Made ->(num) work for changing value of Type obj

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

12 years agoCleaned up this example, but...
Ryan Jendoubi [Sun, 18 Jul 2010 05:24:03 +0000 (06:24 +0100)]
Cleaned up this example, but...

This implementation won't work because assigning:

  $char_var = $int_var;

...will change $char_var into a c_int object, instead
of just giving the value as is expected.

Need to change around when tie is done and what overload
funcs do...

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

12 years agoWas using tie wrongly
Ryan Jendoubi [Sun, 18 Jul 2010 05:01:01 +0000 (06:01 +0100)]
Was using tie wrongly

Was storing the value manipulated by STORE and FETCH in the same
  part of the object that was tied - the point of course is to
  put it somewhere else.

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

12 years agoFirst (failed) attempt at type objects
Ryan Jendoubi [Sun, 18 Jul 2010 03:54:39 +0000 (04:54 +0100)]
First (failed) attempt at type objects

See lib/Ctypes/Type.pm. Tried to use tie'ing for FETCHing and
  STOREing Type values. 2 problems:
  a) trying to encorporate all in same class is complex
  b) FETCH seems to set its tied var to the value returned
Going to try to fix b) by using overloading instead, then look
  at a) again.

modified:   Ctypes.xs
modified:   lib/Ctypes/Type.pm
new file:   t/types.t

12 years agoFixed Function::new and _form_sig
Ryan Jendoubi [Sat, 17 Jul 2010 14:00:05 +0000 (15:00 +0100)]
Fixed Function::new and _form_sig

_form_sig had never been called before last commit.

modified:   lib/Ctypes/Function.pm

12 years agoFix win32 file perm
doubi [Sat, 17 Jul 2010 02:14:49 +0000 (03:14 +0100)]
Fix win32 file perm

modified:   t/win-proto.t

12 years agoCleaned up debug output messages
doubi [Thu, 15 Jul 2010 16:49:32 +0000 (17:49 +0100)]
Cleaned up debug output messages

Also removed const-c.inc from git

modified:   Ctypes.xs
deleted:    const-c.inc
modified:   lib/Ctypes/Callback.pm
modified:   t/callbacks.t

12 years agoSomewhat ameliorated failing win-proto test
Ryan Jendoubi [Tue, 13 Jul 2010 04:39:24 +0000 (05:39 +0100)]
Somewhat ameliorated failing win-proto test

modified:   MANIFEST
modified:   MANIFEST.SKIP
new file:   lib/Ctypes/WinTypes.pm
modified:   t/win-proto.t

12 years agoFixed win32 func-access.t to match Function::new
Ryan Jendoubi [Tue, 13 Jul 2010 02:32:48 +0000 (03:32 +0100)]
Fixed win32 func-access.t to match Function::new

We die on the attempted creation of a non-extant Function obj
  rather than returning a useless object.

modified:   lib/Ctypes.pm
modified:   t/func-access.t

12 years agoFixed callbacks.t & updated ignore files
Ryan Jendoubi [Mon, 12 Jul 2010 16:53:33 +0000 (17:53 +0100)]
Fixed callbacks.t & updated ignore files

modified:   .gitignore
modified:   MANIFEST.SKIP
modified:   Makefile.PL
modified:   const-c.inc
modified:   ignore.txt
modified:   t/callbacks.t

12 years agoCallbacks work but leak memory
Ryan Jendoubi [Mon, 12 Jul 2010 02:54:30 +0000 (03:54 +0100)]
Callbacks work but leak memory

The closure object seems faulty after ffi_prep_closure_loc.
Tests pass but callbacks.t registers as FAIL due to aborting
  while trying to free closure in global destruction
Also pulled in fixes for other tests from branch py_style_calls.

modified:   Ctypes.xs
modified:   MANIFEST
modified:   lib/Ctypes/Callback.pm
modified:   lib/Ctypes/Type.pm
modified:   t/callbacks.t
modified:   t/pod-coverage.t
modified:   t/win-proto.t

12 years agoRemoved _writable attr, store in cb_data_t
Ryan Jendoubi [Tue, 6 Jul 2010 04:24:47 +0000 (05:24 +0100)]
Removed _writable attr, store in cb_data_t

Allocated ffi_closure (the 'writable' address) now stored in $obj's
cb_data_t struct, exposing less data unnecessarily to Perl-space.

modified:   Ctypes.xs
modified:   lib/Ctypes/Callback.pm
modified:   t/callbacks.t

12 years agoRemoved memory lead in Ctypes::_call
Ryan Jendoubi [Sun, 4 Jul 2010 12:04:32 +0000 (13:04 +0100)]
Removed memory lead in Ctypes::_call

Before memory was not allocated for 'p' argtypes so free'ing was
only done for non 'p' types. Pointer argtypes have been allocated
for a few revisions though; just brought free'ing up to date.

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

12 years ago_perl_cb_call now managing stack correctly
Ryan Jendoubi [Sun, 4 Jul 2010 11:55:56 +0000 (12:55 +0100)]
_perl_cb_call now managing stack correctly

modified:   Ctypes.xs

12 years agoFixed accessing args** from _perl_cb_call
Ryan Jendoubi [Sat, 3 Jul 2010 11:04:16 +0000 (12:04 +0100)]
Fixed accessing args** from _perl_cb_call

See [0]; before the cif was Newx'd but its arg_types is a
/pointer/ to the values given locally in _make_callback,
not a copy. Newx'ing argtypes (Ctypes.xs:461) solves the
problem (with matching Safefree line 532).

To do now:
- Management of Perl stack in _perl_cb_call is wrong somehow,
  values not appearing in @_ in Perl space.
- _make_callback needs cleaned up.
- qsort's $cb currently defined in callbacks.t as taking 2 ints,
  but really requires 2 pointers. Will this become a problem?
  If changed to pointers values will need unpack'd in Perl cb

[0]:
http://old.nabble.com/shallow-copying-in-ffi_prep_cif-td28082268.html

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

12 years agoReally fixed _make_callback now
Ryan Jendoubi [Fri, 2 Jul 2010 20:21:16 +0000 (21:21 +0100)]
Really fixed _make_callback now

... I think. At any rate, now working in both debugging and non-
debugging perls.

Also some cleanup.

modified:   Ctypes.xs
modified:   lib/Ctypes.pm
modified:   t/callbacks.t

12 years agoFixed segfault due to local perlcall_cif
Ryan Jendoubi [Fri, 2 Jul 2010 11:53:16 +0000 (12:53 +0100)]
Fixed segfault due to local perlcall_cif

Noticed _perl_cb_call wasn't receiving the right cif. Clearly
ffi_prep_closure_loc just stores a Pointer to the cif, not by val.
perlcall_cif was just a local variable in _make_closure; now
allocated (and added to struct _perl_cb_data for free'ing later).

Now segfaulting on pushing vars to Perl stack but this should
be simpler.

modified:   Ctypes.xs

12 years agoChanged casts to stop compile warnings
Ryan Jendoubi [Fri, 2 Jul 2010 11:12:20 +0000 (12:12 +0100)]
Changed casts to stop compile warnings

All I can think to try now is change the way ptrs are assigned
to the way it was before. Will require changes in a few places.

modified:   Ctypes.xs

12 years agoCleanup, better explanatory debug output
Ryan Jendoubi [Fri, 2 Jul 2010 08:57:27 +0000 (09:57 +0100)]
Cleanup, better explanatory debug output

Still segfaulting in ffi_call on non-debug perl. gdb time.

modified:   Ctypes.xs

12 years agoCleanup / better explanatory debug messages
Ryan Jendoubi [Fri, 2 Jul 2010 08:56:22 +0000 (09:56 +0100)]
Cleanup / better explanatory debug messages

modified:   Ctypes.xs
modified:   const-c.inc

12 years agoPut ptrs from Perl in more predictable place,but...
Ryan Jendoubi [Fri, 2 Jul 2010 08:43:26 +0000 (09:43 +0100)]
Put ptrs from Perl in more predictable place,but...

Still segfault in non-debugging perl

modified:   Ctypes.xs

12 years agoMore callbacks work
Ryan Jendoubi [Thu, 1 Jul 2010 21:47:46 +0000 (22:47 +0100)]
More callbacks work

Test gets to different points with different build options and
debugging/non-debugging perl.

modified:   Ctypes.xs
modified:   const-c.inc
modified:   lib/Ctypes.pm
modified:   lib/Ctypes/Callback.pm
modified:   t/callbacks.t

12 years agoIncorporate improved ::Function::sig from branch
Ryan Jendoubi [Thu, 1 Jul 2010 10:23:04 +0000 (11:23 +0100)]
Incorporate improved ::Function::sig from branch

Pulled in from callbacks branch

modified:   lib/Ctypes/Function.pm

12 years agoImproved new sub sig() in Function.pm
Ryan Jendoubi [Thu, 1 Jul 2010 10:21:04 +0000 (11:21 +0100)]
Improved new sub sig() in Function.pm

Check if $self->{argtypes} exists before appending to
abi + restype (which are always given a value on instantiation).

modified:   lib/Ctypes/Function.pm

12 years agoFixed returning 3 args from _make_callback
Ryan Jendoubi [Thu, 1 Jul 2010 10:13:42 +0000 (11:13 +0100)]
Fixed returning 3 args from _make_callback

Returning pcb_data wasn't working without supplying length of
  pointer to newSVpv.
If dumped with Devel::Peek both _executable and _writable look
  like they have the same value back in Perl. Problem?

modified:   Ctypes.xs
modified:   lib/Ctypes/Callback.pm
modified:   lib/Ctypes/Function.pm
modified:   t/callbacks.t

12 years agoChased down segfault to improper ffi_prep_cif
Ryan Jendoubi [Wed, 30 Jun 2010 23:39:14 +0000 (00:39 +0100)]
Chased down segfault to improper ffi_prep_cif

Also modified ::Function->sig() to create sig if none exists.

modified:   Ctypes.xs
modified:   const-c.inc
modified:   lib/Ctypes/Callback.pm
modified:   lib/Ctypes/Function.pm
modified:   t/callbacks.t

12 years agoMore callbacks work, much debugging needed
Ryan Jendoubi [Wed, 30 Jun 2010 20:45:47 +0000 (21:45 +0100)]
More callbacks work, much debugging needed

::Callback object now keeps ptr to its own perl_cb_data struct
  for free'ing later.
At one point I'd added the writable closure address to
  perl_cb_data but damned if I can remember why now...
  so removed it.

Results for '"ffi_prep_closure_loc" lang:c' on Google codesearch
  used as reference.

modified:   Ctypes.xs
modified:   MANIFEST
modified:   lib/Ctypes/Callback.pm
modified:   t/callbacks.t

12 years agoChange of tactic
Ryan Jendoubi [Wed, 30 Jun 2010 16:53:35 +0000 (17:53 +0100)]
Change of tactic

Callback::new now constructs obj in Perl, calls to _make_callback
in XS to get writable and executable ptrs from ffi_closure_alloc etc.

Everything still v. unfinished

modified:   Ctypes.xs
new file:   lib/Ctypes/Callback.pm

12 years agoCreated perl_cb_data struct
Ryan Jendoubi [Wed, 30 Jun 2010 15:58:59 +0000 (16:58 +0100)]
Created perl_cb_data struct

modified:   Ctypes.xs

12 years agoStart of callbacks work
Ryan Jendoubi [Wed, 30 Jun 2010 12:02:02 +0000 (13:02 +0100)]
Start of callbacks work

modified:   Ctypes.xs
new file:   t/callbacks.t

12 years agoCleanup _call variable declarations
Ryan Jendoubi [Tue, 29 Jun 2010 18:11:14 +0000 (19:11 +0100)]
Cleanup _call variable declarations

modified:   Ctypes.xs

12 years agoMerge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes into callbacks
Ryan Jendoubi [Tue, 29 Jun 2010 17:38:34 +0000 (18:38 +0100)]
Merge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes into callbacks

12 years agoCleanup _call args
Ryan Jendoubi [Tue, 29 Jun 2010 17:37:50 +0000 (18:37 +0100)]
Cleanup _call args

modified:   Ctypes.xs

12 years agoMerge types and prototypes API.
Reini Urban [Mon, 28 Jun 2010 19:16:10 +0000 (21:16 +0200)]
Merge types and prototypes API.
Improve pod, and add API for the utilities.

12 years agoBetter _call error detection, improve test coverage
Reini Urban [Sun, 27 Jun 2010 10:06:59 +0000 (12:06 +0200)]
Better _call error detection, improve test coverage

Strict check sig for string, otherwise the first arg can be stringified to
  something which looks like a sig.
Test wrong _call usage: coverage 43% - only the types are missing now

12 years agomore DLL docs
Reini Urban [Thu, 24 Jun 2010 20:16:44 +0000 (22:16 +0200)]
more DLL docs

12 years agoMore reading of python ctypes:
Reini Urban [Thu, 24 Jun 2010 20:05:49 +0000 (22:05 +0200)]
More reading of python ctypes:
  renamed rtype => restype, atypes => argtypes
  restype is a DLL default

enhanced POD
out-commented const-*.inc

12 years agoSupport pack-style strings for atypes (brevity)
Reini Urban [Thu, 24 Jun 2010 19:12:14 +0000 (21:12 +0200)]
Support pack-style strings for atypes (brevity)
Fix pod sample.

12 years agoReorder private funcs
Ryan Jendoubi [Thu, 24 Jun 2010 10:33:45 +0000 (11:33 +0100)]
Reorder private funcs

modified:   lib/Ctypes/Function.pm

12 years agoMerge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes
Ryan Jendoubi [Thu, 24 Jun 2010 10:30:52 +0000 (11:30 +0100)]
Merge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes

12 years agoFinished adding rurban's logic to Function::new
Ryan Jendoubi [Thu, 24 Jun 2010 10:29:07 +0000 (11:29 +0100)]
Finished adding rurban's logic to Function::new

Defaults now set for $rtype and $abi, checking done on latter.
_call also becomes much simpler.

modified:   lib/Ctypes/Function.pm

12 years agoremove pod for unused validate_types
Reini Urban [Wed, 23 Jun 2010 19:52:22 +0000 (21:52 +0200)]
remove pod for unused validate_types

12 years ago::Function API more like C::DynaLib/Python ctypes
Ryan Jendoubi [Wed, 23 Jun 2010 19:19:01 +0000 (20:19 +0100)]
::Function API more like C::DynaLib/Python ctypes

Should be more internally consistent. Get/set sig now updates
abi, rtype, atypes. Actual sig passed at call time put together
from these three attributes.
See new POD.

modified:   lib/Ctypes/Function.pm

12 years agoMerge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes
Reini Urban [Tue, 22 Jun 2010 18:34:05 +0000 (20:34 +0200)]
Merge branch 'master' of gitorious.org:perl-ctypes/perl-ctypes

Protect from no arg definitions in sig.
func-access.t: skips needs the number
  fix sig (again)

Conflicts:
t/func-access.t