<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -189,3 +189,4 @@ A quick cap of the current lib/ionize directory:
 	treetop
 	treetop.rb
 	version.rb
+</diff>
      <filename>doc/getting_started.txt</filename>
    </modified>
    <modified>
      <diff>@@ -160,8 +160,6 @@ zval *create_array() {
   return new_array;
 }
 
-
-
 VALUE php_array_keys(VALUE self) {
   REQUIRE_PHP_SESSION;
 
@@ -576,7 +574,7 @@ VALUE php_include_file(VALUE self, VALUE filename) {
   return result;
 }
 
-
+/*
 VALUE php_call_user_function1(VALUE self, VALUE function_name) {
   REQUIRE_PHP_SESSION;
   VALUE result;
@@ -621,10 +619,10 @@ VALUE php_call_user_function2(VALUE self, VALUE function_name, VALUE arg1) {
   //  inspect_zhash(args[0]);
   
   if (FAILURE == call_user_function(EG(function_table), NULL, &amp;funcname, &amp;return_value, 1, args)) {
-    if (EG(exception)) {
-      zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), &quot;message&quot;, sizeof(&quot;message&quot;)-1, 0 TSRMLS_CC);
-      printf(&quot;Php error message is %s\n&quot; , Z_STRVAL_P(msg));
-    }
+    //    if (EG(exception)) {
+      //      zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), &quot;message&quot;, sizeof(&quot;message&quot;)-1, 0 TSRMLS_CC);
+      //      printf(&quot;Php error message is %s\n&quot; , Z_STRVAL_P(msg));
+    //    }
 
     rb_raise(rb_eRuntimeError, &quot;Calling php function failed&quot;);
     return Qnil;
@@ -666,13 +664,13 @@ VALUE php_call_user_function3(VALUE self, VALUE function_name, VALUE arg1, VALUE
   zval *z_arg1; MAKE_STD_ZVAL(z_arg1); rb_value2zval2(arg1, z_arg1); args[0] = z_arg1;
   zval *z_arg2; MAKE_STD_ZVAL(z_arg2); rb_value2zval2(arg2, z_arg2); args[1] = z_arg2;
   
-  /*
-  MAKE_STD_ZVAL(args[0]);
-  rb_value2zval2(arg1, args[0]);  
+  
+  //MAKE_STD_ZVAL(args[0]);
+  //rb_value2zval2(arg1, args[0]);  
 
-  MAKE_STD_ZVAL(args[1]);
-  rb_value2zval2(arg2, args[1]);  
-  */
+  //MAKE_STD_ZVAL(args[1]);
+  //rb_value2zval2(arg2, args[1]);  
+  
 
   if (FAILURE == call_user_function(EG(function_table), NULL, &amp;funcname, &amp;return_value, 2, args TSRMLS_CC)) {
     rb_raise(rb_eRuntimeError, &quot;Calling php function failed&quot;);
@@ -810,6 +808,35 @@ VALUE php_call_user_function7(VALUE self, VALUE function_name, VALUE arg1, VALUE
   return result;
 }
 
+*/
+
+VALUE php_call_user_function_n(int argc, VALUE *argv, VALUE self) {
+  zval *args[argc-1];
+
+  zval return_value;
+  zval funcname;
+
+  VALUE result;
+  
+  rb_value2zval2(argv[0], &amp;funcname);
+
+  int i;
+  for (i = 1; i &lt; argc; i++) {
+    MAKE_STD_ZVAL(args[i-1]);
+    rb_value2zval2(argv[i], args[i-1]);
+  }
+  
+  if (FAILURE == call_user_function(EG(function_table), NULL, &amp;funcname, &amp;return_value, argc-1, args TSRMLS_CC)) {
+    // TODO: Raise an error of what actually went wrong..
+    rb_raise(rb_eRuntimeError, &quot;Calling php function failed&quot;);
+    return Qnil;
+  }
+  
+  result = zval2rb_value_p(&amp;return_value);
+
+  return result;  
+}
+
 
 
 /*******************************************************
@@ -978,7 +1005,6 @@ static VALUE ionize_php_array_new2(zval *zvalue_p) {
 
 static VALUE ionize_php_array_real_inspect(VALUE self) {
   //  printf(&quot;Doing real php array inspect\n&quot;);
-
   REQUIRE_PHP_SESSION;
 
   VALUE str, hash_key, hash_value;
@@ -1229,8 +1255,6 @@ static VALUE ionize_php_array_has_key(VALUE self, VALUE key) {
  *******************************************************/
 
 static void ionize_php_object_free(ionize_php_object_t *ionize_object) {
-  //  REQUIRE_PHP_SESSION;
-
   if (ionize_object-&gt;zvalue_p) {
     zval_ptr_dtor(&amp;ionize_object-&gt;zvalue_p);
   }
@@ -1281,11 +1305,44 @@ static VALUE ionize_php_object_inspect(VALUE self) {
 
   str = rb_obj_as_string(self);
   OBJ_INFECT(str, self);
-  RSTRING(str)-&gt;ptr[RSTRING(str)-&gt;len-1]=' ';
+  RSTRING(str)-&gt;ptr[RSTRING(str)-&gt;len-1] = ' ';
 
   return str;
 }
 
+VALUE ionize_php_object_call_function_n(int argc, VALUE *argv, VALUE self) {
+  REQUIRE_PHP_SESSION;  
+  
+  ionize_php_object_t *ionize_object;
+  Data_Get_Struct(self, ionize_php_object_t, ionize_object);
+
+  zval *args[argc-1];
+
+  zval return_value;
+  zval funcname;
+
+  VALUE result;
+  
+  rb_value2zval2(argv[0], &amp;funcname);
+
+  int i;
+  for (i = 1; i &lt; argc; i++) {
+    MAKE_STD_ZVAL(args[i-1]);
+    rb_value2zval2(argv[i], args[i-1]);
+  }
+
+  if (FAILURE == call_user_function(CG(function_table), &amp;ionize_object-&gt;zvalue_p, &amp;funcname, &amp;return_value, argc-1, args TSRMLS_CC)) {
+    // TODO: Raise an error of what actually went wrong..
+    rb_raise(rb_eRuntimeError, &quot;Calling php function failed&quot;);
+    return Qnil;
+  }
+
+  result = zval2rb_value_p(&amp;return_value);
+
+  return result;  
+}
+
+
 
 /*******************************************************
  Ionize::Php::Resource (Php resources that live in Rubyland)
@@ -1373,6 +1430,7 @@ VALUE php_session_end_b(VALUE self) {
 }
 
 
+/*
 VALUE php_last_error_message(VALUE self) {
   if (EG(exception)) {
     zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), &quot;message&quot;, sizeof(&quot;message&quot;)-1, 0 TSRMLS_CC);
@@ -1381,6 +1439,7 @@ VALUE php_last_error_message(VALUE self) {
     return Qnil;
   }
 }
+*/
 
 
 void Init_ionize_php_ext() {
@@ -1395,17 +1454,11 @@ void Init_ionize_php_ext() {
   // Ionize::Php
   rb_define_module_function(rb_mIonizePhp, &quot;eval&quot;, ionize_php_eval_string, 1);
   rb_define_module_function(rb_mIonizePhp, &quot;include&quot;, php_include_file, 1);
-  rb_define_module_function(rb_mIonizePhp, &quot;last_error_message&quot;, php_last_error_message, 0);  
+  //  rb_define_module_function(rb_mIonizePhp, &quot;last_error_message&quot;, php_last_error_message, 0);  
 
   //  rb_define_module_function(rb_mIonizePhp, &quot;array_keys&quot;, php_array_keys, 0);
 
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function1&quot;, php_call_user_function1, 1);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function2&quot;, php_call_user_function2, 2);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function3&quot;, php_call_user_function3, 3);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function4&quot;, php_call_user_function4, 4);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function5&quot;, php_call_user_function5, 5);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function6&quot;, php_call_user_function6, 6);
-  rb_define_module_function(rb_mIonizePhp, &quot;call_function7&quot;, php_call_user_function7, 7);
+  rb_define_module_function(rb_mIonizePhp, &quot;call_function_n&quot;, php_call_user_function_n, -1);
 
   rb_define_module_function(rb_mIonizePhp, &quot;session&quot;, php_session_with_block, 0);
   rb_define_module_function(rb_mIonizePhp, &quot;session_start!&quot;, php_session_start_b, 0);
