Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!talisker.lacave.net!lacave.net!not-for-mail From: "futar C." Newsgroups: comp.lang.ruby Subject: Sharing data between ruby and a custom dll with Win32API Date: Mon, 16 May 2011 05:30:14 -0500 Organization: Service de news de lacave.net Lines: 60 Message-ID: <5daf6b7d2acef28191055cb217178954@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1305541843 85260 65.111.164.187 (16 May 2011 10:30:43 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Mon, 16 May 2011 10:30:43 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383304 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <5daf6b7d2acef28191055cb217178954@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4595 Hi All, I'm building a ruby plugin for SketchUp. I created a havok dll (havok is a physic engine) and I need to share/pass data between ruby and the dll. So far I had no problem to send data from ruby to the dll, but I can't figure out the other way. SketchUp 8 uses ruby 1.8.6, so I use the same Win32API version. Here is my ruby code: def get_matrix(index) matrix = Array.new(16,0.1) matrix2 = @getKaplaMatrix.call(index,matrix.pack("f*")) matrix3 = matrix2.unpack("f*") # puts "HELLO HELLO HELLO" # puts matrix3 if (matrix3.size() != 16) puts "WRONG ARRAY" else puts "ARRAY OK" end return matrix3 end Here is my dll code: DECLDIR float* getKaplaMatrix (int indice, float* matrix) { float* kaplaMatrix = havokUtilities->getKaplaMatrix(indice); for(int i=0 ; i < 16; i++) { matrix[i] = kaplaMatrix[i]; } matrix[14]/= 2; matrix[13]/= 2; matrix[12]/= 2; return(matrix); } I'm trying to send a 4x4 matrix (stored in a [16] array) from the dll to ruby, but I always get errors because some returned arrays are too short. I did some tests and found that then there is an "integer" (declared as "1.0") in the array, the value after the "integer" are lost... The result is that among all the arrays I send to ruby, some of then are of the wrong dimension (because some matrix have some zeros values for example). I have not the slightest idea of why this is happening... Thx -- Posted via http://www.ruby-forum.com/.