Hello, I attached a hand-written orc binding. You can use it, if you know a little bit about orc.
About orc: http://code.entropywave.com/git/orc.git http://code.entropywave.com/projects/orc/ http://www.schleef.org/orc/documentation/ Greetings fabian
using Orc;
const int N = 10;
int16[] a;
int16[] b;
int16[] c;
void main(string[] args)
{
Orc.init();
a = new int16[ N ];
b = new int16[ N ];
c = new int16[ N ];
for( int16 i = 0 ; i < N ; i++ )
{
a[i] = i+1;
b[i] = 100;
}
add_s16(c, a, b);
for( int i = 0 ; i < N ; i++ )
{
message("%d: %d %d -> %d\n", i, a[i], b[i], c[i]);
}
}
void add_s16(int16[] dst, int16[] src1, int16[] src2)
{
Program p = new Program.dss(2,2,2);
p.append_str("addw", "d1", "s1", "s2");
CompileResult r = p.compile();
debug("CompileResult: %d", r);
assert( r == CompileResult.OK );
Executor e = new Executor(p);
e.set_program(p);
e.set_n( dst.length );
e.set_array_str("s1", src1);
e.set_array_str("s2", src2);
e.set_array_str("d1", dst);
e.run();
}
[CCode (lower_case_cprefix = "orc_", cheader_filename = "orc/orc.h")]
namespace Orc
{
/* [Compact]
[SimpleType]
[CCode (cname = "uuid_t")]
public struct UUID {
[CCode (cname="uuid_generate_random", instance_pos = 0)]
public UUID.generate_random();
public void unparse(out string str);
}*/
[CCode (cname = "orc_init")]
public void init();
[CCode (cname = "OrcProgram", unref_function = "orc_program_free")]
public class Program
{
[CCode (cname = "orc_program_new")]
public Program();
public Program.dss(int size1, int size2, int size3);
public unowned string get_name();
public void add_temporary(int size, owned string name);
public void add_source(int size, owned string name);
public void add_destination(int size, owned string name);
public void add_constant(int size, owned string name);
public void add_accumulator(int size, owned string name);
public void add_parameter(int size, owned string name);
public void append(string opcode, int arg0, int arg1, int arg2);
public void append_str(string opcode, string arg0, string arg1, string arg2);
public void append_ds(string opcode, int arg0, int arg1);
public void append_ds_str(string opcode, string arg0, string arg1);
public CompileResult compile();
public int find_var_by_name(string name);
}
/* OrcCompiler */
public class Compiler
{
}
public enum CompileResult
{
OK = 0,
UNKNOWN_COMPILE = 0x100,
MISSING_RULE = 0x101,
UNKNOWN_PARSE = 0x200,
PARSE = 0x201,
VARIABLE = 0x202
}
/* OrcExecutor */
[CCode (cname = "OrcExecutor", unref_function = "orc_executor_free")]
public class Executor
{
[CCode (cname = "orc_executor_new")]
public Executor(Program p);
public void set_array(int _var, void* ptr);
public void set_array_str(string _var, void* ptr);
public void set_n(int n);
public void emulate();
public void run();
public int get_accumulator(int n);
public int get_accumulator_str(string name);
public int set_param(int n, int val);
public int set_param_str(string name, int val);
public void set_program(Program p);
}
}
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
