Browse Source

renamed hl.hdll to std.hdll, added some missing HL_PRIM

Nicolas Cannasse 9 years ago
parent
commit
f202ac4005
13 changed files with 88 additions and 91 deletions
  1. 2 6
      .gitignore
  2. 4 4
      hl.vcxproj
  3. 4 4
      hldll.vcxproj
  4. 4 4
      libs/sdl/sdl.vcxproj
  5. 1 0
      src/hl.h
  6. 8 8
      src/std/buffer.c
  7. 7 7
      src/std/cast.c
  8. 6 6
      src/std/error.c
  9. 12 12
      src/std/file.c
  10. 5 5
      src/std/fun.c
  11. 1 1
      src/std/math.c
  12. 13 13
      src/std/obj.c
  13. 21 21
      src/std/socket.c

+ 2 - 6
.gitignore

@@ -13,13 +13,9 @@ Release
 x64
 *.stackdump
 *.hdll
-/src/_main.c
+/src/_main*
 *.o
-/src/_main2.c
-/src/_main3.c
-/src/_main4.c
-/src/_main5.c
-/src/_main6.c
 *.a
 *.opendb
+*.VC.db
 /include/sdl

+ 4 - 4
hl.vcxproj

@@ -97,7 +97,7 @@
     <Link>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>hl.lib;sdl.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;sdl.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -111,7 +111,7 @@
     <Link>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>hl.lib;sdl.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;sdl.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -130,7 +130,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>hl.lib;sdl.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;sdl.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -148,7 +148,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>hl.lib;sdl.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;sdl.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>

+ 4 - 4
hldll.vcxproj

@@ -72,25 +72,25 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include/pcre;src</IncludePath>
-    <TargetName>hl</TargetName>
+    <TargetName>std</TargetName>
     <TargetExt>.hdll</TargetExt>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include/pcre;src</IncludePath>
-    <TargetName>hl</TargetName>
+    <TargetName>std</TargetName>
     <TargetExt>.hdll</TargetExt>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
     <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include/pcre;src</IncludePath>
-    <TargetName>hl</TargetName>
+    <TargetName>std</TargetName>
     <TargetExt>.hdll</TargetExt>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <LinkIncremental>false</LinkIncremental>
     <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include/pcre;src</IncludePath>
-    <TargetName>hl</TargetName>
+    <TargetName>std</TargetName>
     <TargetExt>.hdll</TargetExt>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+ 4 - 4
libs/sdl/sdl.vcxproj

@@ -105,7 +105,7 @@
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <OutputFile>../../$(Configuration)/$(TargetName).hdll</OutputFile>
-      <AdditionalDependencies>hl.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -119,7 +119,7 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>hl.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -138,7 +138,7 @@
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <OutputFile>../../$(Configuration)/$(TargetName).hdll</OutputFile>
-      <AdditionalDependencies>hl.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -156,7 +156,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>hl.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
+      <AdditionalDependencies>std.lib;winmm.lib;SDL2.lib;opengl32.lib;user32.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>

+ 1 - 0
src/hl.h

@@ -513,6 +513,7 @@ HL_API const uchar *hl_type_str( hl_type *t );
 #define _STRING						_OBJ(_BYTES _I32)
 
 typedef struct {
+	hl_type *t;
 	uchar *bytes;
 	int length;
 } vstring;

+ 8 - 8
src/std/buffer.c

@@ -34,7 +34,7 @@ struct hl_buffer {
 	stringitem data;
 };
 
