Use 'MRB_FUNCTION' instead of 'MRB_METHOD' for modules
This commit is contained in:
		
							parent
							
								
									121df799ab
								
							
						
					
					
						commit
						d151986c72
					
				
					 9 changed files with 61 additions and 131 deletions
				
			
		| 
						 | 
				
			
			@ -156,10 +156,8 @@ findLastDot(char *str)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* File class methods */
 | 
			
		||||
MRB_METHOD(fileBasename)
 | 
			
		||||
MRB_FUNCTION(fileBasename)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value filename;
 | 
			
		||||
	const char *suffix = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -186,10 +184,8 @@ MRB_METHOD(fileBasename)
 | 
			
		|||
	return str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileDelete)
 | 
			
		||||
MRB_FUNCTION(fileDelete)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_int argc;
 | 
			
		||||
	mrb_value *argv;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -209,10 +205,8 @@ MRB_METHOD(fileDelete)
 | 
			
		|||
	return mrb_nil_value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileDirname)
 | 
			
		||||
MRB_FUNCTION(fileDirname)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value filename;
 | 
			
		||||
	mrb_get_args(mrb, "S", &filename);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -222,10 +216,8 @@ MRB_METHOD(fileDirname)
 | 
			
		|||
	return mrb_str_new_cstr(mrb, dir);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileExpandPath)
 | 
			
		||||
MRB_FUNCTION(fileExpandPath)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	const char *path;
 | 
			
		||||
	const char *defDir = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -242,10 +234,8 @@ MRB_METHOD(fileExpandPath)
 | 
			
		|||
	return mrb_str_new_cstr(mrb, buffer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileExtname)
 | 
			
		||||
MRB_FUNCTION(fileExtname)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value filename;
 | 
			
		||||
	mrb_get_args(mrb, "S", &filename);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -254,10 +244,8 @@ MRB_METHOD(fileExtname)
 | 
			
		|||
	return mrb_str_new_cstr(mrb, ext);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileOpen)
 | 
			
		||||
MRB_FUNCTION(fileOpen)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value path;
 | 
			
		||||
	const char *mode = "r";
 | 
			
		||||
	mrb_value block = mrb_nil_value();
 | 
			
		||||
| 
						 | 
				
			
			@ -294,10 +282,8 @@ MRB_METHOD(fileOpen)
 | 
			
		|||
	return obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileRename)
 | 
			
		||||
MRB_FUNCTION(fileRename)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	const char *from, *to;
 | 
			
		||||
	mrb_get_args(mrb, "zz", &from, &to);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -307,11 +293,11 @@ MRB_METHOD(fileRename)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(mrbNoop)
 | 
			
		||||
MRB_FUNCTION(mrbNoop)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
	MRB_FUN_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	return self;
 | 
			
		||||
	return mrb_nil_value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* File instance methods */
 | 
			
		||||
| 
						 | 
				
			
			@ -540,10 +526,8 @@ MRB_METHOD(fileGetMtime)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* FileTest module functions */
 | 
			
		||||
MRB_METHOD(fileTestDoesExist)
 | 
			
		||||
MRB_FUNCTION(fileTestDoesExist)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	const char *filename;
 | 
			
		||||
	mrb_get_args(mrb, "z", &filename);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -552,30 +536,24 @@ MRB_METHOD(fileTestDoesExist)
 | 
			
		|||
	return mrb_bool_value(result == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileTestIsFile)
 | 
			
		||||
MRB_FUNCTION(fileTestIsFile)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	struct stat fileStat;
 | 
			
		||||
	getFileStat(mrb, fileStat);
 | 
			
		||||
 | 
			
		||||
	return mrb_bool_value(S_ISREG(fileStat.st_mode));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileTestIsDirectory)
 | 
			
		||||
MRB_FUNCTION(fileTestIsDirectory)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	struct stat fileStat;
 | 
			
		||||
	getFileStat(mrb, fileStat);
 | 
			
		||||
 | 
			
		||||
	return mrb_bool_value(S_ISDIR(fileStat.st_mode));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(fileTestSize)
 | 
			
		||||
MRB_FUNCTION(fileTestSize)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	struct stat fileStat;
 | 
			
		||||
	getFileStat(mrb, fileStat);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,10 +39,8 @@
 | 
			
		|||
 | 
			
		||||
