Commit for Art Yerkes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6215 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b33b6ab081
commit
74d75c27e8
2 changed files with 40 additions and 10 deletions
|
|
@ -216,10 +216,12 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
|
|||
/* %typemap(how) char * ... */
|
||||
$1 = ($ltype)caml_string_val($input);
|
||||
}
|
||||
/* Again work around the empty array bound bug */
|
||||
%typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] {
|
||||
/* %typemap(how) char [ANY] ... */
|
||||
char *temp = caml_string_val($input);
|
||||
strncpy((char *)$1,temp,$1_dim0);
|
||||
strcpy((char *)$1,temp);
|
||||
/* strncpy would be better but we might not have an array size */
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
|
@ -233,10 +235,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
|
|||
const char *, const signed char *, const unsigned char * {
|
||||
$result = caml_val_string((char *)$1);
|
||||
}
|
||||
/* I'd like to use the length here but can't because it might be empty */
|
||||
%typemap(how)
|
||||
char [ANY], signed char [ANY], unsigned char [ANY],
|
||||
const char [ANY], const signed char [ANY], const unsigned char [ANY] {
|
||||
$result = caml_val_string_len((char *)$1,(int)$1_size);
|
||||
$result = caml_val_string((char *)$1);
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -1076,6 +1076,12 @@ public:
|
|||
strchr(ch,')') || strchr(ch,'>'));
|
||||
}
|
||||
|
||||
/* We accept all chars in identifiers because we use strings to index
|
||||
* them. */
|
||||
int validIdentifier( String *name ) {
|
||||
return Len(name) > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
/* classHandler
|
||||
*
|
||||
* Create a "class" definition for ocaml. I thought quite a bit about
|
||||
|
|
@ -1358,19 +1364,38 @@ public:
|
|||
* which means looking up and registering by typedef and enum name. */
|
||||
int enumDeclaration(Node *n) {
|
||||
String *name = Getattr(n,"name");
|
||||
String *fully_qualified_name = fully_qualify_enum_name(n,name);
|
||||
String *oname = name ? NewString(name) : NULL;
|
||||
/* name is now fully qualified */
|
||||
String *fully_qualified_name = NewString(name);
|
||||
bool seen_enum = false;
|
||||
if( name_qualifier )
|
||||
Delete(name_qualifier);
|
||||
char *strip_position;
|
||||
name_qualifier = fully_qualify_enum_name(n,NewString(""));
|
||||
|
||||
seen_enum = name ?
|
||||
/* Recent changes have distrubed enum and template naming again.
|
||||
* Will try to keep it consistent by can't guarantee much given
|
||||
* that these things move around a lot.
|
||||
*
|
||||
* I need to figure out a way to isolate this module better.
|
||||
*/
|
||||
if( oname ) {
|
||||
strip_position = strstr(Char(oname),"::");
|
||||
|
||||
while( strip_position ) {
|
||||
strip_position += 2;
|
||||
oname = NewString( strip_position );
|
||||
strip_position = strstr( Char(oname), "::" );
|
||||
}
|
||||
}
|
||||
|
||||
seen_enum = oname ?
|
||||
(Getattr(seen_enums,fully_qualified_name) ? true : false) : false;
|
||||
|
||||
if( name && !seen_enum ) {
|
||||
if( oname && !seen_enum ) {
|
||||
const_enum = true;
|
||||
Printf( f_enum_to_int, "| `%s -> (match (y : c_enum_tag) with\n", name );
|
||||
Printf( f_int_to_enum, "| `%s -> C_enum (\n", name );
|
||||
Printf( f_enum_to_int, "| `%s -> (match (y : c_enum_tag) with\n", oname );
|
||||
Printf( f_int_to_enum, "| `%s -> C_enum (\n", oname );
|
||||
/* * * * A note about enum name resolution * * * *
|
||||
* This code should now work, but I think we can do a bit better.
|
||||
* The problem I'm having is that swig isn't very precise about
|
||||
|
|
@ -1382,15 +1407,17 @@ public:
|
|||
* * * */
|
||||
Printf( f_mlbody,
|
||||
"let _ = Callback.register \"%s_marker\" (`%s)\n",
|
||||
fully_qualified_name, name );
|
||||
fully_qualified_name, oname );
|
||||
if( !strncmp(Char(fully_qualified_name),"enum ",5) ) {
|
||||
String *fq_noenum = NewString(Char(fully_qualified_name) + 5);
|
||||
Printf( f_mlbody,
|
||||
"let _ = Callback.register \"%s_marker\" (`%s)\n"
|
||||
"let _ = Callback.register \"%s_marker\" (`%s)\n",
|
||||
fq_noenum, oname,
|
||||
fq_noenum, name );
|
||||
}
|
||||
|
||||
Printf( f_enumtypes_type,"| `%s\n", name );
|
||||
Printf( f_enumtypes_type,"| `%s\n", oname );
|
||||
Insert(fully_qualified_name,0,"enum ");
|
||||
Setattr(seen_enums,fully_qualified_name,n);
|
||||
}
|
||||
|
|
@ -1398,7 +1425,7 @@ public:
|
|||
int ret = Language::enumDeclaration(n);
|
||||
|
||||
if( const_enum ) {
|
||||
Printf( f_int_to_enum, "`int y)\n", name );
|
||||
Printf( f_int_to_enum, "`int y)\n" );
|
||||
Printf( f_enum_to_int,
|
||||
"| `int (x : int) -> C_int x\n"
|
||||
"| _ -> raise (Failure \"Unknown enum tag\"))\n" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue