Преглед на файлове

Added WParam and LParam types for Win32.

woollybah преди 9 години
родител
ревизия
75aca1cfe8
променени са 7 файла, в които са добавени 420 реда и са изтрити 43 реда
  1. 74 1
      ctranslator.bmx
  2. 18 8
      expr.bmx
  3. 24 0
      iparser.bmx
  4. 1 1
      options.bmx
  5. 51 17
      parser.bmx
  6. 2 0
      translator.bmx
  7. 250 16
      type.bmx

+ 74 - 1
ctranslator.bmx

@@ -72,6 +72,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "~q" + p + "l~q"
 		If TULongType( ty ) Return "~q" + p + "y~q"
 		If TSizeTType( ty ) Return "~q" + p + "z~q"
+		If TWParamType( ty ) Return "~q" + p + "w~q"
+		If TLParamType( ty ) Return "~q" + p + "x~q"
 		If TStringType( ty ) Return "~q$~q"
 		If TInt128Type( ty ) Return "~q" + p + "j~q"
 		If TFloat128Type( ty ) Return "~q" + p + "k~q"
@@ -118,6 +120,8 @@ Type TCTranslator Extends TTranslator
 		If TULongType( ty ) Return "~qy~q"
 		If TSizeTType( ty ) Return "~qz~q"
 		If TStringType( ty ) Return "~q$~q"
+		If TWParamType( ty ) Return "~qw~q"
+		If TLParamType( ty ) Return "~qx~q"
 	End Method
 
 	Method TransDefDataConversion$(ty:TType)
@@ -143,6 +147,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "l"
 		If TULongType( ty ) Return "y"
 		If TSizeTType( ty ) Return "z"
+		If TWParamType( ty ) Return "w"
+		If TLParamType( ty ) Return "x"
 		If TStringType( ty ) Return "t"
 	End Method
 	
@@ -158,6 +164,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return p + "l"
 		If TULongType( ty ) Return p + "y"
 		If TSizeTType( ty ) Return p + "t"
+		If TWParamType( ty ) Return p + "w"
+		If TLParamType( ty ) Return p + "x"
 		If TInt128Type( ty ) Return p + "j"
 		If TFloat128Type( ty ) Return p + "k"
 		If TDouble128Type( ty ) Return p + "m"
@@ -214,6 +222,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "BBLONG" + p
 		If TULongType( ty ) Return "BBULONG" + p
 		If TSizeTType( ty ) Return "BBSIZET" + p
+		If TWParamType( ty ) Return "WPARAM" + p
+		If TLParamType( ty ) Return "LPARAM" + p
 		If TInt128Type( ty ) Return "BBINT128" + p
 		If TFloat128Type( ty ) Return "BBFLOAT128" + p
 		If TDouble128Type( ty ) Return "BBDOUBLE128" + p
@@ -291,6 +301,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "%%" + p
 		If TULongType( ty ) Return "||" + p
 		If TSizeTType( ty ) Return "%z" + p
+		If TWParamType( ty ) Return "%w" + p
+		If TLParamType( ty ) Return "%x" + p
 		If TInt128Type( ty ) Return "%j" + p
 		If TFloat128Type( ty ) Return "!k" + p
 		If TDouble128Type( ty ) Return "!m" + p
@@ -342,6 +354,8 @@ Type TCTranslator Extends TTranslator
 			If TLongType( ty ) Return value+"LL"
 			If TULongType( ty ) Return value+"ULL"
 			If TSizeTType( ty ) Return value
+			If TWParamType( ty ) Return value
+			If TLParamType( ty ) Return value
 			If TInt128Type( ty ) Return value
 			If TFloatType( ty ) Then
 				If value = "nan" Or value = "1.#IND0000" Then
@@ -639,7 +653,6 @@ t:+"NULLNULLNULL"
 	'***** Utility *****
 
 	Method TransLocalDecl$( decl:TLocalDecl,init:TExpr, declare:Int = False )
-
 		If Not declare And opt_debug Then
 			Local ty:TType = decl.ty
 			If Not TObjectType( ty ) Or (TObjectType( ty ) And Not TObjectType( ty ).classDecl.IsStruct()) Then
@@ -1505,6 +1518,8 @@ t:+"NULLNULLNULL"
 				If TFloat128Type( src) Return Bra("&"+t)
 				If TDouble128Type( src) Return Bra("&"+t)
 				If TFloat64Type( src) Return Bra("&"+t)
+				If TWParamType( src) Return Bra("&"+t)
+				If TLParamType( src) Return Bra("&"+t)
 
 				If TObjectType(src) Then
 					If TObjectType(src).classDecl.IsExtern() Or (dst._flags & TType.T_VARPTR) Then
