示例#1
0
/**
 * Installs the Libstr library in the given instance of Gunderscript.
 * gunderscript: the instance to receive the library.
 * returns: true upon success, and false upon failure. If failure occurs,
 * you probably did not allocate enough callbacks space in the call to 
 * gunderscript_new().
 */
bool libstr_install(Gunderscript * gunderscript) {
  if(!vm_reg_callback(gunderscript_vm(gunderscript), 
		      "string_equals", 13, vmn_str_equals)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
		      "string", 6, vmn_str)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
		      "string_length", 13, vmn_str_length)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
		      "string_prealloc", 15, vmn_str_prealloc)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "string_append", 13, vmn_str_append)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "string_char_at", 14, vmn_str_char_at)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "char_to_string", 14, vmn_char_to_str)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "string_set_char_at", 18, vmn_str_set_char_at)
) {
    return false;
  }
  return true;
}
示例#2
0
/**
 * Installs the Libmath library in the given instance of Gunderscript.
 * gunderscript: the instance to receive the library.
 * returns: true upon success, and false upon failure. If failure occurs,
 * you probably did not allocate enough callbacks space in the call to 
 * gunderscript_new().
 */
bool libmath_install(Gunderscript * gunderscript) {

  if(!vm_reg_callback(gunderscript_vm(gunderscript), 
		      "math_abs", 8, vmn_math_abs)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_sqrt", 9, vmn_math_sqrt)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_pow", 8, vmn_math_pow)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_round", 10, vmn_math_round)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_sin", 8, vmn_math_sin)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_cos", 8, vmn_math_cos)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_tan", 8, vmn_math_tan)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_asin", 9, vmn_math_asin)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_acos", 9, vmn_math_acos)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_atan", 9, vmn_math_atan)
     || !vm_reg_callback(gunderscript_vm(gunderscript), 
			 "math_atan2", 10, vmn_math_atan2)) {
    return false;
  }
  return true;
}