Skip to content

Commit

Permalink
Merge pull request #146 from bryanedds/symbolics
Browse files Browse the repository at this point in the history
Symbolics

Former-commit-id: 87dd650
  • Loading branch information
bryanedds committed Mar 12, 2016
2 parents 8618b7e + f39b26f commit 6d13c74
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 117 deletions.
198 changes: 100 additions & 98 deletions Nu/Nu/Nu.Gaia.Design/GaiaForm.Designer.cs

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions Nu/Nu/Nu.Gaia/GaiaModules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ module Gaia =
form.propertyEditor.Enabled <- true
form.propertyNameLabel.Text <- scstring selectedGridItem.Label
form.propertyDescriptionTextBox.Text <- selectedGridItem.PropertyDescriptor.Description
let str = typeConverter.ConvertToString selectedGridItem.Value
let strPretty = SymbolIndex.prettyPrint str
let strUnescaped = typeConverter.ConvertToString selectedGridItem.Value
let strEscaped = String.escape strUnescaped
let strPretty = SymbolIndex.prettyPrint strEscaped
form.propertyValueTextBox.Text <- strPretty
// NOTE: can probably use form.propertyValueTextBox.Rtf to highlight matching brace
| _ ->
Expand All @@ -318,7 +319,9 @@ module Gaia =
| GridItemType.Property when form.propertyNameLabel.Text = selectedGridItem.Label ->
let propertyDescriptor = selectedGridItem.PropertyDescriptor :?> EntityPropertyDescriptor
let typeConverter = SymbolicConverter (selectedGridItem.PropertyDescriptor.PropertyType)
try let propertyValue = typeConverter.ConvertFromString form.propertyValueTextBox.Text
try let strEscaped = form.propertyValueTextBox.Text
let strUnescaped = String.unescape strEscaped
let propertyValue = typeConverter.ConvertFromString strUnescaped
propertyDescriptor.SetValue (entityTds, propertyValue)
with exn -> Log.trace ^ "Invalid apply property operation due to: " + scstring exn
| _ -> Log.trace "Invalid apply property operation (likely a code issue in Gaia)."
Expand Down
38 changes: 32 additions & 6 deletions Nu/Nu/Nu/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Nu
open System
open OpenTK
open Prime
open global.Nu // TODO: see if this req'd explicit qualification is due to a compiler bug
open Nu.Tests
module Program =
Expand Down Expand Up @@ -113,15 +115,39 @@ module Program =
Perhaps not realistic, but just an idea. *)

(* IDEA: it was suggested that time-travel debugging a la Elm or http://vimeo.com/36579366
would be appropriate to this engine given its pure functional nature. However, due to the
imperative nature of the physics system, it could be problematic. However again, that doesn't
mean the idea isn't worth pursuing for while it might not work perfectly in all usage
scenarios, it may well be of sufficient value. Additionally, on the possible occasion that the
current physics engine be replaceable with pure functional one, improvements to the feature may
be implementable in time. *)
would be appropriate to this engine given its pure functional nature. *)

(* TODO: investigate Gaia extensibility mechanism. *)

type [<ReferenceEquality>] EntityDescriptor =
{ DispatcherName : string
Fields : Map<string, string> }

type [<ReferenceEquality>] GroupDescriptor =
{ DispatcherName : string
Fields : Map<string, string>
Entities : EntityDescriptor list }

let Entity<'d> (fields : (string * string) list) =
{ EntityDescriptor.DispatcherName = typeof<'d>.Name
Fields = Map.ofSeq fields }

let Group<'d> (fields : (string * string) list) (entities : EntityDescriptor list) =
{ GroupDescriptor.DispatcherName = typeof<'d>.Name
Fields = Map.ofSeq fields
Entities = entities }

let [<EntryPoint; STAThread>] main _ =
Console.WriteLine "Running Nu.exe"
Nu.init false
let group =
Group<GroupDispatcher>
[field? Name !!"Group"]
[Entity<EntityDispatcher>
[field? Name !!"Jim"
field? Size Vector2.Zero]
Entity<EntityDispatcher>
[field? Name !!"Bob"
field? Size Vector2.Zero]]
Console.WriteLine (SymbolIndex.prettyPrint ^ scstring group)
Constants.Engine.SuccessExitCode
28 changes: 20 additions & 8 deletions Nu/Nu/Nu/Reflection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,43 @@ module FieldDefinition =
result

/// In tandem with the define literal, grants a nice syntax to define constant fields.
type DefineConstant =
{ DefineConstant : unit }
type ConstantDefinition =
{ ConstantDefinition : unit }

/// Some magic syntax for composing constant fields.
static member (?) (_, fieldName) =
fun (constant : 'c) ->
FieldDefinition.makeValidated fieldName typeof<'c> ^ Constant constant

/// In tandem with the variable literal, grants a nice syntax to define variable fields.
type DefineVariable =
{ DefineVariable : unit }
type VariableDefinition =
{ VariableDefinition : unit }

/// Some magic syntax for composing variable fields.
static member (?) (_, fieldName) =
fun (variable : unit -> 'v) ->
FieldDefinition.makeValidated fieldName typeof<'v> ^ Variable (fun () -> variable () :> obj)

/// In tandem with the define literal, grants a nice syntax to define field descriptors.
type FieldDescriptor =
{ FieldDescriptor : unit }

/// Some magic syntax for composing constant fields.
static member (?) (_, fieldName : string) =
fun (value : 'v) ->
(fieldName, scstring value)

[<AutoOpen>]
module ReflectionModule =

/// In tandem with the DefineConstant type, grants a nice syntax to define constant fields.
let define = { DefineConstant = () }
/// In tandem with the ConstantDefinition type, grants a nice syntax to define constant fields.
let define = { ConstantDefinition = () }

/// In tandem with the VariableDefinition type, grants a nice syntax to define variable fields.
let variable = { VariableDefinition = () }

/// In tandem with the DefineVariable type, grants a nice syntax to define variable fields.
let variable = { DefineVariable = () }
/// In tandem with the FieldDescriptor type, grants a nice syntax to define field descriptors.
let field = { FieldDescriptor = () }

[<RequireQualifiedAccess>]
module Reflection =
Expand Down
2 changes: 0 additions & 2 deletions Nu/Nu/Nu/Sdl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ module SdlDepsModule =
[<RequireQualifiedAccess>]
module Sdl =

let private resourceNop (_ : nativeint) = ()

/// Update the game engine's state.
let update handleEvent handleUpdate world =
if SDL.SDL_WasInit SDL.SDL_INIT_TIMER <> 0u then
Expand Down
10 changes: 10 additions & 0 deletions Nu/Prime/Debug/Prime.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Nu/Prime/Debug/Prime.exe
Binary file not shown.
Binary file modified Nu/Prime/Debug/Prime.pdb
Binary file not shown.
10 changes: 10 additions & 0 deletions Nu/Prime/Release/Prime.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Nu/Prime/Release/Prime.exe
Binary file not shown.
Binary file modified Nu/Prime/Release/Prime.pdb
Binary file not shown.

0 comments on commit 6d13c74

Please sign in to comment.