Added DECLARE_HANDLE template; used it to define handle types; implemented fixes pointed out to me by alaing in an email

git-svn-id: http://svn.dsource.org/projects/bindings/trunk@417 e3080b08-b6e0-0310-b0a6-cbd5e3aa05fd