void mrbBindingTerminate();
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelEval)
 | 
			
		||||
MRB_FUNCTION(kernelEval)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	const char *exp;
 | 
			
		||||
	mrb_int expLen;
 | 
			
		||||
	mrb_get_args(mrb, "s", &exp, &expLen);
 | 
			
		||||
| 
						 | 
				
			
			@ -74,19 +72,15 @@ static void printP(mrb_state *mrb,
 | 
			
		|||
	gState->eThread().showMessageBox(RSTRING_PTR(buffer), SDL_MESSAGEBOX_INFORMATION);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelP)
 | 
			
		||||
MRB_FUNCTION(kernelP)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	printP(mrb, "inspect", "\n");
 | 
			
		||||
 | 
			
		||||
	return mrb_nil_value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelPrint)
 | 
			
		||||
MRB_FUNCTION(kernelPrint)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	printP(mrb, "to_s", "");
 | 
			
		||||
 | 
			
		||||
	return mrb_nil_value();
 | 
			
		||||
| 
						 | 
				
			
			@ -108,10 +102,8 @@ srandCurrentTime(int *currentSeed)
 | 
			
		|||
	srand(*currentSeed);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelRand)
 | 
			
		||||
MRB_FUNCTION(kernelRand)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	if (!srandCalled)
 | 
			
		||||
	{
 | 
			
		||||
		srandCurrentTime(¤tSeed);
 | 
			
		||||
| 
						 | 
				
			
			@ -142,10 +134,8 @@ MRB_METHOD(kernelRand)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelSrand)
 | 
			
		||||
MRB_FUNCTION(kernelSrand)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	srandCalled = true;
 | 
			
		||||
 | 
			
		||||
	if (mrb->c->ci->argc == 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -168,19 +158,17 @@ MRB_METHOD(kernelSrand)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelExit)
 | 
			
		||||
MRB_FUNCTION(kernelExit)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
	MRB_FUN_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrbBindingTerminate();
 | 
			
		||||
 | 
			
		||||
	return mrb_nil_value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelLoadData)
 | 
			
		||||
MRB_FUNCTION(kernelLoadData)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	const char *filename;
 | 
			
		||||
	mrb_get_args(mrb, "z", &filename);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -200,10 +188,8 @@ MRB_METHOD(kernelLoadData)
 | 
			
		|||
	return obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelSaveData)
 | 
			
		||||
MRB_FUNCTION(kernelSaveData)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value obj;
 | 
			
		||||
	const char *filename;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -225,10 +211,8 @@ MRB_METHOD(kernelSaveData)
 | 
			
		|||
	return mrb_nil_value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(kernelInteger)
 | 
			
		||||
MRB_FUNCTION(kernelInteger)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value obj;
 | 
			
		||||
	mrb_get_args(mrb, "o", &obj);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -882,10 +882,8 @@ verifyMarshalHeader(MarshalContext *ctx)
 | 
			
		|||
		throw Exception(Exception::TypeError, "incompatible marshal file format (can't be read)");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(marshalDump)
 | 
			
		||||
MRB_FUNCTION(marshalDump)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value val;
 | 
			
		||||
	mrb_value port = mrb_nil_value();
 | 
			
		||||
	mrb_int limit = 100;
 | 
			
		||||
| 
						 | 
				
			
			@ -945,10 +943,8 @@ MRB_METHOD(marshalDump)
 | 
			
		|||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(marshalLoad)
 | 
			
		||||
MRB_FUNCTION(marshalLoad)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_value port;
 | 
			
		||||
 | 
			
		||||
	mrb_get_args(mrb, "o", &port);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,20 +53,16 @@ timeFromSecondsInt(mrb_state *mrb, time_t seconds)
 | 
			
		|||
	return obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(timeAt)
 | 
			
		||||
MRB_FUNCTION(timeAt)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	mrb_int seconds;
 | 
			
		||||
	mrb_get_args(mrb, "i", &seconds);
 | 
			
		||||
 | 
			
		||||
	return timeFromSecondsInt(mrb, seconds);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MRB_METHOD(timeNow)
 | 
			
		||||
MRB_FUNCTION(timeNow)
 | 
			
		||||
{
 | 
			
		||||
	MRB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	TimeImpl *p = new TimeImpl;
 | 
			
		||||
 | 
			
		||||
	gettimeofday(&p->_tv, 0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue