Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More frameworks #197

Merged
merged 34 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2dae669
macos: decouple more minor deps from appkit
progrium Aug 22, 2023
5a0275d
generate: fix possible extra : in setter name
progrium Aug 22, 2023
3e4dfd7
generate: explicitly skip class methods on protocols since they dont …
progrium Aug 22, 2023
bd87ab7
macos: add mps framework (w placeholder structs), plus structs to met…
progrium Aug 22, 2023
c662ea1
generate: special case undocumented superclass MPSGraphObject as NSOb…
progrium Aug 22, 2023
ff26a1c
generate: use any/latest minor version for major version of platform
progrium Aug 22, 2023
14ad4bb
macos: add mpsgraph framework
progrium Aug 22, 2023
192ac1f
generate: avoid trying to convert UInt types to NS
progrium Aug 22, 2023
fad3eff
generate: normalize strings so you can use package names against symb…
progrium Aug 22, 2023
01ad3d5
generate: use the framework being generated when symbol belongs to mu…
progrium Aug 22, 2023
f50536c
generate: add SInt8 and UInt8 as mapped to primitive types
progrium Aug 22, 2023
ccd964f
macos: add coremidi framework
progrium Aug 22, 2023
06267f8
generate: resolve aliases when checking if enum type is string
progrium Aug 22, 2023
2e307d4
macos: add vision framework
progrium Aug 22, 2023
7576740
macos: fix subclass demo for ventura by calling init on the subclass …
progrium Aug 22, 2023
24a6253
macos: add fileprovider framework
progrium Aug 22, 2023
a9dfc47
macos: add corevideo framework
progrium Aug 22, 2023
9862b31
macos: add coremedia framework
progrium Aug 22, 2023
9bd8800
macos: add coremediaio framework
progrium Aug 22, 2023
48e5a98
macos: add coreaudiotypes framework
progrium Aug 22, 2023
8027b40
macos: add quartz framework
progrium Aug 22, 2023
4118e68
macos: add contactsui framework
progrium Aug 22, 2023
d5ff7ad
generate: make needsallocate for functions simpler and more accurate
progrium Aug 22, 2023
d80f6b1
macos: add mediaplayer framework
progrium Aug 22, 2023
31dd9fe
macos: add avfoundation framework
progrium Aug 22, 2023
23e2c4c
macos: add avkit framework
progrium Aug 22, 2023
e063b24
macos: add missing types and placeholder structs to coremedia and cor…
progrium Aug 22, 2023
1006efb
macos: add coreaudio framework
progrium Aug 22, 2023
137bf82
macos: move wip frameworks with (mostly) circular dependency issues u…
progrium Aug 22, 2023
bead90e
Makefile: add test task
progrium Aug 22, 2023
028e9ac
generate: add methods to stats
progrium Aug 22, 2023
7de7652
macos: skip protocol imports for coremediaio and fileprovider for now
progrium Aug 22, 2023
eb4c6b2
generate: fix declparse to parse enums without { }
progrium Aug 22, 2023
9cacd18
macos: add sysconfig framework
progrium Aug 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ generate:
$(GOEXE) generate ./...
.PHONY: generate

test:
$(GOEXE) test ./...
.PHONY: test