@@ -1580,6 +1595,12 @@ t:+"NULLNULLNULL"
 			Else If TSizeTType( dst )
 				If IsPointerType(src, TType.T_SIZET, TType.T_POINTER & dst._flags) Return t
 				If TNumericType( src ) Return Bra("(BBSIZET" + p + ")"+t)
+			Else If TWParamType( dst )
+				If IsPointerType(src, TType.T_WPARAM, TType.T_POINTER & dst._flags) Return t
+				If TNumericType( src ) Return Bra("(WPARAM" + p + ")"+t)
+			Else If TLParamType( dst )
+				If IsPointerType(src, TType.T_LPARAM, TType.T_POINTER & dst._flags) Return t
+				If TNumericType( src ) Return Bra("(LPARAM" + p + ")"+t)
 			Else If TInt128Type( dst )
 				If IsPointerType(src, TType.T_INT128, TType.T_POINTER & dst._flags) Return t
 				If TNumericType( src ) Return Bra("(BBINT128" + p + ")"+t)
@@ -1618,6 +1639,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra( t+"!=0" )
 			If TULongType( src ) Return Bra( t+"!=0" )
 			If TSizeTType( src ) Return Bra( t+"!=0" )
+			If TWParamType( src ) Return Bra( t+"!=0" )
+			If TLParamType( src ) Return Bra( t+"!=0" )
 			If TDoubleType( src ) Return Bra( t+"!=0.0f" )
 			If TArrayType( src ) Return Bra( t+"!= &bbEmptyArray" )
 			If TStringType( src ) Return Bra( t+"!= &bbEmptyString" )
@@ -1644,6 +1667,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBINT)"+t)
 			If TULongType( src ) Return Bra("(BBINT)"+t)
 			If TSizeTType( src ) Return Bra("(BBINT)"+t)
+			If TWParamType( src ) Return Bra("(BBINT)"+t)
+			If TLParamType( src ) Return Bra("(BBINT)"+t)
 			If TStringType( src ) Return "bbStringToInt" + Bra(t)
 			'If TIntVarPtrType( src ) Return Bra("*" + t)
 			If IsPointerType(src,0,TType.T_POINTER) Return Bra("(BBINT)"+t)
@@ -1657,6 +1682,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return t
 			If TULongType( src ) Return Bra("(BBLONG)"+t)
 			If TSizeTType( src ) Return Bra("(BBLONG)"+t)
+			If TWParamType( src ) Return Bra("(BBLONG)"+t)
+			If TLParamType( src ) Return Bra("(BBLONG)"+t)
 			If TFloatType( src ) Return Bra("(BBLONG)"+t)
 			If TDoubleType( src ) Return Bra("(BBLONG)"+t)
 			If TStringType( src ) Return "bbStringToLong" + Bra(t)
@@ -1672,6 +1699,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src) Return Bra("(BBSIZET)"+t)
 			If TULongType( src) Return Bra("(BBSIZET)"+t)
 			If TSizeTType( src ) Return t
+			If TWParamType( src ) Return Bra("(BBSIZET)"+t)
+			If TLParamType( src ) Return Bra("(BBSIZET)"+t)
 			If TFloatType( src ) Return Bra("(BBSIZET)"+t)
 			If TDoubleType( src ) Return Bra("(BBSIZET)"+t)
 			If TStringType( src ) Return "bbStringToSizet" + Bra(t)
@@ -1689,6 +1718,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBFLOAT)"+t)
 			If TULongType( src ) Return Bra("(BBFLOAT)"+t)
 			If TSizeTType( src ) Return Bra("(BBFLOAT)"+t)
+			If TWParamType( src ) Return Bra("(BBFLOAT)"+t)
+			If TLParamType( src ) Return Bra("(BBFLOAT)"+t)
 			If TStringType( src ) Return "bbStringToFloat" + Bra(t)
 			'If TFloatVarPtrType( src ) Return Bra("*" + t)
 			'If TPointerType( src ) Return Bra("(BBFLOAT)"+t)
@@ -1703,6 +1734,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TULongType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TSizeTType( src ) Return Bra("(BBDOUBLE)"+t)
+			If TWParamType( src ) Return Bra("(BBDOUBLE)"+t)
+			If TLParamType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TStringType( src ) Return "bbStringToDouble" + Bra(t)
 			'If TDoubleVarPtrType( src ) Return Bra("*" + t)
 			'If TPointerType( src ) Return Bra("(BBDOUBLE)"+t)