-hl_buffer *hl_alloc_buffer() {
+HL_PRIM hl_buffer *hl_alloc_buffer() {
 	hl_buffer *b = (hl_buffer*)hl_gc_alloc(sizeof(hl_buffer));
 	b->totlen = 0;
 	b->blen = 16;
@@ -57,7 +57,7 @@ static void buffer_append_new( hl_buffer *b, const uchar *s, int len ) {
 	b->data = it;
 }
 
-void hl_buffer_str_sub( hl_buffer *b, const uchar *s, int len ) {
+HL_PRIM void hl_buffer_str_sub( hl_buffer *b, const uchar *s, int len ) {
 	stringitem it;
 	if( s == NULL || len <= 0 )
 		return;
@@ -79,11 +79,11 @@ void hl_buffer_str_sub( hl_buffer *b, const uchar *s, int len ) {
 	buffer_append_new(b,s,len);
 }
 
-void hl_buffer_str( hl_buffer *b, const uchar *s ) {
+HL_PRIM void hl_buffer_str( hl_buffer *b, const uchar *s ) {
 	if( s ) hl_buffer_str_sub(b,s,(int)ustrlen(s)); else hl_buffer_str_sub(b,USTR("NULL"),4);
 }
 
-void hl_buffer_cstr( hl_buffer *b, const char *s ) {
+HL_PRIM void hl_buffer_cstr( hl_buffer *b, const char *s ) {
 	if( s ) {
 		int len = (int)strlen(s);
 		uchar *out = (uchar*)malloc(sizeof(uchar)*(len+1));
@@ -93,7 +93,7 @@ void hl_buffer_cstr( hl_buffer *b, const char *s ) {
 	} else hl_buffer_str_sub(b,USTR("NULL"),4);
 }
 
-void hl_buffer_char( hl_buffer *b, uchar c ) {
+HL_PRIM void hl_buffer_char( hl_buffer *b, uchar c ) {
 	stringitem it;
 	b->totlen++;
 	it = b->data;
@@ -104,7 +104,7 @@ void hl_buffer_char( hl_buffer *b, uchar c ) {
 	buffer_append_new(b,(uchar*)&c,1);
 }
 
-uchar *hl_buffer_content( hl_buffer *b, int *len ) {
+HL_PRIM uchar *hl_buffer_content( hl_buffer *b, int *len ) {
 	uchar *buf = (uchar*)hl_gc_alloc_noptr((b->totlen+1)<<1);
 	stringitem it = b->data;
 	uchar *s = ((uchar*)buf) + b->totlen;
@@ -362,11 +362,11 @@ static void hl_buffer_rec( hl_buffer *b, vdynamic *v, vlist *stack ) {
 	}
 }
 
-void hl_buffer_val( hl_buffer *b, vdynamic *v ) {
+HL_PRIM void hl_buffer_val( hl_buffer *b, vdynamic *v ) {
 	hl_buffer_rec(b,v,NULL);
 }
 
-uchar *hl_to_string( vdynamic *v ) {
+HL_PRIM uchar *hl_to_string( vdynamic *v ) {
 	hl_buffer *b = hl_alloc_buffer();
 	hl_buffer_val(b,v);
 	hl_buffer_char(b,0);

+ 7 - 7
src/std/cast.c

@@ -23,7 +23,7 @@
 
 #define TK2(a,b)		((a) | ((b)<<5))
 
-vdynamic *hl_make_dyn( void *data, hl_type *t ) {
+HL_PRIM vdynamic *hl_make_dyn( void *data, hl_type *t ) {
 	vdynamic *v;
 	switch( t->kind ) {
 	case HI8:
@@ -75,7 +75,7 @@ vdynamic *hl_make_dyn( void *data, hl_type *t ) {
 }
 
 
-int hl_dyn_casti( void *data, hl_type *t, hl_type *to ) {
+HL_PRIM int hl_dyn_casti( void *data, hl_type *t, hl_type *to ) {
 	if( t->kind == HDYN ) {
 		vdynamic *v = *((vdynamic**)data);
 		if( v == NULL ) return 0;
@@ -108,7 +108,7 @@ int hl_dyn_casti( void *data, hl_type *t, hl_type *to ) {
 	return 0;
 }
 
-void *hl_dyn_castp( void *data, hl_type *t, hl_type *to ) {
+HL_PRIM void *hl_dyn_castp( void *data, hl_type *t, hl_type *to ) {
 	if( t->kind == HDYN || t->kind == HNULL ) {
 		vdynamic *v = *(vdynamic**)data;
 		if( v == NULL ) return NULL;
@@ -196,7 +196,7 @@ void *hl_dyn_castp( void *data, hl_type *t, hl_type *to ) {
 	return 0;
 }
 
-double hl_dyn_castd( void *data, hl_type *t ) {
+HL_PRIM double hl_dyn_castd( void *data, hl_type *t ) {
 	if( t->kind == HDYN ) {
 		vdynamic *v = *((vdynamic**)data);
 		if( v == NULL ) return 0;
@@ -228,7 +228,7 @@ double hl_dyn_castd( void *data, hl_type *t ) {
 	return 0.;
 }
 
-float hl_dyn_castf( void *data, hl_type *t ) {
+HL_PRIM float hl_dyn_castf( void *data, hl_type *t ) {
 	if( t->kind == HDYN ) {
 		vdynamic *v = *((vdynamic**)data);
 		if( v == NULL ) return 0;
@@ -274,7 +274,7 @@ static int dcompare( double a, double b ) {
  	return d == 0. ? 0 : (d > 0. ? 1 : -1);
 }
 
-int hl_dyn_compare( vdynamic *a, vdynamic *b ) {
+HL_PRIM int hl_dyn_compare( vdynamic *a, vdynamic *b ) {
 	if( a == b )
 		return 0;
 	if( a == NULL )
@@ -316,7 +316,7 @@ int hl_dyn_compare( vdynamic *a, vdynamic *b ) {
 	return hl_invalid_comparison;
 }
 
-void hl_write_dyn( void *data, hl_type *t, vdynamic *v ) {
+HL_PRIM void hl_write_dyn( void *data, hl_type *t, vdynamic *v ) {
 	switch( t->kind ) {
 	case HI8:
 	case HBOOL:

+ 6 - 6
src/std/error.c

@@ -26,7 +26,7 @@
 HL_PRIM hl_trap_ctx *hl_current_trap = NULL;
 HL_PRIM vdynamic *hl_current_exc = NULL;
 
-void *hl_fatal_error( const char *msg, const char *file, int line ) {
+HL_PRIM void *hl_fatal_error( const char *msg, const char *file, int line ) {
 	printf("%s(%d) : FATAL ERROR : %s\n",file,line,msg);
 #ifdef _DEBUG
 	*(int*)NULL = 0;
@@ -36,21 +36,21 @@ void *hl_fatal_error( const char *msg, const char *file, int line ) {
 	return NULL;
 }
 
-void hl_throw( vdynamic *v ) {
+HL_PRIM void hl_throw( vdynamic *v ) {
 	hl_trap_ctx *t = hl_current_trap;
 	hl_current_exc = v;
 	hl_current_trap = t->prev;
 #ifdef _DEBUG
-	if( hl_current_trap == NULL ) *(int*)NULL = 0; // Uncaught exception
+//	if( hl_current_trap == NULL ) *(int*)NULL = 0; // Uncaught exception
 #endif
 	longjmp(t->buf,1);
 }
 
-void hl_rethrow( vdynamic *v ) {
+HL_PRIM void hl_rethrow( vdynamic *v ) {
 	hl_throw(v);
 }
 
-void hl_error_msg( const uchar *fmt, ... ) {
+HL_PRIM void hl_error_msg( const uchar *fmt, ... ) {
 	uchar buf[256];
 	vdynamic *d;
 	int len;
@@ -63,7 +63,7 @@ void hl_error_msg( const uchar *fmt, ... ) {
 	hl_throw(d);
 }
 
-void hl_fatal_fmt(const char *fmt, ...) {
+HL_PRIM void hl_fatal_fmt(const char *fmt, ...) {
 	char buf[256];
 	va_list args;
 	va_start(args, fmt);

+ 12 - 12
src/std/file.c

@@ -37,7 +37,7 @@ static void fdesc_finalize( hl_fdesc *f ) {
 	if( f->f ) fclose(f->f);
 }
 
-hl_fdesc *hl_file_open( vbyte *name, int mode, bool binary ) {
+HL_PRIM hl_fdesc *hl_file_open( vbyte *name, int mode, bool binary ) {
 #	ifdef HL_UFOPEN
 	static const uchar *MODES[] = { USTR("r"), USTR("w"), USTR("a"), NULL, USTR("rb"), USTR("wb"), USTR("ab") };
 	FILE *f = fopen((uchar*)name,MODES[mode|(binary?4:0)]);
@@ -53,49 +53,49 @@ hl_fdesc *hl_file_open( vbyte *name, int mode, bool binary ) {
 	return fd;
 }
 
-void hl_file_close( hl_fdesc *f ) {	
+HL_PRIM void hl_file_close( hl_fdesc *f ) {
 	if( f->f ) fclose(f->f);
 	f->f = NULL;
 }
 
-int hl_file_write( hl_fdesc *f, vbyte *buf, int pos, int len ) {
+HL_PRIM int hl_file_write( hl_fdesc *f, vbyte *buf, int pos, int len ) {
 	return (int)fwrite(buf+pos,1,len,f->f);
 }
 
-int hl_file_read( hl_fdesc *f, vbyte *buf, int pos, int len ) {
+HL_PRIM int hl_file_read( hl_fdesc *f, vbyte *buf, int pos, int len ) {
 	return (int)fread((char*)buf+pos,1,len,f->f);
 }
 
-bool hl_file_write_char( hl_fdesc *f, int c ) {
+HL_PRIM bool hl_file_write_char( hl_fdesc *f, int c ) {
 	unsigned char cc = (unsigned char)c;
 	return fwrite(&cc,1,1,f->f) == 1;
 }
 
-int hl_file_read_char( hl_fdesc *f ) {
+HL_PRIM int hl_file_read_char( hl_fdesc *f ) {
 	unsigned char cc;
 	if( fread(&cc,1,1,f->f) != 1 )
 		return -2;
 	return cc;
 }
 
-bool hl_file_seek( hl_fdesc *f, int pos, int kind ) {
+HL_PRIM bool hl_file_seek( hl_fdesc *f, int pos, int kind ) {
 	return fseek(f->f,pos,kind) == 0;
 }
 
-int hl_file_tell( hl_fdesc *f ) {
+HL_PRIM int hl_file_tell( hl_fdesc *f ) {
 	return ftell(f->f);
 }
 
-bool hl_file_eof( hl_fdesc *f ) {
+HL_PRIM bool hl_file_eof( hl_fdesc *f ) {
 	return feof(f->f);
 }
 
-bool hl_file_flush( hl_fdesc *f ) {
+HL_PRIM bool hl_file_flush( hl_fdesc *f ) {
 	return fflush( f->f ) == 0;
 }
 
 #define MAKE_STDIO(k) \
-	hl_fdesc *hl_file_##k() { \
+	HL_PRIM hl_fdesc *hl_file_##k() { \
 		hl_fdesc *f; \
 		f = (hl_fdesc*)hl_gc_alloc_noptr(sizeof(hl_fdesc)); \
 		f->f = k; \
@@ -107,7 +107,7 @@ MAKE_STDIO(stdin);
 MAKE_STDIO(stdout);
 MAKE_STDIO(stderr);
 
-vbyte *hl_file_contents( vbyte *name, int *size ) {
+HL_PRIM vbyte *hl_file_contents( vbyte *name, int *size ) {
 	int len;
 	int p = 0;
 	vbyte *content;

+ 5 - 5
src/std/fun.c

@@ -21,7 +21,7 @@
  */
 #include <hl.h>
 
-vclosure *hl_alloc_closure_void( hl_type *t, void *fvalue ) {
+HL_PRIM vclosure *hl_alloc_closure_void( hl_type *t, void *fvalue ) {
 	vclosure *c = (vclosure*)hl_gc_alloc(sizeof(vclosure));
 	c->t = t;
 	c->fun = fvalue;
@@ -43,7 +43,7 @@ static hl_type *hl_get_closure_type( hl_type *t ) {
 	return (hl_type*)&ft->closure_type;
 }
 
-vclosure *hl_alloc_closure_ptr( hl_type *fullt, void *fvalue, void *v ) {
+HL_PRIM vclosure *hl_alloc_closure_ptr( hl_type *fullt, void *fvalue, void *v ) {
 	vclosure *c = (vclosure*)hl_gc_alloc(sizeof(vclosure));
 	c->t = hl_get_closure_type(fullt);
 	c->fun = fvalue;
@@ -67,7 +67,7 @@ HL_PRIM vdynamic* hl_get_closure_value( vdynamic *c ) {
 	return (vdynamic*)cl->value;
 }
 
-bool hl_fun_compare( vdynamic *a, vdynamic *b ) {
+HL_PRIM bool hl_fun_compare( vdynamic *a, vdynamic *b ) {
 	vclosure *ca, *cb;
 	if( a == b )
 		return true;
@@ -166,7 +166,7 @@ static void fun_var_args() {
 	hl_fatal("assert");
 }
 
-void *hl_wrapper_call( void *_c, void **args, vdynamic *ret ) {
+HL_PRIM void *hl_wrapper_call( void *_c, void **args, vdynamic *ret ) {
 	vclosure_wrapper *c = (vclosure_wrapper*)_c;
 	hl_type_fun *tfun = c->cl.t->fun;
 	union { double d; int i; float f; } tmp[HL_MAX_ARGS];
@@ -240,7 +240,7 @@ void *hl_wrapper_call( void *_c, void **args, vdynamic *ret ) {
 	return pret;
 }
 
-vclosure *hl_make_fun_wrapper( vclosure *v, hl_type *to ) {
+HL_PRIM vclosure *hl_make_fun_wrapper( vclosure *v, hl_type *to ) {
 	vclosure_wrapper *c;
 	void *wrap = hlc_get_wrapper(to);
 	if( wrap == NULL ) return NULL;

+ 1 - 1
src/std/math.c

@@ -27,7 +27,7 @@
     #define NAN (*(const float *) __nan)
 #endif
 
-double hl_nan() {
+HL_PRIM double hl_nan() {
 	return NAN;
 }
 

+ 13 - 13
src/std/obj.c

@@ -38,7 +38,7 @@ static void hl_lookup_insert( hl_field_lookup *l, int size, int hash, hl_type *t
 	l[pos].t = t;
 }
 
-hl_field_lookup *hl_lookup_find( hl_field_lookup *l, int size, int hash ) {
+HL_PRIM hl_field_lookup *hl_lookup_find( hl_field_lookup *l, int size, int hash ) {
 	int min = 0;
 	int max = size;
 	while( min < max ) {
@@ -74,11 +74,11 @@ static int hl_cache_count = 0;
 static int hl_cache_size = 0;
 static hl_field_lookup *hl_cache = NULL;
 
-int hl_hash( vbyte *b ) {
+HL_PRIM int hl_hash( vbyte *b ) {
 	return hl_hash_gen((uchar*)b,true);
 }
 
-int hl_hash_gen( const uchar *name, bool cache_name ) {
+HL_PRIM int hl_hash_gen( const uchar *name, bool cache_name ) {
 	int h = 0;
 	const uchar *oname = name;
 	while( *name ) {
@@ -104,12 +104,12 @@ int hl_hash_gen( const uchar *name, bool cache_name ) {
 	return h;
 }
 
-const uchar *hl_field_name( int hash ) {
+HL_PRIM const uchar *hl_field_name( int hash ) {
 	hl_field_lookup *l = hl_lookup_find(hl_cache, hl_cache_count, hash);
 	return l ? (uchar*)l->t : USTR("???");
 }
 
-void hl_cache_free() {
+HL_PRIM void hl_cache_free() {
 	int i;
 	for(i=0;i<hl_cache_count;i++)
 		free(hl_cache[i].t);
@@ -513,7 +513,7 @@ static vdynamic *hl_obj_lookup_extra( vdynamic *d, int hfield ) {
 	return NULL;
 }
 
-int hl_dyn_geti( vdynamic *d, int hfield, hl_type *t ) {
+HL_PRIM int hl_dyn_geti( vdynamic *d, int hfield, hl_type *t ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup(d,hfield,&ft);
 	if( !addr ) return 0;
@@ -535,21 +535,21 @@ int hl_dyn_geti( vdynamic *d, int hfield, hl_type *t ) {
 	}
 }
 
-float hl_dyn_getf( vdynamic *d, int hfield ) {
+HL_PRIM float hl_dyn_getf( vdynamic *d, int hfield ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup(d,hfield,&ft);
 	if( !addr ) return 0.;
 	return ft->kind == HF32 ? *(float*)addr : hl_dyn_castf(addr,ft);
 }
 
-double hl_dyn_getd( vdynamic *d, int hfield ) {
+HL_PRIM double hl_dyn_getd( vdynamic *d, int hfield ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup(d,hfield,&ft);
 	if( !addr ) return 0.;
 	return ft->kind == HF64 ? *(double*)addr : hl_dyn_castd(addr,ft);
 }
 
-void *hl_dyn_getp( vdynamic *d, int hfield, hl_type *t ) {
+HL_PRIM void *hl_dyn_getp( vdynamic *d, int hfield, hl_type *t ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup(d,hfield,&ft);
 	if( !addr ) {
@@ -601,7 +601,7 @@ static void *hl_obj_lookup_set( vdynamic *d, int hfield, hl_type *t, hl_type **f
 	return NULL;
 }
 
-void hl_dyn_seti( vdynamic *d, int hfield, hl_type *t, int value ) {
+HL_PRIM void hl_dyn_seti( vdynamic *d, int hfield, hl_type *t, int value ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup_set(d,hfield,t,&ft);
 	switch( ft->kind ) {
@@ -634,7 +634,7 @@ void hl_dyn_seti( vdynamic *d, int hfield, hl_type *t, int value ) {
 	}
 }
 
-void hl_dyn_setf( vdynamic *d, int hfield, float value ) {
+HL_PRIM void hl_dyn_setf( vdynamic *d, int hfield, float value ) {
 	hl_type *t;
 	void *addr = hl_obj_lookup_set(d,hfield,&hlt_f32,&t);
 	if( t->kind == HF32 )
@@ -647,7 +647,7 @@ void hl_dyn_setf( vdynamic *d, int hfield, float value ) {
 	}
 }
 
-void hl_dyn_setd( vdynamic *d, int hfield, double value ) {
+HL_PRIM void hl_dyn_setd( vdynamic *d, int hfield, double value ) {
 	hl_type *t;
 	void *addr = hl_obj_lookup_set(d,hfield,&hlt_f64,&t);
 	if( t->kind == HF64 )
@@ -660,7 +660,7 @@ void hl_dyn_setd( vdynamic *d, int hfield, double value ) {
 	}
 }
 
-void hl_dyn_setp( vdynamic *d, int hfield, hl_type *t, void *value ) {
+HL_PRIM void hl_dyn_setp( vdynamic *d, int hfield, hl_type *t, void *value ) {
 	hl_type *ft;
 	void *addr = hl_obj_lookup_set(d,hfield,t,&ft);
 	if( hl_same_type(t,ft) || value == NULL )

+ 21 - 21
src/std/socket.c

@@ -79,7 +79,7 @@ static int block_error() {
 	return -2;
 }
 
-void hl_socket_init() {
+HL_PRIM void hl_socket_init() {
 #ifdef HL_WIN
 	if( !init_done ) {
 		WSAStartup(MAKEWORD(2,0),&init_data);
@@ -88,7 +88,7 @@ void hl_socket_init() {
 #endif
 }
 
-hl_socket *hl_socket_new( bool udp ) {
+HL_PRIM hl_socket *hl_socket_new( bool udp ) {
 	SOCKET s;
 	if( udp )
 		s = socket(AF_INET,SOCK_DGRAM,0);
@@ -113,12 +113,12 @@ hl_socket *hl_socket_new( bool udp ) {
 	}
 }
 
-void hl_socket_close( hl_socket *s ) {
+HL_PRIM void hl_socket_close( hl_socket *s ) {
 	closesocket(s->sock);
 	s->sock = INVALID_SOCKET;
 }
 
-int hl_socket_send_char( hl_socket *s, int c ) {
+HL_PRIM int hl_socket_send_char( hl_socket *s, int c ) {
 	unsigned char cc;
 	cc = (unsigned char)c;
 	if( send(s->sock,&cc,1,MSG_NOSIGNAL) == SOCKET_ERROR )
@@ -126,7 +126,7 @@ int hl_socket_send_char( hl_socket *s, int c ) {
 	return 1;
 }
 
-int hl_socket_send( hl_socket *s, vbyte *buf, int pos, int len ) {
+HL_PRIM int hl_socket_send( hl_socket *s, vbyte *buf, int pos, int len ) {
 	int r = send(s->sock, (char*)buf + pos, len, MSG_NOSIGNAL);
 	if( len == SOCKET_ERROR )
 		return block_error();
@@ -134,14 +134,14 @@ int hl_socket_send( hl_socket *s, vbyte *buf, int pos, int len ) {
 }
 
 
-int hl_socket_recv( hl_socket *s, vbyte *buf, int pos, int len ) {
+HL_PRIM int hl_socket_recv( hl_socket *s, vbyte *buf, int pos, int len ) {
 	int	ret = recv(s->sock, (char*)buf + pos, len, MSG_NOSIGNAL);
 	if( ret == SOCKET_ERROR )
 		return block_error();
 	return ret;
 }
 
-int hl_socket_recv_char( hl_socket *s ) {
+HL_PRIM int hl_socket_recv_char( hl_socket *s ) {
 	unsigned char cc;
 	int ret = recv(s->sock,&cc,1,MSG_NOSIGNAL);
 	if( ret == SOCKET_ERROR || ret == 0 )
@@ -149,7 +149,7 @@ int hl_socket_recv_char( hl_socket *s ) {
 	return cc;
 }
 
-int hl_host_resolve( vbyte *host ) {
+HL_PRIM int hl_host_resolve( vbyte *host ) {
 	unsigned int ip;
 	ip = inet_addr((char*)host);
 	if( ip == INADDR_NONE ) {
@@ -169,13 +169,13 @@ int hl_host_resolve( vbyte *host ) {
 	return ip;
 }
 
-vbyte *hl_host_to_string( int ip ) {
+HL_PRIM vbyte *hl_host_to_string( int ip ) {
 	struct in_addr i;
 	*(int*)&i = ip;
 	return (vbyte*)inet_ntoa(i);
 }
 
-vbyte *hl_host_reverse( int ip ) {
+HL_PRIM vbyte *hl_host_reverse( int ip ) {
 	struct hostent *h;
 #	if defined(HL_WIN) || defined(HL_MAC)
 	h = gethostbyaddr((char *)&ip,4,AF_INET);
@@ -190,14 +190,14 @@ vbyte *hl_host_reverse( int ip ) {
 	return (vbyte*)h->h_name;
 }
 
-vbyte *hl_host_local() {
+HL_PRIM vbyte *hl_host_local() {
 	char buf[256];
 	if( gethostname(buf,256) == SOCKET_ERROR )
 		return NULL;
 	return hl_copy_bytes((vbyte*)buf,(int)strlen(buf)+1);
 }
 
-bool hl_socket_connect( hl_socket *s, int host, int port ) {
+HL_PRIM bool hl_socket_connect( hl_socket *s, int host, int port ) {
 	struct sockaddr_in addr;
 	memset(&addr,0,sizeof(addr));
 	addr.sin_family = AF_INET;
@@ -211,11 +211,11 @@ bool hl_socket_connect( hl_socket *s, int host, int port ) {
 	return true;
 }
 
-bool hl_socket_listen( hl_socket *s, int n ) {
+HL_PRIM bool hl_socket_listen( hl_socket *s, int n ) {
 	return listen(s->sock,n) != SOCKET_ERROR;
 }
 
-bool hl_socket_bind( hl_socket *s, int host, int port ) {
+HL_PRIM bool hl_socket_bind( hl_socket *s, int host, int port ) {
 	int opt = 1;
 	struct sockaddr_in addr;
 	memset(&addr,0,sizeof(addr));
@@ -228,7 +228,7 @@ bool hl_socket_bind( hl_socket *s, int host, int port ) {
 	return bind(s->sock,(struct sockaddr*)&addr,sizeof(addr)) != SOCKET_ERROR;
 }
 
-hl_socket *hl_socket_accept( hl_socket *s ) {
+HL_PRIM hl_socket *hl_socket_accept( hl_socket *s ) {
 	struct sockaddr_in addr;
 	unsigned int addrlen = sizeof(addr);
 	SOCKET nsock;
@@ -241,7 +241,7 @@ hl_socket *hl_socket_accept( hl_socket *s ) {
 	return hs;
 }
 
-bool hl_socket_peer( hl_socket *s, int *host, int *port ) {
+HL_PRIM bool hl_socket_peer( hl_socket *s, int *host, int *port ) {
 	struct sockaddr_in addr;
 	unsigned int addrlen = sizeof(addr);
 	if( getpeername(s->sock,(struct sockaddr*)&addr,&addrlen) == SOCKET_ERROR )
@@ -251,7 +251,7 @@ bool hl_socket_peer( hl_socket *s, int *host, int *port ) {
 	return true;
 }
 
-bool hl_socket_host( hl_socket *s, int *host, int *port ) {
+HL_PRIM bool hl_socket_host( hl_socket *s, int *host, int *port ) {
 	struct sockaddr_in addr;
 	unsigned int addrlen = sizeof(addr);
 	if( getsockname(s->sock,(struct sockaddr*)&addr,&addrlen) == SOCKET_ERROR )
@@ -261,7 +261,7 @@ bool hl_socket_host( hl_socket *s, int *host, int *port ) {
 	return true;
 }
 
-bool hl_socket_set_timeout( hl_socket *s, double t ) {
+HL_PRIM bool hl_socket_set_timeout( hl_socket *s, double t ) {
 #ifdef HL_WIN
 	int time = (int)(t * 1000);
 #else
@@ -275,13 +275,13 @@ bool hl_socket_set_timeout( hl_socket *s, double t ) {
 	return true;
 }
 
-bool hl_socket_shutdown( hl_socket *s, bool r, bool w ) {
+HL_PRIM bool hl_socket_shutdown( hl_socket *s, bool r, bool w ) {
 	if( !r && !w )
 		return true;
 	return shutdown(s->sock,r?(w?SHUT_RDWR:SHUT_RD):SHUT_WR) == 0;
 }
 
-bool hl_socket_set_blocking( hl_socket *s, bool b ) {
+HL_PRIM bool hl_socket_set_blocking( hl_socket *s, bool b ) {
 #ifdef HL_WIN
 	unsigned long arg = b?0:1;
 	return ioctlsocket(s->sock,FIONBIO,&arg) == 0;
@@ -297,7 +297,7 @@ bool hl_socket_set_blocking( hl_socket *s, bool b ) {
 #endif
 }
 
-bool hl_socket_set_fast_send( hl_socket *s, bool b ) {
+HL_PRIM bool hl_socket_set_fast_send( hl_socket *s, bool b ) {
 	int fast = b;
 	return setsockopt(s->sock,IPPROTO_TCP,TCP_NODELAY,(char*)&fast,sizeof(fast)) == 0;
 }