php-src/ext/com_dotnet
Zeev Suraski 7c710a9f9b Use zval_ptr_dtor() to free variables as soon as they hit refcount of 0.
Note:  You should not be using ZVAL_DELREF() in day to day usage.  Instead,
       you should use zval_ptr_dtor().  Use ZVAL_DELREF() only if you're
       messing with the refcount directly and know what you're doing.
Note #2:  For clarity, if you want to initialize a new zval with a refcount
          of 0, it's best to do that directly, instead of using ZVAL_DELREF
          after allocating the zval...
2004-02-15 12:58:19 +00:00
..
tests Make these tests work under win32 2003-12-05 13:42:04 +00:00
com_com.c zend_default_classes.h -> zend_exceptions.h 2004-02-12 10:43:27 +00:00
com_dotnet.c zend_default_classes.h -> zend_exceptions.h 2004-02-12 10:43:27 +00:00
com_extension.c zend_default_classes.h -> zend_exceptions.h 2004-02-12 10:43:27 +00:00
com_handlers.c fix copy-n-past error in constructor. 2004-02-12 12:11:21 +00:00
com_iterator.c zend_default_classes.h -> zend_exceptions.h 2004-02-12 10:43:27 +00:00
com_misc.c zend_default_classes.h -> zend_exceptions.h 2004-02-12 10:43:27 +00:00
com_olechar.c - A belated happy holidays and PHP 5 2004-01-08 08:18:22 +00:00
com_saproxy.c Use zval_ptr_dtor() to free variables as soon as they hit refcount of 0. 2004-02-15 12:58:19 +00:00
com_typeinfo.c - A belated happy holidays and PHP 5 2004-01-08 08:18:22 +00:00
com_variant.c - A belated happy holidays and PHP 5 2004-01-08 08:18:22 +00:00
com_wrapper.c - A belated happy holidays and PHP 5 2004-01-08 08:18:22 +00:00
config.w32 Port other major parts of PHP 4 COM extension into PHP 5 com_dotnet 2004-01-07 21:00:07 +00:00
CREDITS add credits 2003-08-14 20:48:06 +00:00
php_com_dotnet_internal.h - Update with new destructor code 2004-02-04 11:14:47 +00:00
php_com_dotnet.h - Happy new year and PHP 5 for rest of the files too.. 2004-01-08 17:33:29 +00:00
README update todo part of readme 2004-01-20 11:01:16 +00:00

This is the new php5 COM module.

It is not 100% backwards compatible with PHP 4 ext/com, but you should not miss
the "features" that have not been retained.

This module exposes 3 classes: variant, com and dotnet(*).
com and dotnet classes are descendants of the variant class; the only
difference between the three are their constructors.  Once instantiated, the
module doesn't make a distinction between them.

COM errrors are mapped to exceptions; you should protect your COM code using
the try..catch construct if you want to be able to handle error conditions.

Be warned that due to the way the ZE2 currently works, exceptions are only
"armed" at the time they are detected, but do not "detonate" until the end of
the statement.  So, code like this:

  $obj->foo[43]->bar();

Where the foo[43] access triggers an exception will continue to call the bar()
method on a null object and cause a fatal php error.

Default properties and array access:

$obj = new COM("...");
$obj[1]->foo();

The code above will use the type information for the object to determine its
default property and then access it.  In PHP 4, it was hard-coded to use the
"Items" member, which was wrong.

The default property will also be used by the casting support to determine the
value for the object.

Variants:

This implementation of COM takes a simpler approach than the PHP 4 version;
we only map a few native types to COM and vice-versa, leaving the more complex
things as variants.  This allows greater consistency of data when passing
parameters to and from COM objects (no data will be lost).  In addition, a
large number of the variant API has been mapped to PHP space so that you can
use it for working with the special variant decimal, currency and date time
types.  This could be used as a replacement for the bcmath extension, for
example.

You can use the new object casting hook to for a php-native representation of
a variant object:

$a = new variant(4);
$b = new variant(6);
$c = variant_add($a, $b);
echo $c; // outputs 10 as a string, instead of Object

Sample Script:

<?php
$word = new COM("word.application");
print "Loaded Word, version {$word->Version}\n"; 
$word->Visible = 1; 
$word->Documents->Add(); 
$word->Selection->TypeText("This is a test..."); 
$word->Documents[1]->SaveAs("Useless test.doc"); 
$word->Quit(); 
?>

TODO:

- Mapping PHP arrays as SafeArray's.  This is currently not done.
  Probably will implement this into $a = new variant($php_array, VT_ARRAY)
  or something similar.
- documentation

* dotnet support requires that you have the mscoree.h header from the .net sdk
  when you build the module.