@@ -1716,6 +1749,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return "bbStringFromLong"+Bra( t )
 			If TULongType( src ) Return "bbStringFromULong"+Bra( t )
 			If TSizeTType( src ) Return "bbStringFromSizet"+Bra( t )
+			If TWParamType( src ) Return "bbStringFromWParam"+Bra( t )
+			If TLParamType( src ) Return "bbStringFromLParam"+Bra( t )
 			If TFloatType( src ) Return "bbStringFromFloat"+Bra( t )
 			If TDoubleType( src ) Return "bbStringFromDouble"+Bra( t )
 			If TStringType( src ) Then
@@ -1753,6 +1788,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBBYTE)"+t)
 			If TULongType( src ) Return Bra("(BBBYTE)"+t)
 			If TSizeTType( src ) Return Bra("(BBBYTE)"+t)
+			If TWParamType( src ) Return Bra("(BBBYTE)"+t)
+			If TLParamType( src ) Return Bra("(BBBYTE)"+t)
 			If TStringType( src ) Return "bbStringToInt" + Bra(t)
 			'If TByteVarPtrType( src ) Return Bra("*" + t)
 		Else If TShortType( dst )
@@ -1766,6 +1803,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBSHORT)"+t)
 			If TULongType( src ) Return Bra("(BBSHORT)"+t)
 			If TSizeTType( src ) Return Bra("(BBSHORT)"+t)
+			If TWParamType( src ) Return Bra("(BBSHORT)"+t)
+			If TLParamType( src ) Return Bra("(BBSHORT)"+t)
 			If TStringType( src ) Return "bbStringToInt" + Bra(t)
 			'If TShortVarPtrType( src ) Return Bra("*" + t)
 		Else If TUIntType( dst )
@@ -1779,6 +1818,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBUINT)"+t)
 			If TULongType( src ) Return Bra("(BBUINT)"+t)
 			If TSizeTType( src ) Return Bra("(BBUINT)"+t)
+			If TWParamType( src ) Return Bra("(BBUINT)"+t)
+			If TLParamType( src ) Return Bra("(BBUINT)"+t)
 			If TStringType( src ) Return "bbStringToUInt" + Bra(t)
 		Else If TULongType( dst )
 			If TBoolType( src ) Return Bra( t )
@@ -1791,6 +1832,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBULONG)"+t)
 			If TULongType( src) Return t
 			If TSizeTType( src ) Return Bra("(BBULONG)"+t)
+			If TWParamType( src ) Return Bra("(BBULONG)"+t)
+			If TLParamType( src ) Return Bra("(BBULONG)"+t)
 			If TStringType( src ) Return "bbStringToULong" + Bra(t)
 			If TFloat64Type( src ) Return Bra("(BBULONG)"+t)
 		Else If TFloat64Type( dst )
@@ -1810,6 +1853,36 @@ t:+"NULLNULLNULL"
 			If TDouble128Type( src) Return t
 			If TInt128Type( src ) Return Bra("(BBDOUBLE128)"+t)
 			If TFloat128Type( src ) Return Bra("(BBDOUBLE128)"+t)
+		 Else If TWParamType( dst )
+			If TBoolType( src ) Return Bra( t )
+			If TByteType( src) Return Bra("(WPARAM)"+t)
+			If TShortType( src) Return Bra("(WPARAM)"+t)
+			If TIntType( src) Return Bra("(WPARAM)"+t)
+			If TUIntType( src) Return Bra("(WPARAM)"+t)
+			If TLongType( src) Return Bra("(WPARAM)"+t)
+			If TULongType( src) Return Bra("(WPARAM)"+t)
+			If TSizeTType( src ) Return Bra("(WPARAM)"+t)
+			If TWParamType( src ) Return t
+			If TLParamType( src ) Return Bra("(WPARAM)"+t)
+			If TFloatType( src ) Return Bra("(WPARAM)"+t)
+			If TDoubleType( src ) Return Bra("(WPARAM)"+t)
+			If TStringType( src ) Return "bbStringToWParam" + Bra(t)
+			If IsPointerType(src,0,TType.T_POINTER) Return Bra("(WPARAM)"+t)
+		 Else If TLParamType( dst )
+			If TBoolType( src ) Return Bra( t )
+			If TByteType( src) Return Bra("(LPARAM)"+t)
+			If TShortType( src) Return Bra("(LPARAM)"+t)
+			If TIntType( src) Return Bra("(LPARAM)"+t)
+			If TUIntType( src) Return Bra("(LPARAM)"+t)
+			If TLongType( src) Return Bra("(LPARAM)"+t)
+			If TULongType( src) Return Bra("(LPARAM)"+t)
+			If TSizeTType( src ) Return Bra("(LPARAM)"+t)
+			If TWParamType( src ) Return Bra("(LPARAM)"+t)
+			If TLParamType( src ) Return t
+			If TFloatType( src ) Return Bra("(LPARAM)"+t)
+			If TDoubleType( src ) Return Bra("(LPARAM)"+t)
+			If TStringType( src ) Return "bbStringToLParam" + Bra(t)
+			If IsPointerType(src,0,TType.T_POINTER) Return Bra("(LPARAM)"+t)
 
 		Else If TArrayType( dst )
 			If TArrayType( src ) Then