@@ -1433,6 +1486,7 @@ void Init_ionize_php_ext() {
   rb_cIonizePhpObject = rb_define_class_under(rb_mIonizePhp, &quot;Object&quot;, rb_cObject);
   rb_define_method(rb_cIonizePhpObject, &quot;inspect&quot;, ionize_php_object_inspect, 0);
   rb_define_method(rb_cIonizePhpObject, &quot;instance_variables_hash&quot;, ionize_php_object_instance_variables_hash, 0);
+  rb_define_method(rb_cIonizePhpObject, &quot;call_function_n&quot;, ionize_php_object_call_function_n, -1);
 
   // Ionize::Php::Resource
   rb_cIonizePhpResource = rb_define_class_under(rb_mIonizePhp, &quot;Resource&quot;, rb_cObject);</diff>
      <filename>ext/ionize_php_ext.c</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>ext/ionize_php_ext.o</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>ext/ionize_php_ext.so</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,12 @@
 
 require File.dirname(__FILE__) + '/ionize_php_ext'
 
-Ionize::Php.start_session!
+Ionize::Php.session do
+  result = Ionize::Php.eval(%Q{ return array(&quot;okay&quot; =&gt; 100, &quot;color&quot; =&gt; &quot;red&quot;); })
+  keys = Ionize::Php.call_function_n('array_keys', result)
+  puts keys.inspect
+  
+  link = Ionize::Php.call_function_n('mysql_connect', 'localhost', 'mysql_user', 'mysql_password')
+  Ionize::Php.call_function_n('mysql_close', link)
+end
 
-result = Ionize::Php.eval(%Q{ return array(&quot;okay&quot; =&gt; 100, &quot;color&quot; =&gt; &quot;red&quot;); })
-keys = Ionize::Php.call_function2('array_keys', result)
-puts keys.inspect
-
-values = Ionize::Php.call_function2('array_values', result)
-puts values.inspect
-
-last = Ionize::Php.call_function2('array_pop', result)
-puts result.inspect
-puts last.inspect
-
-Ionize::Php.end_session!</diff>
      <filename>ext/test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,38 +40,38 @@ describe &quot;Working with Php::Array&quot; do
 
   it &quot;should take an array as a php argument&quot; do
     stack = Ionize::Php::Array.from_array([&quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;, &quot;raspberry&quot;])
-    fruit = Ionize::Php.call_function2('array_pop', stack)
+    fruit = Ionize::Php.call_function_n('array_pop', stack)
     stack.to_hash.should == {0 =&gt; &quot;orange&quot;, 1 =&gt; &quot;banana&quot;, 2 =&gt; &quot;apple&quot;}
     fruit.should == &quot;raspberry&quot;
   end
 
   it &quot;should take nested arrays&quot; do
     array = Ionize::Php.eval(%Q{ return array('a' =&gt; 'apple', 'b' =&gt; 'banana', 'c' =&gt; array ('x', 'y', 'z')); })
-    result = Ionize::Php.call_function3('print_r', array, true)
+    result = Ionize::Php.call_function_n('print_r', array, true)
     result.should == &quot;Array\n(\n    [a] =&gt; apple\n    [b] =&gt; banana\n    [c] =&gt; Array\n        (\n            [0] =&gt; x\n            [1] =&gt; y\n            [2] =&gt; z\n        )\n\n)\n&quot;
   end
 
   it &quot;should return the array keys&quot; do
     result = Ionize::Php.eval(%Q{ return array(0 =&gt; 100, &quot;color&quot; =&gt; &quot;red&quot;); })
-    keys = Ionize::Php.call_function2('array_keys', result)
+    keys = Ionize::Php.call_function_n('array_keys', result)
     keys.to_hash.should == {0 =&gt; 0, 1 =&gt; &quot;color&quot;}
   end
 
   it &quot;should return the array values&quot; do
     result = Ionize::Php.eval(%Q{ return array(0 =&gt; 100, &quot;color&quot; =&gt; &quot;red&quot;); })
-    values = Ionize::Php.call_function2('array_values', result)
+    values = Ionize::Php.call_function_n('array_values', result)
     values.to_hash.should == {0 =&gt; 100, 1 =&gt; &quot;red&quot;}
   end
 
   it &quot;should flip the array&quot; do
     result = Ionize::Php.eval(%Q{ return array(0 =&gt; 100, &quot;color&quot; =&gt; &quot;red&quot;); })
-    flipped = Ionize::Php.call_function2('array_flip', result)
+    flipped = Ionize::Php.call_function_n('array_flip', result)
     flipped.to_hash.should == {100 =&gt; 0, &quot;red&quot; =&gt; &quot;color&quot;}
   end
 
   it &quot;should pad the array&quot; do
     input     = Ionize::Php.eval(%Q{ return array(12, 10, 9); })
-    new_input = Ionize::Php.call_function4('array_pad', input, 5, 0);
+    new_input = Ionize::Php.call_function_n('array_pad', input, 5, 0);
     new_input.to_hash.should == {0 =&gt; 12, 1 =&gt; 10, 2 =&gt; 9, 3 =&gt; 0, 4 =&gt; 0}
   end
 
@@ -107,11 +107,11 @@ describe &quot;Working with Php::Array&quot; do
 
   it &quot;should maintain the array's internal pointer&quot; do
     array = Ionize::Php::Array.from_array(['step one', 'step two', 'step three', 'step four'])
-    Ionize::Php.call_function2('current', array).should == &quot;step one&quot;
-    Ionize::Php.call_function2('next', array)
-    Ionize::Php.call_function2('next', array)
-    Ionize::Php.call_function2('current', array).should == &quot;step three&quot;    
-    Ionize::Php.call_function2('reset', array)
-    Ionize::Php.call_function2('current', array).should == &quot;step one&quot;
+    Ionize::Php.call_function_n('current', array).should == &quot;step one&quot;
+    Ionize::Php.call_function_n('next', array)
+    Ionize::Php.call_function_n('next', array)
+    Ionize::Php.call_function_n('current', array).should == &quot;step three&quot;    
+    Ionize::Php.call_function_n('reset', array)
+    Ionize::Php.call_function_n('current', array).should == &quot;step one&quot;
   end
 end  </diff>
      <filename>spec/extension/array_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,30 +17,12 @@ describe &quot;Working with call_function and eval&quot; do
   end
 
   it &quot;should provide the right version number&quot; do
-    Ionize::Php.call_function1('phpversion').should == &quot;5.2.9&quot;
-  end
-
-  it &quot;should give the string length&quot; do
-    Ionize::Php.call_function2('strlen', 'abc').should == 3
-  end
-
-  it &quot;should ... &quot; do
-    Ionize::Php.call_function3('substr', &quot;abcdef&quot;, -1).should == &quot;f&quot;
-  end
-
-  it &quot;should find the string length of a big text file&quot; do
-    Ionize::Php.call_function2('strlen', File.read(&quot;/home/robinhoode/dev/ruby/other/ionize/spec/fixtures/drupal_4.php&quot;)).should == 5212
-  end
-
-  it &quot;should parse a small bit of php&quot; do
-    calling do
-      Ionize::Php.call_function2('token_get_all', %Q{ &lt;?php phpinfo(); ?&gt; })
-    end.should_not raise_error
+    Ionize::Php.call_function_n('phpversion').should == &quot;5.2.9&quot;
   end
 
   it &quot;should call a php function with a null argument with segfaulting&quot; do
     calling do
-      Ionize::Php.call_function2('empty', nil)
+      Ionize::Php.call_function_n('empty', nil)
     end.should_not raise_error
   end
 </diff>
      <filename>spec/extension/call_and_eval_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,6 +51,8 @@ describe &quot;Working with objects&quot; do
   end
 
   it &quot;should call an object's function&quot; do
-    raise &quot;Not implemented&quot;
+    veggie = Ionize::Php.eval(%Q{ return new Vegetable(true, &quot;blue&quot;); })
+    veggie.call_function_n('is_edible').should  == true
+    veggie.call_function_n('what_color').should == &quot;blue&quot;
   end
 end</diff>
      <filename>spec/extension/object_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,6 @@ describe &quot;Working with resources&quot; do
   end
 
   it &quot;should return a resource&quot; do
-    handle = Ionize::Php.call_function3('fopen', &quot;spec/fixtures/drupal_1.php&quot;, &quot;r&quot;)
+    handle = Ionize::Php.call_function_n('fopen', &quot;spec/fixtures/drupal_1.php&quot;, &quot;r&quot;)
   end
 end</diff>
      <filename>spec/extension/resource_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,4 +16,22 @@ describe &quot;Working with php strings&quot; do
     Ionize::Php.session_end!    
   end
 
+  it &quot;should give the string length&quot; do
+    Ionize::Php.call_function_n('strlen', 'abc').should == 3
+  end
+
+  it &quot;should find the substring of a given string &quot; do
+    Ionize::Php.call_function_n('substr', &quot;abcdef&quot;, -1).should == &quot;f&quot;
+  end
+
+  it &quot;should find the string length of a big text file&quot; do
+    Ionize::Php.call_function_n('strlen', File.read(&quot;/home/robinhoode/dev/ruby/other/ionize/spec/fixtures/drupal_4.php&quot;)).should == 5212
+  end
+
+  it &quot;should parse a small bit of php&quot; do
+    calling do
+      Ionize::Php.call_function_n('token_get_all', %Q{ &lt;?php phpinfo(); ?&gt; })
+    end.should_not raise_error
+  end
+
 end</diff>
      <filename>spec/extension/strings_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>52c6bd3cd37b00335e5f13d3bed094a38b926f85</id>
    </parent>
  </parents>
  <author>
    <name>farleyknight</name>
    <email>farleyknight+github@gmail.com</email>
  </author>
  <url>http://github.com/farleyknight/ionize/commit/4dbb5b69c8951e790eb855cdd4ba915b46ea1cb7</url>
  <id>4dbb5b69c8951e790eb855cdd4ba915b46ea1cb7</id>
  <committed-date>2009-06-07T15:31:15-07:00</committed-date>
  <authored-date>2009-06-07T15:31:15-07:00</authored-date>
  <message>Added support for variable number of arguments and object method calls</message>
  <tree>476307c36ecc874a137043959795eb5de63661fd</tree>
  <committer>
    <name>farleyknight</name>
    <email>farleyknight+github@gmail.com</email>
  </committer>
</commit>
