Skip to content

Commit

Permalink
Make Godot classes opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
lboklin authored and KaneTW committed Apr 8, 2019
1 parent 8906708 commit 4e9f181
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 20 deletions.
17 changes: 13 additions & 4 deletions classgen/app-classgen/Main.hs
Expand Up @@ -2,6 +2,7 @@ import Classgen.Module
import Classgen.Spec
import Control.Lens
import Control.Monad.State
import Data.Maybe (mapMaybe)
import Data.Aeson
import qualified Data.ByteString.Lazy as BL
import qualified Data.HashMap.Strict as HM
Expand All @@ -22,13 +23,21 @@ main = do
print classes
let state = execState (mapM_ addClass classes >> resolveMethods) (ClassgenState mempty mempty mempty)
mapM_ writeModule (HM.elems (state ^. modules))
writeModule (Module () (Just classModuleHead) [] classImports (state ^. mainDecls))
writeModule $ godotApiAuto (state ^. mainDecls)


where
classModuleHead = ModuleHead () classModuleName Nothing Nothing
classModuleName = ModuleName () $ "Godot.Api.Auto"

godotApiAuto decls = Module () (Just $ classModuleHead $ classExports decls) [] classImports decls
classModuleHead exps = ModuleHead () classModuleName Nothing (Just exps)
classModuleName = ModuleName () "Godot.Api.Auto"
classExports decls = ExportSpecList () $ tcMethod : tcHasBaseClass : mapMaybe fromNewtypeOnly decls
tcMethod = EThingWith () (EWildcard () 0) (UnQual () (Ident () "Method")) []
tcHasBaseClass = EThingWith () (EWildcard () 0) (UnQual () (Ident () "HasBaseClass")) []
fromNewtypeOnly decl = case decl of
DataDecl _ (NewType _) _ (DHead _ (Ident () ntName)) _ _ ->
Just $ EAbs () (NoNamespace ()) (UnQual () (Ident () ntName))
_ ->
Nothing
classImports = map (\n -> ImportDecl () (ModuleName () n) False False False Nothing Nothing Nothing)
[ "Data.Coerce", "Foreign.C", "Godot.Internal.Dispatch"
, "System.IO.Unsafe", "Godot.Gdnative.Internal", "Godot.Gdnative.Types"]
Expand Down
217 changes: 216 additions & 1 deletion src/Godot/Api/Auto.hs
@@ -1,4 +1,219 @@
module Godot.Api.Auto where
module Godot.Api.Auto
(Method(..), HasBaseClass(..), GodotGlobalConstants,
GodotReference, GodotResource, GodotScript, GodotWeakRef,
GodotImage, GodotInputEvent, GodotInputEventWithModifiers,
GodotInputEventKey, GodotInputEventMouse,
GodotInputEventMouseButton, GodotInputEventMouseMotion,
GodotInputEventJoypadButton, GodotInputEventJoypadMotion,
GodotInputEventScreenDrag, GodotInputEventScreenTouch,
GodotInputEventAction, GodotInputEventGesture,
GodotInputEventMagnifyGesture, GodotInputEventPanGesture,
GodotFuncRef, GodotStreamPeer, GodotStreamPeerBuffer,
GodotStreamPeerTCP, GodotTCP_Server, GodotPacketPeer,
GodotPacketPeerUDP, GodotStreamPeerSSL, GodotIP,
GodotPacketPeerStream, GodotNetworkedMultiplayerPeer,
GodotMultiplayerAPI, GodotMainLoop, GodotTranslation,
GodotPHashTranslation, GodotUndoRedo, GodotHTTPClient,
GodotTriangleMesh, GodotResourceInteractiveLoader, Godot_File,
Godot_Directory, Godot_Thread, Godot_Mutex, Godot_Semaphore,
GodotXMLParser, GodotConfigFile, GodotPCKPacker,
GodotPackedDataContainer, GodotPackedDataContainerRef, GodotAStar,
GodotEncodedObjectAsID, GodotJSONParseResult, GodotIP_Unix,
Godot_Geometry, Godot_ResourceLoader, Godot_ResourceSaver,
Godot_OS, Godot_Engine, Godot_ClassDB, Godot_Marshalls, Godot_JSON,
GodotProjectSettings, GodotInputMap, GodotTranslationServer,
GodotPerformance, GodotVisualServer, GodotNode, GodotInput,
GodotInputDefault, GodotAudioServer, GodotARVRServer,
GodotExpression, GodotPhysicsServer, GodotPhysics2DServer,
GodotARVRInterface, GodotARVRPositionalTracker, GodotAudioStream,
GodotAudioStreamPlayback, GodotAudioStreamMicrophone,
GodotAudioStreamRandomPitch, GodotAudioEffect, GodotAudioEffectEQ,
GodotAudioEffectFilter, GodotAudioBusLayout,
GodotAudioEffectAmplify, GodotAudioEffectReverb,
GodotAudioEffectLowPassFilter, GodotAudioEffectHighPassFilter,
GodotAudioEffectBandPassFilter, GodotAudioEffectNotchFilter,
GodotAudioEffectBandLimitFilter, GodotAudioEffectLowShelfFilter,
GodotAudioEffectHighShelfFilter, GodotAudioEffectEQ6,
GodotAudioEffectEQ10, GodotAudioEffectEQ21,
GodotAudioEffectDistortion, GodotAudioEffectStereoEnhance,
GodotAudioEffectPanner, GodotAudioEffectChorus,
GodotAudioEffectDelay, GodotAudioEffectCompressor,
GodotAudioEffectLimiter, GodotAudioEffectPitchShift,
GodotAudioEffectPhaser, GodotAudioEffectRecord,
GodotPhysics2DDirectBodyState, GodotPhysics2DDirectSpaceState,
GodotPhysics2DShapeQueryResult, GodotPhysics2DTestMotionResult,
GodotPhysics2DShapeQueryParameters,
GodotPhysicsShapeQueryParameters, GodotPhysicsDirectBodyState,
GodotPhysicsDirectSpaceState, GodotPhysicsShapeQueryResult,
GodotInstancePlaceholder, GodotViewport, GodotWorld, GodotWorld2D,
GodotTexture, GodotViewportTexture, GodotHTTPRequest, GodotTimer,
GodotCanvasLayer, GodotCanvasItem, GodotNode2D,
GodotCanvasModulate, GodotResourcePreloader, GodotButtonGroup,
GodotControl, GodotTheme, GodotBaseButton, GodotShortCut,
GodotButton, GodotLabel, GodotRange, GodotScrollBar,
GodotHScrollBar, GodotVScrollBar, GodotProgressBar, GodotSlider,
GodotHSlider, GodotVSlider, GodotPopup, GodotPopupPanel,
GodotMenuButton, GodotCheckBox, GodotCheckButton, GodotToolButton,
GodotLinkButton, GodotPanel, GodotTextureRect, GodotColorRect,
GodotNinePatchRect, GodotContainer, GodotTabContainer, GodotTabs,
GodotSeparator, GodotHSeparator, GodotVSeparator,
GodotTextureButton, GodotBitMap, GodotBoxContainer,
GodotHBoxContainer, GodotVBoxContainer, GodotGridContainer,
GodotCenterContainer, GodotScrollContainer, GodotPanelContainer,
GodotTextureProgress, GodotItemList, GodotLineEdit,
GodotVideoPlayer, GodotVideoStream, GodotWindowDialog,
GodotAcceptDialog, GodotConfirmationDialog, GodotFileDialog,
GodotPopupMenu, GodotTree, GodotTextEdit, GodotTreeItem,
GodotOptionButton, GodotSpinBox, GodotReferenceRect,
GodotColorPicker, GodotColorPickerButton, GodotRichTextLabel,
GodotMarginContainer, GodotPopupDialog, GodotViewportContainer,
GodotSplitContainer, GodotHSplitContainer, GodotVSplitContainer,
GodotGraphNode, GodotGraphEdit, GodotSpatial, GodotSpatialGizmo,
GodotSkeleton, GodotAnimationPlayer, GodotTween,
GodotVisualInstance, GodotGeometryInstance, GodotCamera,
GodotEnvironment, GodotClippedCamera, GodotListener,
GodotARVRCamera, GodotARVRController, GodotARVRAnchor,
GodotARVROrigin, GodotInterpolatedCamera, GodotMeshInstance,
GodotMesh, GodotImmediateGeometry, GodotSpriteBase3D,
GodotSprite3D, GodotAnimatedSprite3D, GodotSpriteFrames,
GodotLight, GodotDirectionalLight, GodotOmniLight, GodotSpotLight,
GodotReflectionProbe, GodotGIProbe, GodotGIProbeData,
GodotBakedLightmap, GodotBakedLightmapData,
GodotAnimationTreePlayer, GodotParticles, GodotCPUParticles,
GodotCurve, GodotGradientTexture, GodotPosition3D,
GodotNavigationMeshInstance, GodotNavigationMesh, GodotNavigation,
GodotRootMotionView, GodotAnimationTree, GodotAnimationRootNode,
GodotAnimationNode, GodotAnimationNodeBlendTree,
GodotAnimationNodeBlendSpace1D, GodotAnimationNodeBlendSpace2D,
GodotAnimationNodeStateMachine,
GodotAnimationNodeStateMachinePlayback,
GodotAnimationNodeStateMachineTransition, GodotAnimationNodeOutput,
GodotAnimationNodeOneShot, GodotAnimationNodeAnimation,
GodotAnimationNodeAdd2, GodotAnimationNodeAdd3,
GodotAnimationNodeBlend2, GodotAnimationNodeBlend3,
GodotAnimationNodeTimeScale, GodotAnimationNodeTimeSeek,
GodotAnimationNodeTransition, GodotCollisionObject,
GodotPhysicsBody, GodotStaticBody, GodotPhysicsMaterial,
GodotRigidBody, GodotKinematicCollision, GodotKinematicBody,
GodotSpringArm, GodotShape, GodotPhysicalBone, GodotSoftBody,
GodotSkeletonIK, GodotBoneAttachment, GodotVehicleBody,
GodotVehicleWheel, GodotArea, GodotProximityGroup,
GodotCollisionShape, GodotCollisionPolygon, GodotRayCast,
GodotMultiMeshInstance, GodotMultiMesh, GodotCurve3D, GodotPath,
GodotPathFollow, GodotOrientedPathFollow, GodotVisibilityNotifier,
GodotVisibilityEnabler, GodotWorldEnvironment,
GodotRemoteTransform, GodotJoint, GodotPinJoint, GodotHingeJoint,
GodotSliderJoint, GodotConeTwistJoint, GodotGeneric6DOFJoint,
GodotMeshLibrary, GodotShader, GodotVisualShader,
GodotVisualShaderNode, GodotVisualShaderNodeInput,
GodotVisualShaderNodeOutput, GodotVisualShaderNodeScalarConstant,
GodotVisualShaderNodeColorConstant,
GodotVisualShaderNodeVec3Constant,
GodotVisualShaderNodeTransformConstant,
GodotVisualShaderNodeScalarOp, GodotVisualShaderNodeVectorOp,
GodotVisualShaderNodeColorOp, GodotVisualShaderNodeTransformMult,
GodotVisualShaderNodeTransformVecMult,
GodotVisualShaderNodeScalarFunc, GodotVisualShaderNodeVectorFunc,
GodotVisualShaderNodeDotProduct, GodotVisualShaderNodeVectorLen,
GodotVisualShaderNodeScalarInterp,
GodotVisualShaderNodeVectorInterp,
GodotVisualShaderNodeVectorCompose,
GodotVisualShaderNodeTransformCompose,
GodotVisualShaderNodeVectorDecompose,
GodotVisualShaderNodeTransformDecompose,
GodotVisualShaderNodeTexture, GodotVisualShaderNodeCubeMap,
GodotCubeMap, GodotVisualShaderNodeUniform,
GodotVisualShaderNodeScalarUniform,
GodotVisualShaderNodeColorUniform,
GodotVisualShaderNodeVec3Uniform,
GodotVisualShaderNodeTransformUniform,
GodotVisualShaderNodeTextureUniform,
GodotVisualShaderNodeCubeMapUniform, GodotMaterial,
GodotShaderMaterial, GodotCanvasItemMaterial, GodotCPUParticles2D,
GodotParticles2D, GodotSprite, GodotAnimatedSprite,
GodotPosition2D, GodotLine2D, GodotGradient, GodotMeshInstance2D,
GodotCollisionObject2D, GodotPhysicsBody2D, GodotStaticBody2D,
GodotRigidBody2D, GodotKinematicBody2D, GodotKinematicCollision2D,
GodotArea2D, GodotCollisionShape2D, GodotShape2D,
GodotCollisionPolygon2D, GodotRayCast2D, GodotVisibilityNotifier2D,
GodotVisibilityEnabler2D, GodotPolygon2D, GodotSkeleton2D,
GodotBone2D, GodotLight2D, GodotLightOccluder2D,
GodotOccluderPolygon2D, GodotYSort, GodotBackBufferCopy,
GodotCamera2D, GodotJoint2D, GodotPinJoint2D, GodotGrooveJoint2D,
GodotDampedSpringJoint2D, GodotTileSet, GodotTileMap,
GodotParallaxBackground, GodotParallaxLayer,
GodotTouchScreenButton, GodotRemoteTransform2D,
GodotParticlesMaterial, GodotCurveTexture, GodotArrayMesh,
GodotPrimitiveMesh, GodotCapsuleMesh, GodotCubeMesh,
GodotCylinderMesh, GodotPlaneMesh, GodotPrismMesh, GodotQuadMesh,
GodotSphereMesh, GodotSpatialMaterial, GodotRayShape,
GodotSphereShape, GodotBoxShape, GodotCapsuleShape,
GodotCylinderShape, GodotPlaneShape, GodotConvexPolygonShape,
GodotConcavePolygonShape, GodotSurfaceTool, GodotMeshDataTool,
GodotSpatialVelocityTracker, GodotSky, GodotPanoramaSky,
GodotProceduralSky, GodotStreamTexture, GodotImageTexture,
GodotAtlasTexture, GodotLargeTexture, GodotProxyTexture,
GodotAnimatedTexture, GodotTextureLayered, GodotTexture3D,
GodotTextureArray, GodotAnimation, GodotFont, GodotBitmapFont,
GodotTextFile, GodotDynamicFontData, GodotDynamicFont,
GodotStyleBox, GodotStyleBoxEmpty, GodotStyleBoxTexture,
GodotStyleBoxFlat, GodotStyleBoxLine, GodotPolygonPathFinder,
GodotAudioStreamPlayer, GodotAudioStreamPlayer2D,
GodotAudioStreamPlayer3D, GodotAudioStreamSample, GodotLineShape2D,
GodotSegmentShape2D, GodotRayShape2D, GodotCircleShape2D,
GodotRectangleShape2D, GodotCapsuleShape2D,
GodotConvexPolygonShape2D, GodotConcavePolygonShape2D,
GodotCurve2D, GodotPath2D, GodotPathFollow2D, GodotNavigation2D,
GodotNavigationPolygon, GodotNavigationPolygonInstance,
GodotSceneState, GodotPackedScene, GodotSceneTree,
GodotSceneTreeTimer, GodotEditorPlugin, GodotEditorImportPlugin,
GodotEditorScript, GodotEditorSelection, GodotEditorFileDialog,
GodotEditorSettings, GodotEditorSpatialGizmo,
GodotEditorResourcePreview, GodotEditorResourcePreviewGenerator,
GodotEditorFileSystem, GodotEditorFileSystemDirectory,
GodotScriptEditor, GodotEditorInterface, GodotEditorExportPlugin,
GodotEditorResourceConversionPlugin, GodotEditorSceneImporter,
GodotEditorInspector, GodotEditorInspectorPlugin,
GodotEditorProperty, GodotAnimationTrackEditPlugin,
GodotScriptCreateDialog, GodotEditorScenePostImport,
GodotJavaScript, GodotCSGShape, GodotCSGPrimitive, GodotCSGMesh,
GodotCSGSphere, GodotCSGBox, GodotCSGCylinder, GodotCSGTorus,
GodotCSGPolygon, GodotCSGCombiner, GodotNetworkedMultiplayerENet,
GodotGDNativeLibrary, GodotGDNative, GodotMultiplayerPeerGDNative,
GodotPacketPeerGDNative, GodotStreamPeerGDNative,
GodotARVRInterfaceGDNative, GodotNativeScript, GodotPluginScript,
GodotGDScript, GodotGDScriptFunctionState, GodotGridMap,
GodotMobileVRInterface, GodotRegExMatch, GodotRegEx,
GodotResourceImporterOGGVorbis, GodotResourceImporter,
GodotAudioStreamOGGVorbis, GodotVideoStreamTheora, GodotUPNP,
GodotUPNPDevice, GodotVisualScript, GodotVisualScriptNode,
GodotVisualScriptFunctionState, GodotVisualScriptFunction,
GodotVisualScriptOperator, GodotVisualScriptVariableSet,
GodotVisualScriptVariableGet, GodotVisualScriptConstant,
GodotVisualScriptIndexGet, GodotVisualScriptIndexSet,
GodotVisualScriptGlobalConstant, GodotVisualScriptClassConstant,
GodotVisualScriptMathConstant, GodotVisualScriptBasicTypeConstant,
GodotVisualScriptEngineSingleton, GodotVisualScriptSceneNode,
GodotVisualScriptSceneTree, GodotVisualScriptResourcePath,
GodotVisualScriptSelf, GodotVisualScriptCustomNode,
GodotVisualScriptSubCall, GodotVisualScriptComment,
GodotVisualScriptConstructor, GodotVisualScriptLocalVar,
GodotVisualScriptLocalVarSet, GodotVisualScriptInputAction,
GodotVisualScriptDeconstruct, GodotVisualScriptPreload,
GodotVisualScriptTypeCast, GodotVisualScriptFunctionCall,
GodotVisualScriptPropertySet, GodotVisualScriptPropertyGet,
GodotVisualScriptEmitSignal, GodotVisualScriptReturn,
GodotVisualScriptCondition, GodotVisualScriptWhile,
GodotVisualScriptIterator, GodotVisualScriptSequence,
GodotVisualScriptSwitch, GodotVisualScriptSelect,
GodotVisualScriptYield, GodotVisualScriptYieldSignal,
GodotVisualScriptBuiltinFunc, GodotVisualScriptExpression,
Godot_VisualScriptEditor, GodotVideoStreamWebm,
GodotWebSocketMultiplayerPeer, GodotWebSocketServer,
GodotWebSocketClient, GodotWebSocketPeer, GodotBulletPhysicsServer,
GodotBulletPhysicsDirectBodyState, GodotPhysics2DServerSW,
GodotPhysics2DDirectBodyStateSW)
where
import Data.Coerce
import Foreign.C
import Godot.Internal.Dispatch
Expand Down

0 comments on commit 4e9f181

Please sign in to comment.