+ 18 - 8
expr.bmx

@@ -215,8 +215,10 @@ Type TExpr
 		If TInt128Type( lhs ) Or TInt128Type( rhs ) Return New TInt128Type
 		If TULongType( lhs ) Or TULongType( rhs ) Return New TULongType
 		If TSizeTType( lhs ) Or TSizeTType( rhs ) Return New TSizeTType
+		If TWParamType( lhs ) Or TWParamType( rhs ) Return New TWParamType
 		If TLongType( lhs ) And TUIntType( rhs ) Return New TULongType
 		If TUIntType( lhs ) And TLongType( rhs ) Return New TULongType
+		If TLParamType( lhs ) Or TLParamType( rhs ) Return New TLParamType
 		If TLongType( lhs ) Or TLongType( rhs ) Return New TLongType
 		If TUIntType( lhs ) Or TUIntType( rhs ) Return New TUIntType
 		If TIntType( lhs ) Or TIntType( rhs ) Return New TIntType
@@ -360,7 +362,7 @@ Type TConstExpr Extends TExpr
 			Return Self
 		End If
 		
-		If TIntType( ty ) Or TShortType( ty ) Or TByteType( ty ) Or TLongType( ty ) Or TUIntType( ty ) Or TULongType( ty )
+		If TIntType( ty ) Or TShortType( ty ) Or TByteType( ty ) Or TLongType( ty ) Or TUIntType( ty ) Or TULongType( ty ) Or TWParamType(ty) Or TLParamType(ty)
 			Local radix:Int
 			If value.StartsWith( "%" )
 				radix=1
@@ -496,7 +498,7 @@ Type TConstExpr Extends TExpr
 			Local val:Long = value.ToLong()
 			
 			If val < 0 Then
-				If TByteType(ty) Or TShortType(ty) Or TUIntType(ty) Or TULongType(ty) Or TSizeTType(ty) Or TInt128Type(ty) Then
+				If TByteType(ty) Or TShortType(ty) Or TUIntType(ty) Or TULongType(ty) Or TSizeTType(ty) Or TInt128Type(ty) Or TWParamType(ty) Then
 					Return False
 				End If
 			Else
@@ -506,13 +508,13 @@ Type TConstExpr Extends TExpr
 					End If
 				End If
 
-				If TUIntType(ty) Or (TSizeTType(ty) And WORD_SIZE = 4) Then
+				If TUIntType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 4) Then
 					If val > 4294967296:Long Then
 						Return False
 					End If
 				End If
 				
-				If TULongType(ty) Or (TSizeTType(ty) And WORD_SIZE = 8) Then
+				If TULongType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 8) Then
 					If value.length > 20 Then
 						Return False
 					Else If value.length = 20 Then
@@ -535,13 +537,13 @@ Type TConstExpr Extends TExpr
 				End If
 			End If
 
-			If TIntType(ty) Then
+			If TIntType(ty) Or (TLParamType(ty) And WORD_SIZE = 4) Then
 				If value <> String.FromInt(Int(val)) Then
 					Return False
 				End If
 			End If
 
-			If TLongType(ty) Then
+			If TLongType(ty) Or (TLParamType(ty) And WORD_SIZE = 8) Then
 				If value <> String.FromLong(Long(val)) Then
 					Return False
 				End If
@@ -1491,6 +1493,10 @@ Type TCastExpr Extends TExpr
 			Return String( val )
 		Else If TByteType( exprType )
 			Return Byte( val )
+		Else If TWParamType( exprType )
+			Return Long( val )
+		Else If TLParamType( exprType )
+			Return Long( val )
 		Else If TObjectType( exprType )
 			If TStringType( expr.exprType )
 				Return val
@@ -1632,6 +1638,10 @@ Type TBinaryMathExpr Extends TBinaryExpr
 				exprType=New TULongType
 			Else If TSizeTType(lhs.exprType) Then
 				exprType=New TSizeTType