clobber:
$(GOEXE) run ./generate/tools/clobbergen.go ./macos
.PHONY: clobber
Expand Down
4 changes: 4 additions & 0 deletions generate/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (db *Generator) ToClassGen(sym Symbol) *codegen.Class {
}
}
if st.Interface.SuperName != "" {
// MPSGraphObject not documented, but we should assume its at least similar to NSObject
if st.Interface.SuperName == "MPSGraphObject" {
st.Interface.SuperName = "NSObject"
}
if st.Interface.SuperName == "NSObject" {
classGen.Super = &codegen.Class{
Type: typing.Object,
Expand Down
10 changes: 9 additions & 1 deletion generate/codegen/aliasinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ type AliasInfo struct {

// IsString return if is a string type Enum
func (e *AliasInfo) IsString() bool {
_, ok := e.Type.(*typing.StringType)
t := e.Type
for {
at, ok := t.(*typing.AliasType)
if !ok {
break
}
t = at.Type
}
_, ok := t.(*typing.StringType)
return ok
}

Expand Down
4 changes: 2 additions & 2 deletions generate/codegen/gen_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (m *Method) needRelease() bool {
case *typing.PrimitiveType, *typing.StringType:
return false
}
return strings.HasPrefix(m.Name, "new") || !strings.HasPrefix(m.Name, "init") && strings.HasPrefix(m.Name, "Initial") ||
strings.HasPrefix(m.Name, "copy") || strings.HasPrefix(m.Name, "mutableCopy")
//!strings.HasPrefix(m.Name, "init") && strings.HasPrefix(m.Name, "Initial")
return m.Name == "new" || m.Name == "copy" || m.Name == "mutableCopy"
}

// Selector return full Objc function name
Expand Down
6 changes: 4 additions & 2 deletions generate/codegen/gen_property.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package codegen

import (
"strings"

"github.com/progrium/macdriver/generate/typing"
"github.com/progrium/macdriver/internal/stringx"
)
Expand Down Expand Up @@ -49,11 +51,11 @@ func (p *Property) getter() *Method {
func (p *Property) setter() *Method {
name := "set" + stringx.Capitalize(p.Name)
if p.SetterName != "" {
name = p.SetterName
name = strings.TrimSuffix(p.SetterName, ":")
}
goName := "set" + stringx.Capitalize(p.GoName)
if p.SetterName != "" {
goName = p.SetterName
goName = strings.TrimSuffix(p.SetterName, ":")
}
return &Method{
Name: name,
Expand Down
12 changes: 12 additions & 0 deletions generate/codegen/gen_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func (p *Protocol) writeProtocolInterface(w *CodeWriter) {
}
}
for _, m := range p.allMethods() {
// don't support class methods on protocols yet
if m.ClassMethod {
continue
}
if !m.Required {
w.WriteLine("// optional")
} else {
Expand Down Expand Up @@ -176,6 +180,10 @@ func (p *Protocol) writeDelegateStruct(w *CodeWriter) {

receiver := "di"
for _, m := range p.allMethods() {
// don't support class methods on protocols yet
if m.ClassMethod {
continue
}
if !m.Required {
w.WriteLine(fmt.Sprintf("func (%s *%s) Has%s() bool {", receiver, implStructName, m.ProtocolGoFuncName()))
w.WriteLine(fmt.Sprintf("\t return %s._%s != nil", receiver, m.ProtocolGoFuncName()))
Expand Down Expand Up @@ -235,6 +243,10 @@ func (p *Protocol) writeProtocolWrapperStruct(w *CodeWriter) {
w.WriteLine("}")

for _, m := range p.allMethods() {
// don't support class methods on protocols yet
if m.ClassMethod {
continue
}
w.WriteLine("")
if !m.Required {
receiver := strings.ToLower(typeName[0:1] + "_")
Expand Down
8 changes: 8 additions & 0 deletions generate/codegen/modulewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ func (m *ModuleWriter) WriteCode() {
// get "cannot find protocol declaration" with protocol imports
return
}
if m.Module.Package == "coremediaio" {
// get "cannot find protocol declaration" with protocol imports
return
}
if m.Module.Package == "fileprovider" {
// get "cannot find protocol declaration" with protocol imports
return
}
m.WriteProtocolsImportCode()
}

Expand Down
14 changes: 14 additions & 0 deletions generate/declparse/declparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ var tests = []struct {
},
},

{
ParseOnly: true,
s: `typedef enum SCPreferencesNotification : uint32_t SCPreferencesNotification;`,
n: &Statement{
Enum: &EnumDecl{
Name: "SCPreferencesNotification",
Type: TypeInfo{
Name: "uint32_t",
},
},
Typedef: "SCPreferencesNotification",
},
},

{
ParseOnly: true,
// notice eNum is "enum"
Expand Down
3 changes: 2 additions & 1 deletion generate/declparse/parser_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func parseEnum(p *Parser) (next stateFn, node Node, err error) {
}

if err := p.expectToken(lexer.LCURLY); err != nil {
return nil, nil, err
p.tb.Unscan()
return nil, decl, nil
}

if err = p.expectToken(lexer.VARARG); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion generate/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (db *Generator) ResolveTypeAlias(typeName string) (declparse.TypeInfo, bool

func (db *Generator) TypeFromSymbolName(name string) typing.Type {
// hardcoded for now
if db.Platform == "macos" && strings.HasPrefix(name, "UI") {
if db.Platform == "macos" && strings.HasPrefix(name, "UI") && !strings.HasPrefix(name, "UInt") {
name = "NS" + strings.TrimPrefix(name, "UI")
}
s := db.FindTypeSymbol(name)
Expand Down
124 changes: 124 additions & 0 deletions generate/modules/enums/macos/mediaplayer
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
MPChangeLanguageOptionSettingNone 0
MPChangeLanguageOptionSettingNowPlayingItemOnly 1
MPChangeLanguageOptionSettingPermanent 2
MPErrorCancelled 6
MPErrorCloudServiceCapabilityMissing 2
MPErrorNetworkConnectionFailed 3
MPErrorNotFound 4
MPErrorNotSupported 5
MPErrorPermissionDenied 1
MPErrorRequestTimedOut 7
MPErrorUnknown 0
MPMediaTypeAny -1
MPMediaTypeAnyAudio 255
MPMediaTypeAnyVideo 65280
MPMediaTypeAudioBook 4
MPMediaTypeAudioITunesU 8
MPMediaTypeHomeVideo 8192
MPMediaTypeMovie 256
MPMediaTypeMusic 1
MPMediaTypeMusicVideo 2048
MPMediaTypePodcast 2
MPMediaTypeTVShow 512
MPMediaTypeVideoITunesU 4096
MPMediaTypeVideoPodcast 1024
MPNowPlayingInfoLanguageOptionTypeAudible 0
MPNowPlayingInfoLanguageOptionTypeLegible 1
MPNowPlayingInfoMediaTypeAudio 1
MPNowPlayingInfoMediaTypeNone 0
MPNowPlayingInfoMediaTypeVideo 2
MPNowPlayingPlaybackStateInterrupted 4
MPNowPlayingPlaybackStatePaused 2
MPNowPlayingPlaybackStatePlaying 1
MPNowPlayingPlaybackStateStopped 3
MPNowPlayingPlaybackStateUnknown 0
MPRemoteCommandHandlerStatusCommandFailed 200
MPRemoteCommandHandlerStatusDeviceNotFound 120
MPRemoteCommandHandlerStatusNoActionableNowPlayingItem 110
MPRemoteCommandHandlerStatusNoSuchContent 100
MPRemoteCommandHandlerStatusSuccess 0
MPRepeatTypeAll 2
MPRepeatTypeOff 0
MPRepeatTypeOne 1
MPSeekCommandEventTypeBeginSeeking 0
MPSeekCommandEventTypeEndSeeking 1
MPShuffleTypeCollections 2
MPShuffleTypeItems 1
MPShuffleTypeOff 0
MPErrorDomain MPErrorDomain
MPLanguageOptionCharacteristicContainsOnlyForcedSubtitles public.subtitles.forced-only
MPLanguageOptionCharacteristicDescribesMusicAndSound public.accessibility.describes-music-and-sound
MPLanguageOptionCharacteristicDescribesVideo public.accessibility.describes-video
MPLanguageOptionCharacteristicDubbedTranslation public.translation.dubbed
MPLanguageOptionCharacteristicEasyToRead public.easy-to-read
MPLanguageOptionCharacteristicIsAuxiliaryContent public.auxiliary-content
MPLanguageOptionCharacteristicIsMainProgramContent public.main-program-content
MPLanguageOptionCharacteristicLanguageTranslation public.translation
MPLanguageOptionCharacteristicTranscribesSpokenDialog public.accessibility.transcribes-spoken-dialog
MPLanguageOptionCharacteristicVoiceOverTranslation public.translation.voice-over
MPMediaEntityPropertyPersistentID persistentID
MPMediaItemPropertyAlbumArtist albumArtist
MPMediaItemPropertyAlbumArtistPersistentID albumArtistPID
MPMediaItemPropertyAlbumPersistentID albumPID
MPMediaItemPropertyAlbumTitle albumTitle
MPMediaItemPropertyAlbumTrackCount albumTrackCount
MPMediaItemPropertyAlbumTrackNumber albumTrackNumber
MPMediaItemPropertyArtist artist
MPMediaItemPropertyArtistPersistentID artistPID
MPMediaItemPropertyArtwork artwork
MPMediaItemPropertyAssetURL assetURL
MPMediaItemPropertyBeatsPerMinute beatsPerMinute
MPMediaItemPropertyBookmarkTime bookmarkTime
MPMediaItemPropertyComments comments
MPMediaItemPropertyComposer composer
MPMediaItemPropertyComposerPersistentID composerPID
MPMediaItemPropertyDateAdded dateAdded
MPMediaItemPropertyDiscCount discCount
MPMediaItemPropertyDiscNumber discNumber
MPMediaItemPropertyGenre genre
MPMediaItemPropertyGenrePersistentID genrePID
MPMediaItemPropertyHasProtectedAsset hasProtectedAsset
MPMediaItemPropertyIsCloudItem isCloudItem
MPMediaItemPropertyIsCompilation isCompilation
MPMediaItemPropertyIsExplicit isExplicit
MPMediaItemPropertyIsPreorder isPreorder
MPMediaItemPropertyLastPlayedDate lastPlayedDate
MPMediaItemPropertyLyrics lyrics
MPMediaItemPropertyMediaType mediaType
MPMediaItemPropertyPersistentID persistentID
MPMediaItemPropertyPlayCount playCount
MPMediaItemPropertyPlaybackDuration playbackDuration
MPMediaItemPropertyPlaybackStoreID playbackStoreID
MPMediaItemPropertyPodcastPersistentID podcastPID
MPMediaItemPropertyPodcastTitle podcastTitle
MPMediaItemPropertyRating rating
MPMediaItemPropertyReleaseDate releaseDate
MPMediaItemPropertySkipCount skipCount
MPMediaItemPropertyTitle title
MPMediaItemPropertyUserGrouping userGrouping
MPMediaPlaybackIsPreparedToPlayDidChangeNotification MPMediaPlaybackIsPreparedToPlayDidChangeNotification
MPMediaPlaylistPropertyAuthorDisplayName externalVendorDisplayName
MPMediaPlaylistPropertyCloudGlobalID cloudGlobalID
MPMediaPlaylistPropertyDescriptionText descriptionInfo
MPMediaPlaylistPropertyName name
MPMediaPlaylistPropertyPersistentID playlistPersistentID
MPMediaPlaylistPropertyPlaylistAttributes playlistAttributes
MPMediaPlaylistPropertySeedItems seedItems
MPNowPlayingInfoCollectionIdentifier MPNowPlayingInfoCollectionIdentifier
MPNowPlayingInfoPropertyAssetURL MPNowPlayingInfoPropertyAssetURL
MPNowPlayingInfoPropertyAvailableLanguageOptions MPNowPlayingInfoPropertyAvailableLanguageOptions
MPNowPlayingInfoPropertyChapterCount MPNowPlayingInfoPropertyChapterCount
MPNowPlayingInfoPropertyChapterNumber MPNowPlayingInfoPropertyChapterNumber
MPNowPlayingInfoPropertyCurrentLanguageOptions MPNowPlayingInfoPropertyCurrentLanguageOption
MPNowPlayingInfoPropertyCurrentPlaybackDate MPNowPlayingInfoPropertyCurrentPlaybackDate
MPNowPlayingInfoPropertyDefaultPlaybackRate MPNowPlayingInfoPropertyDefaultPlaybackRate
MPNowPlayingInfoPropertyElapsedPlaybackTime MPNowPlayingInfoPropertyElapsedPlaybackTime
MPNowPlayingInfoPropertyExternalContentIdentifier MPNowPlayingInfoPropertyExternalContentIdentifier
MPNowPlayingInfoPropertyExternalUserProfileIdentifier MPNowPlayingInfoPropertyExternalUserProfileIdentifier
MPNowPlayingInfoPropertyIsLiveStream MPNowPlayingInfoPropertyIsLiveStream
MPNowPlayingInfoPropertyMediaType MPNowPlayingInfoPropertyMediaType
MPNowPlayingInfoPropertyPlaybackProgress MPNowPlayingInfoPropertyPlaybackProgress
MPNowPlayingInfoPropertyPlaybackQueueCount MPNowPlayingInfoPropertyPlaybackQueueCount
MPNowPlayingInfoPropertyPlaybackQueueIndex MPNowPlayingInfoPropertyPlaybackQueueIndex
MPNowPlayingInfoPropertyPlaybackRate MPNowPlayingInfoPropertyPlaybackRate
MPNowPlayingInfoPropertyServiceIdentifier MPNowPlayingInfoPropertyServiceIdentifier
Loading
Loading