Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.0 - Français

Change language to:
English - 日本語 - Português

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Manuel Scilab >> API Scilab > Scilab Gateway API > OverLoad

OverLoad

C gateway function which tells Scilab to look for another overloaded function

Calling Sequence

OverLoad(StackPos)

Arguments

StackPos

the position in the Scilab memory of the parameter for which we want to take into account for the overloading process (input argument)

Description

A C gateway function which tells Scilab to look for another overloaded function. Scilab then appends to the name of the function a prefix (like %sp_ if the parameter taken into account is sparse) and look for the overloaded function. You must include stack-c.h to benefit from this function.

Be careful with the Scilab name of the function. Indeed, the current overloading process of Scilab works only on Scilab primitives (Scilab function wrote in C) which must have a Scilab name which is maximum 8 char wide.

WARNING: This API is deprecated from Scilab 5.2.0 and is going to be removed with Scilab 6.0. Please use API Scilab (the new Scilab API).

Examples

In this example, the C interface function takes one input parameters and prints the integer corresponding to the type of the variable sent as parameter in the Scilab console.

#include <stack-c.h>
#include <sciprint.h>

int sci_check_properties_2(char * fname)
{
  int m1,n1,l1;

  CheckRhs(1,1);
  CheckLhs(0,1) ;

  switch(VarType(1)) 
    {
    case sci_matrix: 
      GetRhsVar(1, "d", &m1, &n1, &l1);
      sciprint("1 is a scalar matrix\n");
      break;
    case sci_strings:
      GetRhsVar(1, "c", &m1, &n1, &l1);
      sciprint("1 is a string\n");
      break;
    case sci_sparse:
      sciprint("1 is a sparse trying to overload\n");
      OverLoad(1);
    }

  LhsVar(1) = 0;

  return 0;
}
 </programlisting>

    <para>The builder.sce script look like this:</para>

    <programlisting role = "example"><![CDATA[  
// This is the builder.sce 
// must be run from this directory 

lines(0);

ilib_name  = 'lib_check_properties';

files = ['check_properties.c'];

libs  = [];

table =['chprop2', 'sci_check_properties_2'];

// We must be careful when we choose a scilab function name in case of overloading.
// We Scilab name function must be 8 char max.

ldflags = "";
cflags  = "";
fflags  = "";

ilib_build(ilib_name,table,files,libs,'Makelib',ldflags,cflags,fflags);

And now, an example of use of this new function:

chprop2([1,2,2]);
chprop2('foo');

// overload case 

deff('[]=%sp_chprop2(sp)','disp(''sparse overloaded'')');
chprop2(sparse([1,2,3]));
<< NumOpt Scilab Gateway API Rhs >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jan 26 16:24:17 CET 2011