+			Else If TWParamType(lhs.exprType) Then
+				exprType=New TWParamType
+			Else If TLParamType(lhs.exprType) Then
+				exprType=New TLParamType
 			Else
 				exprType=New TIntType
 			End If
@@ -1693,7 +1703,7 @@ Type TBinaryMathExpr Extends TBinaryExpr
 			Case "~~" Return x ~ y
 			Case "|" Return x | y
 			End Select
-		Else If TLongType( exprType ) Or TSizeTType(exprType) Or TUIntType(exprType) Or TULongType(exprType) Or TInt128Type(exprType)
+		Else If TLongType( exprType ) Or TSizeTType(exprType) Or TUIntType(exprType) Or TULongType(exprType) Or TInt128Type(exprType) Or TWParamType(exprType) Or TLParamType(exprType) 
 			Local x:Long=Long(lhs),y:Long=Long(rhs)
 			Select op
 			Case "^" Return x^y
@@ -1794,7 +1804,7 @@ Type TBinaryCompareExpr Extends TBinaryExpr
 			Case ">"  r=(lhs> rhs)
 			Case ">=", "=>" r=(lhs>=rhs)
 			End Select
-		Else If TLongType( ty ) Or TSizeTType( ty ) Or TUIntType( ty ) Or TULongType( ty ) Or TInt128Type(ty)
+		Else If TLongType( ty ) Or TSizeTType( ty ) Or TUIntType( ty ) Or TULongType( ty ) Or TInt128Type(ty) Or TWParamType(ty) Or TLParamType(ty)
 			Local lhs:Long=Long( Self.lhs.Eval() )
 			Local rhs:Long=Long( Self.rhs.Eval() )
 			Select op

+ 24 - 0
iparser.bmx

@@ -1216,6 +1216,10 @@ End Rem
 				ty = New TSizetType
 			ElseIf CParse("j") Then
 				ty = New TInt128Type
+			ElseIf CParse("w") Then
+				ty = New TWParamType
+			ElseIf CParse("x") Then
+				ty = New TLParamType
 			End If
 			
 			If CParse("&") And Not (attrs & DECL_FIELD) Then
@@ -1532,6 +1536,26 @@ End Rem
 			Wend
 			Return ty
 		End If
+		If CParse( "wparam" )
+			Local ty:TType = New TWParamType
+			While CParse("ptr")
+				ty = TType.MapToPointerType(ty)
+			Wend
+			While CParse( "*" )
+				ty = TType.MapToPointerType(ty)
+			Wend
+			Return ty
+		End If
+		If CParse( "lparam" )
+			Local ty:TType = New TLParamType
+			While CParse("ptr")
+				ty = TType.MapToPointerType(ty)
+			Wend
+			While CParse( "*" )
+				ty = TType.MapToPointerType(ty)
+			Wend
+			Return ty
+		End If
 		Return ParseIdentType()
 	End Method
 	

+ 1 - 1
options.bmx

@@ -25,7 +25,7 @@ SuperStrict
 
 Import "base.configmap.bmx"
 
-Const version:String = "0.80"
+Const version:String = "0.81"
 
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_MODULE:Int = 1

+ 51 - 17
parser.bmx

@@ -541,30 +541,42 @@ Type TParser
 		If CParse( "object" ) Return New TIdentType.Create( "brl.classes.object" )
 
 		Local ty:TType
-		If CParse( "short" ) ty = New TShortType
-		If CParse( "byte" ) ty = New TByteType
-		If CParse( "int" ) ty = New TIntType
-		If CParse( "uint" ) ty = New TUIntType
-		If CParse( "float" ) ty = New TFloatType
-		If CParse( "long" ) ty = New TLongType
-		If CParse( "ulong" ) ty = New TULongType
-		If CParse( "double" ) ty = New TDoubleType
-		If CParse( "size_t" ) ty = New TSizeTType
-		If CParse( "int128" ) Then
+		If CParse( "short" )
+			ty = New TShortType
+		Else If CParse( "byte" )
+			ty = New TByteType
+		Else If CParse( "int" )
+			ty = New TIntType
+		Else If CParse( "uint" )
+			ty = New TUIntType
+		Else If CParse( "float" )
+			ty = New TFloatType
+		Else If CParse( "long" )
+			ty = New TLongType
+		Else If CParse( "ulong" )
+			ty = New TULongType
+		Else If CParse( "double" )
+			ty = New TDoubleType
+		Else If CParse( "size_t" )
+			ty = New TSizeTType
+		Else If CParse( "int128" ) Then
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			ty = New TInt128Type
-		End If
-		If CParse( "float128" ) Then
+		Else If CParse( "float128" ) Then
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			ty = New TFloat128Type
-		End If
-		If CParse( "double128" ) Then
+		Else If CParse( "double128" ) Then
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			ty = New TDouble128Type
-		End If
-		If CParse( "float64" ) Then
+		Else If CParse( "float64" ) Then
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			ty = New TFloat64Type
+		Else If CParse( "wparam" ) Then
+			If opt_platform <> "win32" Err "WParam types only available on Win32"
+			ty = New TWParamType
+		Else If CParse( "lparam" ) Then
+			If opt_platform <> "win32" Err "LParam types only available on Win32"
+			ty = New TLParamType
 		End If
 
 		While CParse("ptr")
