home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


Sauerbraten in a dll

by PlateWolf on 07/24/2006 01:50, 45 messages, last message: 03/24/2008 16:27, 15843 views, last view: 09/28/2024 20:20

Hi, I want to access Sauerbraten externally, did anyone managed to compile it in a dll ?
(Like SDL for example).

Go to first 20 messagesGo to previous 20 messages    Board Index   

#43: Re: ..

by MovingTarget on 03/21/2008 14:35, refers to #42

Uuuugh... I tried SWIG once, and I failed miserably. It kept complaining about supposed syntax errors in the C++ code, when it compiled fine. My experiences have not exactly been fun.

reply to this message

#44: ..

by scasd on 03/22/2008 18:22

So what about obscurant code - as far as I think OO should be possible with cube script. Look at the following example. It would still need member function call routines plus member value lookup - but this should be possible too. You have to create a stack like the member value stack done below which will be some effort... one or two days I think :o]

Cube script isnt sandboxed - the biggest problem but maybe it will be in the future - I still got some Segmentation Faults while hacking that stuff.



// create a fake class type or inherit a fake class
// usage: class [name] [parent] [parent]
// where one or two partens are optional
"class" = [
alias classtype $arg1;

// create the member-apply function for our new class
alias $classtype (
concatword "alias " $classtype .members " (concat $" $classtype .members " $arg1); alias (concatword " $classtype ". $arg1) $arg2" // set value "class.member"
);

// empty memberlist
alias (concatword $classtype .members) [];

// get stuff from our parental class
loop i 2 [
alias parentgetter (concatword "alias parent $arg" (+ (i) 2));
parentgetter;

if (> (listlen $parent) 0) [

alias membergetter (concatword "alias members $" $parent .members);
membergetter;
alias membercount (listlen $members);
//echo $members - $membercount;

// get parents members
loop i $membercount [
alias membername (at $members (i));
//echo "- copy member " $membername;
alias membercopy (concatword $classtype " " $membername " $" $parent . $membername);
membercopy;
];
];
];

// delete local data
alias membercopy []; alias membername []; alias membercount []; alias membergetter []; alias parent []; alias parentgetter [];

alias current.classtype $classtype; // remember this class
alias membercount []; alias members []; alias classtype [];
]



// append a member to the last created fake class
// usage: member [name] [value]
"member" = [
if (> (listlen $current.classtype) 0) [
current.classtype $arg1 $arg2;
]
]


// delete a fake class and its members
// usage: delete [name]
"delete" = [
alias classtype $arg1;
alias membergetter (concatword "alias members $" $classtype .members);
membergetter;
alias membercount (listlen $members);
//echo $members - $membercount;

// get members
alias (concatword $classtype .members) [];
loop i $membercount [
alias membername (at $members (i));
//echo "- delete member " $membername;
alias memberdelete (concatword "alias " $classtype . $membername " []");
memberdelete;
];

if (= $current.classtype $classtype) [
alias current.classtype [];
];

alias $classtype [];

alias memberdelete []; alias membername []; alias membercount []; alias membergetter []; alias classtype [];
];



echo test...

class vec2;
vec2 x 12; // default values
vec2 y 34;
echo $vec2.members - $vec2.x - $vec2.y;

class vec3 vec2;
member z 56;
echo $vec3.members - $vec3.x - $vec3.y - $vec3.z;

vec2.x = 78; // the order is important - changes after "inheritance" doesnt affect the inherited classes !!!
echo "vec2 again:" $vec2.members - $vec2.x - $vec2.y;

class pos vec3;
echo $pos.members - $pos.x - $pos.y - $pos.z;

delete vec3; // pos is still working...
echo $vec3.members - $vec3.x - $vec3.y - $vec3.z;

class color;
member r 1;
member g 2;
member b 3;
echo $color.members - $color.r - $color.g - $color.b;

class pixel color vec2; // more than 2 base classes would need a dummy...
echo $pixel.members;

reply to this message

#45: Re: ..

by yoopers on 03/24/2008 16:27, refers to #43

SWIG doesn't like nested structs, classes, and unions, which explains many of the syntax errors. It's also quite picky about how arguments are passed.

But good news, everyone! There are ways around these issues, it just takes more time to create the interface. The downside is that the interface becomes more tightly coupled with the code, but that's been my experience with SWIG in general.

reply to this message

Go to first 20 messagesGo to previous 20 messages    Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
56731205 visitors requested 74643737 pages
page created in 0.055 seconds using 10 queries
hosted by Boost Digital