@@ -599,6 +611,14 @@ Type TParser
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			Return New TFloat64Type
 		End If
+		If CParse( "wparam" ) Then
+			If opt_platform <> "win32" Err "WParam types only available on Win32"
+			Return New TWParamType
+		End If
+		If CParse( "lparam" ) Then
+			If opt_platform <> "win32" Err "LParam types only available on Win32"
+			Return New TLParamType
+		End If
 	End	Method
 
 	Method ParseNewType:TType()
@@ -630,6 +650,14 @@ Type TParser
 			If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 			Return New TFloat64Type
 		End If
+		If CParse( "wparam" ) Then
+			If opt_platform <> "win32" Err "WParam types only available on Win32"
+			Return New TWParamType
+		End If
+		If CParse( "lparam" ) Then
+			If opt_platform <> "win32" Err "LParam types only available on Win32"
+			Return New TLParamType
+		End If
 		Return ParseIdentType()
 	End Method
 
@@ -1040,7 +1068,7 @@ Type TParser
 		Case "false"
 			NextToke
 			expr=New TConstExpr.Create( New TIntType,"" )
-		Case "int","long","float","double","object","short","byte","size_t","uint","ulong","int128","float64","float128","double128"
+		Case "int","long","float","double","object","short","byte","size_t","uint","ulong","int128","float64","float128","double128","lparam","wparam"
 			Local id$=_toke
 			Local ty:TType=ParseType()
 
@@ -1074,6 +1102,12 @@ Type TParser
 					Case "float64"
 						If opt_arch <> "x64" Err "Intrinsic types only available on x64"
 						ty = New TFloat64Type
+					Case "wparam"
+						If opt_platform <> "win32" Err "WParam types only available on Win32"
+						ty = New TWParamType
+					Case "lparam"
+						If opt_platform <> "win32" Err "LParam types only available on Win32"
+						ty = New TLParamType
 				End Select
 			End If
 

+ 2 - 0
translator.bmx

@@ -196,6 +196,8 @@ Type TTranslator
 		If TInt128Type( ty ) Return p + "j"
 		If TDouble128Type( ty ) Return p + "m"
 		If TStringType( ty ) Return p + "S"
+		If TWParamType( ty ) Return p + "W"
+		If TLParamType( ty ) Return p + "L"
 		If TArrayType( ty ) Then
 			Return p + "a" + TransMangleType(TArrayType( ty ).elemType)
 		End If

+ 250 - 16
type.bmx

@@ -208,6 +208,8 @@ Type TType
 	Const T_INT128:Int      = $2000
 	Const T_FLOAT128:Int    = $4000
 	Const T_DOUBLE128:Int   = $8000
+	Const T_LPARAM:Int      =$10000
+	Const T_WPARAM:Int      =$20000
 
 	Const T_MAX_DISTANCE:Int = $FFFF
 
@@ -438,11 +440,11 @@ Type TIntType Extends TIntegralType
 		'	Return ctor And ctor.IsCtor()
 		'EndIf
 		If _flags & T_VARPTR And (TIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
-		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null)
+		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And TLParamType(ty)<>Null)
 	End Method
 
 	Method WidensToType:Int( ty:TType )
-		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TIntType(ty)<>Null And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TIntType(ty)<>Null And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or (WORD_SIZE=8 And TLParamType(ty)<>Null)
 	End Method
 	
 	Method DistanceToType:Int(ty:TType)
@@ -458,10 +460,18 @@ Type TIntType Extends TIntegralType
 			Return 0
 		End If
 		
+		If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
+			Return 0
+		End If
+		
 		If TLongType(ty)<>Null Then
 			Return 2
 		End If
 
+		If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
+			Return 2
+		End If
+		
 		If TFloatType(ty)<>Null Then
 			Return 4
 		End If
@@ -501,11 +511,11 @@ Type TUIntType Extends TIntegralType
 		'	Return ctor And ctor.IsCtor()
 		'EndIf
 		If _flags & T_VARPTR And (TUIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
-		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
+		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null))
 	End Method
 
 	Method WidensToType:Int( ty:TType )
-		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TUIntType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<> Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TUIntType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<> Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or (WORD_SIZE=8 And TWParamType(ty)<>Null)
 	End Method
 
 	Method DistanceToType:Int(ty:TType)
@@ -517,7 +527,7 @@ Type TUIntType Extends TIntegralType
 			End If
 		End If
 
-		If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 0
 		End If
 		
@@ -529,7 +539,7 @@ Type TUIntType Extends TIntegralType
 			Return 1
 		End If
 		
-		If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 2
 		End If
 		
@@ -580,14 +590,14 @@ Type TSizeTType Extends TIntegralType
 		'	Return ctor And ctor.IsCtor()
 		'EndIf
 		If _flags & T_VARPTR And (TSizeTType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
-		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
+		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And TUIntType(ty)<>Null) Or (WORD_SIZE=8 And TULongType(ty)<>Null)
 	End Method
 
 	Method WidensToType:Int( ty:TType )
 		If WORD_SIZE = 4 Then
-			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
 		Else
-			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
 		End If
 	End Method
 
@@ -604,6 +614,10 @@ Type TSizeTType Extends TIntegralType
 			Return 0
 		End If
 
+		If TWParamType(ty)<>Null Then
+			Return 0
+		End If
+
 		If WORD_SIZE = 4 Then
 			If TUIntType(ty)<>Null Then
 				Return 0
@@ -612,6 +626,10 @@ Type TSizeTType Extends TIntegralType
 			If TIntType(ty)<>Null Then
 				Return 2
 			End If
+			
+			If TLParamType(ty)<>Null Then
+				Return 2
+			End If
 
 			If TULongType(ty)<>Null Then
 				Return 3
@@ -638,6 +656,10 @@ Type TSizeTType Extends TIntegralType
 				Return 2
 			End If
 
+			If TLParamType(ty)<>Null Then
+				Return 2
+			End If
+
 			If TFloatType(ty)<>Null Then
 				Return 4
 			End If
@@ -687,7 +709,7 @@ Type TByteType Extends TIntegralType
 	End Method
 
 	Method WidensToType:Int( ty:TType )
-		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TByteType(ty)<>Null And (ty._flags & T_VAR)) Or TShortType(ty)<>Null Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TByteType(ty)<>Null And (ty._flags & T_VAR)) Or TShortType(ty)<>Null Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
 	End Method
 
 	Method DistanceToType:Int(ty:TType)
@@ -707,7 +729,7 @@ Type TByteType Extends TIntegralType
 			Return 2
 		End If
 
-		If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 4
 		End If
 		
@@ -718,8 +740,12 @@ Type TByteType Extends TIntegralType
 		If TIntType(ty)<>Null Then
 			Return 5
 		End If
+
+		If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
+			Return 5
+		End If
 		
-		If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 6
 		End If
 		
@@ -731,6 +757,10 @@ Type TByteType Extends TIntegralType
 			Return 7
 		End If
 
+		If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
+			Return 7
+		End If
+
 		If TFloatType(ty)<>Null Then
 			Return 8
 		End If
@@ -774,7 +804,7 @@ Type TShortType Extends TIntegralType
 	End Method
 
 	Method WidensToType:Int( ty:TType )
-		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TShortType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+		Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TShortType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
 	End Method
 
 	Method DistanceToType:Int(ty:TType)
@@ -790,7 +820,7 @@ Type TShortType Extends TIntegralType
 			Return 0
 		End If
 
-		If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 2
 		End If
 		
@@ -801,8 +831,12 @@ Type TShortType Extends TIntegralType
 		If TIntType(ty)<>Null Then
 			Return 3
 		End If
+
+		If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
+			Return 3
+		End If
 		
-		If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 4
 		End If
 
@@ -814,6 +848,10 @@ Type TShortType Extends TIntegralType
 			Return 5
 		End If
 
+		If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
+			Return 5
+		End If
+
 		If TFloatType(ty)<>Null Then
 			Return 6
 		End If
@@ -872,6 +910,10 @@ Type TLongType Extends TIntegralType ' BaH Long
 		If TLongType(ty)<>Null Then
 			Return 0
 		End If
+		
+		If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
+			Return 0
+		End If
 
 		If TFloatType(ty)<>Null Then
 			Return 2
@@ -931,7 +973,7 @@ Type TULongType Extends TIntegralType
 			Return 0
 		End If
 
-		If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
+		If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
 			Return 0
 		End If
 		
@@ -1729,3 +1771,195 @@ Type TVarPtrType Extends TType
 		Return New TVarPtrType
 	End Method
 End Type
+
+Type TParamType Extends TIntegralType
+End Type
+
+Type TWParamType Extends TParamType
+
+	Method EqualsType:Int( ty:TType )
+		Return TWParamType( ty )<>Null And (_flags = ty._flags Or ..
+			(_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
+	End Method
+	
+	Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
+		If _flags & T_VARPTR And (TWParamType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
+		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
+	End Method
+
+	Method WidensToType:Int( ty:TType )
+		If WORD_SIZE = 4 Then
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TWParamType(ty)<>Null Or TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
+		Else
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TWParamType(ty)<>Null Or TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
+		End If
+	End Method
+
+	Method DistanceToType:Int(ty:TType)
+		If IsPointerType(ty, 0, T_POINTER) Then
+			If IsPointerType(Self, 0, T_POINTER) Then
+				Return 0
+			Else
+				Return T_MAX_DISTANCE
+			End If
+		End If
+
+		If TWParamType(ty)<>Null Then
+			Return 0
+		End If
+
+		If TSizeTType(ty)<>Null Then
+			Return 0
+		End If
+
+		If WORD_SIZE = 4 Then
+			If TUIntType(ty)<>Null Then
+				Return 0
+			End If
+
+			If TIntType(ty)<>Null Then
+				Return 2
+			End If
+
+			If TULongType(ty)<>Null Then
+				Return 3
+			End If
+
+			If TLongType(ty)<>Null Then
+				Return 4
+			End If
+
+			If TFloatType(ty)<>Null Then
+				Return 5
+			End If
+	
+			If TDoubleType(ty)<>Null Then
+				Return 6
+			End If
+			
+		Else
+			If TULongType(ty)<>Null Then
+				Return 0
+			End If
+
+			If TLongType(ty)<>Null Then
+				Return 2
+			End If
+
+			If TFloatType(ty)<>Null Then
+				Return 4
+			End If
+	
+			If TDoubleType(ty)<>Null Then
+				Return 6
+			End If
+
+			If TFloat64Type(ty)<>Null Then
+				Return 8
+			End If
+
+		End If
+	
+		Return T_MAX_DISTANCE
+	End Method
+	
+	Method OnCopy:TType()
+		Return New TWParamType
+	End Method
+
+	Method ToString$()
+		Return "WPARAM" + ToStringParts()
+	End Method
+
+	Method GetSize:Int()
+		Return WORD_SIZE
+	End Method
+
+End Type
+
+Type TLParamType Extends TParamType
+
+	Method EqualsType:Int( ty:TType )
+		Return TLParamType( ty )<>Null And (_flags = ty._flags Or ..
+			(_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
+	End Method
+	
+	Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
+		If _flags & T_VARPTR And (TLParamType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
+		Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
+	End Method
+
+	Method WidensToType:Int( ty:TType )
+		If WORD_SIZE = 4 Then
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TIntType(ty)<>Null Or TLParamType(ty)<>Null) And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
+		Else
+			Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TLongType(ty)<>Null Or TLParamType(ty)<>Null) And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
+		End If
+	End Method
+
+	Method DistanceToType:Int(ty:TType)
+		If IsPointerType(ty, 0, T_POINTER) Then
+			If IsPointerType(Self, 0, T_POINTER) Then
+				Return 0
+			Else
+				Return T_MAX_DISTANCE
+			End If
+		End If
+
+		If TLParamType(ty)<>Null Then
+			Return 0
+		End If
+
+		If WORD_SIZE = 4 Then
+		
+			If TIntType(ty)<>Null Then
+				Return 0
+			End If
+			
+			If TLongType(ty)<>Null Then
+				Return 2
+			End If
+			
+			If TFloatType(ty)<>Null Then
+				Return 4
+			End If
+			
+			If TDoubleType(ty)<>Null Then
+				Return 6
+			End If
+			
+		Else
+			If TLongType(ty)<>Null Then
+				Return 0
+			End If
+	
+			If TFloatType(ty)<>Null Then
+				Return 2
+			End If
+	
+			If TDoubleType(ty)<>Null Then
+				Return 4
+			End If
+	
+			If TFloat64Type(ty)<>Null Then
+				Return 6
+			End If
+
+		End If
+	
+		Return T_MAX_DISTANCE
+	End Method
+	
+	Method OnCopy:TType()
+		Return New TLParamType
+	End Method
+
+	Method ToString$()
+		Return "LPARAM" + ToStringParts()
+	End Method
+
+	Method GetSize:Int()
+		Return WORD_SIZE
+	End Method
+
+End Type